Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 01/24] fftools/ffmpeg_mux_init: merge ost_add_from_filter() to ost_add()
@ 2023-05-28  9:13 Anton Khirnov
  2023-05-28  9:13 ` [FFmpeg-devel] [PATCH 02/24] fftools/ffmpeg: add logging for creating output streams Anton Khirnov
                   ` (22 more replies)
  0 siblings, 23 replies; 27+ messages in thread
From: Anton Khirnov @ 2023-05-28  9:13 UTC (permalink / raw)
  To: ffmpeg-devel

This way ost_add() knows about the complex filtergraph it is fed from,
which will become useful in future commits.
---
 fftools/ffmpeg_mux_init.c | 71 ++++++++++++++++++---------------------
 1 file changed, 32 insertions(+), 39 deletions(-)

diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 7878789bb4..de39b360af 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -985,7 +985,8 @@ fail:
 }
 
 static OutputStream *ost_add(Muxer *mux, const OptionsContext *o,
-                             enum AVMediaType type, InputStream *ist)
+                             enum AVMediaType type, InputStream *ist,
+                             OutputFilter *ofilter)
 {
     AVFormatContext *oc = mux->fc;
     MuxStream     *ms;
@@ -1040,6 +1041,14 @@ static OutputStream *ost_add(Muxer *mux, const OptionsContext *o,
         av_strlcat(ms->log_name, "/",       sizeof(ms->log_name));
         av_strlcat(ms->log_name, enc->name, sizeof(ms->log_name));
     } else {
+        if (ofilter) {
+            av_log(ost, AV_LOG_ERROR,
+                   "Streamcopy requested for output stream fed "
+                   "from a complex filtergraph. Filtering and streamcopy "
+                   "cannot be used together.\n");
+            exit_program(1);
+        }
+
         av_strlcat(ms->log_name, "/copy", sizeof(ms->log_name));
     }
 
@@ -1233,22 +1242,26 @@ static OutputStream *ost_add(Muxer *mux, const OptionsContext *o,
             exit_program(1);
     }
 
-    if (ost->ist) {
-        if (ost->enc &&
-            (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) {
+    if (ost->enc &&
+        (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) {
+        if (ofilter) {
+            ost->filter       = ofilter;
+            ofilter->ost      = ost;
+            avfilter_inout_free(&ofilter->out_tmp);
+        } else {
             ret = init_simple_filtergraph(ost->ist, ost);
             if (ret < 0) {
                 av_log(ost, AV_LOG_ERROR,
                        "Error initializing a simple filtergraph\n");
                 exit_program(1);
             }
-        } else {
-            ret = ist_output_add(ost->ist, ost);
-            if (ret < 0) {
-                av_log(ost, AV_LOG_ERROR,
-                       "Error binding an input stream\n");
-                exit_program(1);
-            }
+        }
+    } else if (ost->ist) {
+        ret = ist_output_add(ost->ist, ost);
+        if (ret < 0) {
+            av_log(ost, AV_LOG_ERROR,
+                   "Error binding an input stream\n");
+            exit_program(1);
         }
     }
 
@@ -1261,26 +1274,6 @@ static OutputStream *ost_add(Muxer *mux, const OptionsContext *o,
     return ost;
 }
 
-// add a new output stream fed by the provided filtergraph output
-static void ost_add_from_filter(OutputFilter *ofilter, const OptionsContext *o,
-                               Muxer *mux)
-{
-    OutputStream *ost = ost_add(mux, o, ofilter->type, NULL);
-
-    ost->filter       = ofilter;
-
-    ofilter->ost      = ost;
-
-    if (!ost->enc_ctx) {
-        av_log(ost, AV_LOG_ERROR, "Streamcopy requested for output stream fed "
-               "from a complex filtergraph. Filtering and streamcopy "
-               "cannot be used together.\n");
-        exit_program(1);
-    }
-
-    avfilter_inout_free(&ofilter->out_tmp);
-}
-
 static void map_auto_video(Muxer *mux, const OptionsContext *o)
 {
     AVFormatContext *oc = mux->fc;
@@ -1329,7 +1322,7 @@ static void map_auto_video(Muxer *mux, const OptionsContext *o)
        }
     }
     if (best_ist)
-        ost_add(mux, o, AVMEDIA_TYPE_VIDEO, best_ist);
+        ost_add(mux, o, AVMEDIA_TYPE_VIDEO, best_ist, NULL);
 }
 
 static void map_auto_audio(Muxer *mux, const OptionsContext *o)
@@ -1371,7 +1364,7 @@ static void map_auto_audio(Muxer *mux, const OptionsContext *o)
        }
     }
     if (best_ist)
-        ost_add(mux, o, AVMEDIA_TYPE_AUDIO, best_ist);
+        ost_add(mux, o, AVMEDIA_TYPE_AUDIO, best_ist, NULL);
 }
 
 static void map_auto_subtitle(Muxer *mux, const OptionsContext *o)
@@ -1406,7 +1399,7 @@ static void map_auto_subtitle(Muxer *mux, const OptionsContext *o)
                 input_descriptor && output_descriptor &&
                 (!input_descriptor->props ||
                  !output_descriptor->props)) {
-                ost_add(mux, o, AVMEDIA_TYPE_SUBTITLE, ist);
+                ost_add(mux, o, AVMEDIA_TYPE_SUBTITLE, ist, NULL);
                 break;
             }
         }
@@ -1426,7 +1419,7 @@ static void map_auto_data(Muxer *mux, const OptionsContext *o)
             continue;
         if (ist->st->codecpar->codec_type == AVMEDIA_TYPE_DATA &&
             ist->st->codecpar->codec_id == codec_id )
-            ost_add(mux, o, AVMEDIA_TYPE_DATA, ist);
+            ost_add(mux, o, AVMEDIA_TYPE_DATA, ist, NULL);
     }
 }
 
@@ -1458,7 +1451,7 @@ loop_end:
                    "in any defined filter graph, or was already used elsewhere.\n", map->linklabel);
             exit_program(1);
         }
-        ost_add_from_filter(ofilter, o, mux);
+        ost_add(mux, o, ofilter->type, NULL, ofilter);
     } else {
         ist = input_files[map->file_index]->streams[map->stream_index];
         if (ist->user_set_discard == AVDISCARD_ALL) {
@@ -1490,7 +1483,7 @@ loop_end:
             return;
         }
 
-        ost_add(mux, o, ist->st->codecpar->codec_type, ist);
+        ost_add(mux, o, ist->st->codecpar->codec_type, ist, NULL);
     }
 }
 
@@ -1524,7 +1517,7 @@ static void of_add_attachments(Muxer *mux, const OptionsContext *o)
         avio_read(pb, attachment, len);
         memset(attachment + len, 0, AV_INPUT_BUFFER_PADDING_SIZE);
 
-        ost = ost_add(mux, o, AVMEDIA_TYPE_ATTACHMENT, NULL);
+        ost = ost_add(mux, o, AVMEDIA_TYPE_ATTACHMENT, NULL, NULL);
         ost->attachment_filename       = o->attachments[i];
         ost->par_in->extradata         = attachment;
         ost->par_in->extradata_size    = len;
@@ -1557,7 +1550,7 @@ static void create_streams(Muxer *mux, const OptionsContext *o)
             case AVMEDIA_TYPE_AUDIO:    auto_disable_a = 1; break;
             case AVMEDIA_TYPE_SUBTITLE: auto_disable_s = 1; break;
             }
-            ost_add_from_filter(ofilter, o, mux);
+            ost_add(mux, o, ofilter->type, NULL, ofilter);
         }
     }
 
-- 
2.40.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2023-05-31 17:03 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-28  9:13 [FFmpeg-devel] [PATCH 01/24] fftools/ffmpeg_mux_init: merge ost_add_from_filter() to ost_add() Anton Khirnov
2023-05-28  9:13 ` [FFmpeg-devel] [PATCH 02/24] fftools/ffmpeg: add logging for creating output streams Anton Khirnov
2023-05-28  9:13 ` [FFmpeg-devel] [PATCH 03/24] fftools/ffmpeg_filter: use a dedicated variable for marking simple filtergraphs Anton Khirnov
2023-05-28  9:13 ` [FFmpeg-devel] [PATCH 04/24] fftools/ffmpeg_filter: always pass graph description to fg_create() Anton Khirnov
2023-05-28  9:13 ` [FFmpeg-devel] [PATCH 05/24] fftools/ffmpeg_filter: store just the link label in OutputFilter Anton Khirnov
2023-05-28  9:13 ` [FFmpeg-devel] [PATCH 06/24] fftools/ffmpeg_filter: decouple allocating InputFilter and binding it to InputStream Anton Khirnov
2023-05-28  9:13 ` [FFmpeg-devel] [PATCH 07/24] fftools/ffmpeg_filter: move some functions higher up Anton Khirnov
2023-05-28  9:14 ` [FFmpeg-devel] [PATCH 08/24] fftools/ffmpeg_filter: create Input/OutputFilters together with FilterGraph Anton Khirnov
2023-05-28  9:14 ` [FFmpeg-devel] [PATCH 09/24] fftools/ffmpeg_filter: factor out binding an output stream to OutputFilter Anton Khirnov
2023-05-28  9:14 ` [FFmpeg-devel] [PATCH 10/24] fftools/ffmpeg_mux_init: move OutputFilter setup code to ffmpeg_filter Anton Khirnov
2023-05-28  9:14 ` [FFmpeg-devel] [PATCH 11/24] fftools/ffmpeg_filter: try to configure filtergraphs earlier Anton Khirnov
2023-05-28  9:14 ` [FFmpeg-devel] [PATCH 12/24] fftools/ffmpeg: constify AVSubtitle parameters as appropriate Anton Khirnov
2023-05-28  9:14 ` [FFmpeg-devel] [PATCH 13/24] fftools/ffmpeg_dec: move sub2video submission to ffmpeg_filter Anton Khirnov
2023-05-28  9:14 ` [FFmpeg-devel] [PATCH 14/24] fftools/ffmpeg_filter: move sub2video subtitle queue to InputFilterPriv Anton Khirnov
2023-05-28  9:14 ` [FFmpeg-devel] [PATCH 15/24] fftools/ffmpeg: tweak sub2video_heartbeat() arguments Anton Khirnov
2023-05-28  9:14 ` [FFmpeg-devel] [PATCH 16/24] fftools/ffmpeg: rework setting sub2video parameters Anton Khirnov
2023-05-28 19:43   ` Michael Niedermayer
2023-05-29 12:49     ` [FFmpeg-devel] [PATCH] " Anton Khirnov
2023-05-31 17:02       ` Michael Niedermayer
2023-05-28  9:14 ` [FFmpeg-devel] [PATCH 17/24] fftools/ffmpeg: move sub2video handling to ffmpeg_filter Anton Khirnov
2023-05-28  9:14 ` [FFmpeg-devel] [PATCH 18/24] fftools/ffmpeg_enc: stop configuring filters from encoder flush Anton Khirnov
2023-05-28  9:14 ` [FFmpeg-devel] [PATCH 19/24] fftools/ffmpeg_filter: drop unreachable code Anton Khirnov
2023-05-28  9:14 ` [FFmpeg-devel] [PATCH 20/24] fftools/ffmpeg_filter: make ifilter_has_all_input_formats() static Anton Khirnov
2023-05-28  9:14 ` [FFmpeg-devel] [PATCH 21/24] fftools/ffmpeg_filter: make InputStream.filter private Anton Khirnov
2023-05-28  9:14 ` [FFmpeg-devel] [PATCH 22/24] fftools/ffmpeg_filter: constify the argument of filtergraph_is_simple() Anton Khirnov
2023-05-28  9:14 ` [FFmpeg-devel] [PATCH 23/24] fftools/ffmpeg_mux: flush bsfs immediately on exceeding recoding time Anton Khirnov
2023-05-28  9:14 ` [FFmpeg-devel] [PATCH 24/24] fftools/ffmpeg_filter: do not flush encoders on parameter change Anton Khirnov

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git