From patchwork Wed Jul 12 09:06:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgQsWTc2No?= X-Patchwork-Id: 4305 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.1.76 with SMTP id 73csp542127vsb; Wed, 12 Jul 2017 02:07:12 -0700 (PDT) X-Received: by 10.223.170.7 with SMTP id p7mr2067646wrd.79.1499850432363; Wed, 12 Jul 2017 02:07:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499850432; cv=none; d=google.com; s=arc-20160816; b=aFrdKqc3DHQFq0QhsQn3CaLeqF/39qAGx5HF2j6Jsv5WkVyCS8GWwiztt5TSRA+9sv u0Oa+8nlPgrNwWJNZlJgVnUtrfXopHRMIvb56STMLL1DZEF+iyMT1lJMGH4zrOi9ihen VpzqrxH1KC+kAfVYKm2lc/38eoCk5cL/mX6Kg6VKpW204h+pckFmS/sBLKpRyvObt9hj FW5ODAHthyTbnbV+fLa2APAu0/J5COkfqhIBLVJjHd1cVKldDe0PwF67Ho6X9fx2uFN4 laX86GJ0R+x7aJ9fI0DNkp4tfW8Ejuw2+CSDRqds62oXj0pRKS3yhPAZXleC7oAToU9y Id/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:delivered-to :arc-authentication-results; bh=b3+/T048thLa54bp5eksqL11U31DwokTGC+Z6nxqFFI=; b=o9qCY0Pw5MFOQBx9b4XJjlvVpPmEsNUEdrrULJg34os/TCefcqrO3Iso0iXPHMY9mn gtRETo24ErUemHbbby+/oVHuCO5tHgrKzx8fj4AoI8YEtPoanbO9/HPQHl2enMvnh+up kmWjMfUy+pNebvcB98P1U6AYX6nSQny7AVi+NQsl3faxDTN5bbMzWt/8B1dVhFGB1zWG MpWQqokTfz54SkzEn9PGhdvEuzwqAsxeFimZVaQoCdM3UdQFU/MoJ0sw3rerFDSxui06 PTkFWUWs2Hxy4tzIN06/1s87hFjeavJMd96HSU5WPgJHq6mxh/4sxaCaGJPM8Ahpv3by Lq7g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id t15si1670243wme.83.2017.07.12.02.07.11; Wed, 12 Jul 2017 02:07:12 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AE5CE689A70; Wed, 12 Jul 2017 12:07:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from golem.pkh.me (LStLambert-657-1-117-164.w92-154.abo.wanadoo.fr [92.154.28.164]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AD63E6891DD for ; Wed, 12 Jul 2017 12:06:56 +0300 (EEST) Received: from localhost (golem.pkh.me [local]) by golem.pkh.me (OpenSMTPD) with ESMTPA id 86ded10e; Wed, 12 Jul 2017 09:07:01 +0000 (UTC) From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= To: ffmpeg-devel@ffmpeg.org Date: Wed, 12 Jul 2017 11:06:52 +0200 Message-Id: <20170712090655.2964-1-u@pkh.me> X-Mailer: git-send-email 2.13.2 Subject: [FFmpeg-devel] [PATCH 1/3] ffmpeg: add -(no)find_stream_info expert option 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: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- ffmpeg_opt.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c index 9b7e8c74b9..10ca260648 100644 --- a/ffmpeg_opt.c +++ b/ffmpeg_opt.c @@ -145,6 +145,7 @@ static int override_ffserver = 0; static int input_stream_potentially_available = 0; static int ignore_unknown_streams = 0; static int copy_unknown_streams = 0; +static int find_stream_info = 1; static void uninit_options(OptionsContext *o) { @@ -949,10 +950,8 @@ static int open_input_file(OptionsContext *o, const char *filename) AVInputFormat *file_iformat = NULL; int err, i, ret; int64_t timestamp; - AVDictionary **opts; AVDictionary *unused_opts = NULL; AVDictionaryEntry *e = NULL; - int orig_nb_streams; // number of streams before avformat_find_stream_info char * video_codec_name = NULL; char * audio_codec_name = NULL; char *subtitle_codec_name = NULL; @@ -1055,13 +1054,19 @@ static int open_input_file(OptionsContext *o, const char *filename) for (i = 0; i < ic->nb_streams; i++) choose_decoder(o, ic, ic->streams[i]); - /* Set AVCodecContext options for avformat_find_stream_info */ - opts = setup_find_stream_info_opts(ic, o->g->codec_opts); - orig_nb_streams = ic->nb_streams; + if (find_stream_info) { + AVDictionary **opts = setup_find_stream_info_opts(ic, o->g->codec_opts); + int orig_nb_streams = ic->nb_streams; + // TODO: reindent /* If not enough info to get the stream parameters, we decode the first frames to get it. (used in mpeg case for example) */ ret = avformat_find_stream_info(ic, opts); + + for (i = 0; i < orig_nb_streams; i++) + av_dict_free(&opts[i]); + av_freep(&opts); + if (ret < 0) { av_log(NULL, AV_LOG_FATAL, "%s: could not find codec parameters\n", filename); if (ic->nb_streams == 0) { @@ -1069,6 +1074,7 @@ static int open_input_file(OptionsContext *o, const char *filename) exit_program(1); } } + } if (o->start_time_eof != AV_NOPTS_VALUE) { if (ic->duration>0) { @@ -1180,10 +1186,6 @@ static int open_input_file(OptionsContext *o, const char *filename) } } - for (i = 0; i < orig_nb_streams; i++) - av_dict_free(&opts[i]); - av_freep(&opts); - input_stream_potentially_available = 1; return 0; @@ -3520,6 +3522,8 @@ const OptionDef options[] = { { "thread_queue_size", HAS_ARG | OPT_INT | OPT_OFFSET | OPT_EXPERT | OPT_INPUT, { .off = OFFSET(thread_queue_size) }, "set the maximum number of queued packets from the demuxer" }, + { "find_stream_info", OPT_BOOL | OPT_INPUT | OPT_EXPERT, { &find_stream_info }, + "read and decode the streams to fill missing information with heuristics" }, /* video options */ { "vframes", OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_video_frames },