[FFmpeg-cvslog] fftools/ffmpeg_opt: factor auto-mapping data streams out of open_output_file()

Anton Khirnov git at videolan.org
Thu Jul 28 18:02:18 EEST 2022


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Mon Jun 20 14:13:43 2022 +0200| [85692aeecb5a9cb8f8dce5482d5b709e26ff53a7] | committer: Anton Khirnov

fftools/ffmpeg_opt: factor auto-mapping data streams out of open_output_file()

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=85692aeecb5a9cb8f8dce5482d5b709e26ff53a7
---

 fftools/ffmpeg_opt.c | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 04f4abb88a..287527f478 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -2618,6 +2618,20 @@ static void map_auto_subtitle(OutputFile *of, AVFormatContext *oc,
         }
 }
 
+static void map_auto_data(OutputFile *of, AVFormatContext *oc,
+                          OptionsContext *o)
+{
+        /* Data only if codec id match */
+            enum AVCodecID codec_id = av_guess_codec(oc->oformat, NULL, oc->url, NULL, AVMEDIA_TYPE_DATA);
+            for (int i = 0; codec_id != AV_CODEC_ID_NONE && i < nb_input_streams; i++) {
+                if (input_streams[i]->user_set_discard == AVDISCARD_ALL)
+                    continue;
+                if (input_streams[i]->st->codecpar->codec_type == AVMEDIA_TYPE_DATA
+                    && input_streams[i]->st->codecpar->codec_id == codec_id )
+                    new_data_stream(o, oc, i);
+            }
+}
+
 static int open_output_file(OptionsContext *o, const char *filename)
 {
     AVFormatContext *oc;
@@ -2701,18 +2715,8 @@ static int open_output_file(OptionsContext *o, const char *filename)
             map_auto_audio(of, oc, o);
         if (!o->subtitle_disable)
             map_auto_subtitle(of, oc, o);
-
-        /* Data only if codec id match */
-        if (!o->data_disable ) {
-            enum AVCodecID codec_id = av_guess_codec(oc->oformat, NULL, filename, NULL, AVMEDIA_TYPE_DATA);
-            for (i = 0; codec_id != AV_CODEC_ID_NONE && i < nb_input_streams; i++) {
-                if (input_streams[i]->user_set_discard == AVDISCARD_ALL)
-                    continue;
-                if (input_streams[i]->st->codecpar->codec_type == AVMEDIA_TYPE_DATA
-                    && input_streams[i]->st->codecpar->codec_id == codec_id )
-                    new_data_stream(o, oc, i);
-            }
-        }
+        if (!o->data_disable)
+            map_auto_data(of, oc, o);
     } else {
         for (i = 0; i < o->nb_stream_maps; i++) {
             StreamMap *map = &o->stream_maps[i];



More information about the ffmpeg-cvslog mailing list