From patchwork Sat Feb 15 16:12:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Linjie" X-Patchwork-Id: 17792 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 8D81044AF3C for ; Sat, 15 Feb 2020 18:16:03 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6A9B7689C1D; Sat, 15 Feb 2020 18:16:03 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 92814687F1A for ; Sat, 15 Feb 2020 18:15:56 +0200 (EET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Feb 2020 08:15:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,445,1574150400"; d="scan'208";a="227942181" Received: from icl-dev.sh.intel.com ([10.239.158.73]) by orsmga008.jf.intel.com with ESMTP; 15 Feb 2020 08:15:52 -0800 From: Linjie Fu To: ffmpeg-devel@ffmpeg.org Date: Sun, 16 Feb 2020 00:12:57 +0800 Message-Id: <1581783177-10335-1-git-send-email-linjie.fu@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [FFmpeg-devel] [PATCH] fftools/ffmpeg_filter: add -autoscale to disable/enable the default scale X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Linjie Fu , "U . Artie Eoff" MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Currently, ffmpeg inserts scale filter by default in the filter graph to force the whole decoded stream to scale into the same size with the first frame. It's not quite make sense in resolution changing cases if user wants the rawvideo without any scale. Using autoscale/noautoscale as an output option to indicate whether auto inserting the scale filter in the filter graph: -noautoscale or -autoscale 0: disable the default auto scale filter inserting. ffmpeg -y input.mp4 out1.yuv -noautoscale out2.yuv -autoscale 0 out3.yuv Update docs. Signed-off-by: U. Artie Eoff Signed-off-by: Linjie Fu --- doc/ffmpeg.texi | 16 ++++++++++++---- fftools/ffmpeg.h | 3 +++ fftools/ffmpeg_filter.c | 2 +- fftools/ffmpeg_opt.c | 5 +++++ 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 29753f0..aebafb3 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -734,10 +734,6 @@ ffmpeg -dump_attachment:t "" -i INPUT Technical note -- attachments are implemented as codec extradata, so this option can actually be used to extract extradata from any stream, not just attachments. - -@item -noautorotate -Disable automatically rotating video based on file metadata. - @end table @section Video Options @@ -819,6 +815,18 @@ Create the filtergraph specified by @var{filtergraph} and use it to filter the stream. This is an alias for @code{-filter:v}, see the @ref{filter_option,,-filter option}. + +@item -autorotate +Automatically rotate the video according to file metadata. Enabled by +default, use @option{-noautorotate} to disable it. + +@item -autoscale +Automatically scale the video according to the resolution of first frame. +Enabled by default, use @option{-noautoscale} to disable it. When autoscale is +disabled, all output frames of filter graph might not be in the same resolution +and may be inadequate for some encoder/muxer. Therefore, it is not recommended +to disable it unless you really know what you are doing. +Disable autoscale at your own risk. @end table @section Advanced Video options diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 7b6f802..8beba6c 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -230,6 +230,8 @@ typedef struct OptionsContext { int nb_time_bases; SpecifierOpt *enc_time_bases; int nb_enc_time_bases; + SpecifierOpt *autoscale; + int nb_autoscale; } OptionsContext; typedef struct InputFilter { @@ -479,6 +481,7 @@ typedef struct OutputStream { int force_fps; int top_field_first; int rotate_overridden; + int autoscale; double rotate_override_value; AVRational frame_aspect_ratio; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 40cc4c1..46c8ea8 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -469,7 +469,7 @@ static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter, if (ret < 0) return ret; - if (ofilter->width || ofilter->height) { + if ((ofilter->width || ofilter->height) && ofilter->ost->autoscale) { char args[255]; AVFilterContext *filter; AVDictionaryEntry *e = NULL; diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 12d4488..a6f4216 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1405,6 +1405,8 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e ost->encoder_opts = filter_codec_opts(o->g->codec_opts, ost->enc->id, oc, st, ost->enc); MATCH_PER_STREAM_OPT(presets, str, preset, oc, st); + ost->autoscale = 1; + MATCH_PER_STREAM_OPT(autoscale, i, ost->autoscale, oc, st); if (preset && (!(ret = get_preset_file_2(preset, ost->enc->name, &s)))) { do { buf = get_line(s); @@ -3650,6 +3652,9 @@ const OptionDef options[] = { { "autorotate", HAS_ARG | OPT_BOOL | OPT_SPEC | OPT_EXPERT | OPT_INPUT, { .off = OFFSET(autorotate) }, "automatically insert correct rotate filters" }, + { "autoscale", HAS_ARG | OPT_BOOL | OPT_SPEC | + OPT_EXPERT | OPT_OUTPUT, { .off = OFFSET(autoscale) }, + "automatically insert a scale filter at the end of the filter graph" }, /* audio options */ { "aframes", OPT_AUDIO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_audio_frames },