Re: [FFmpeg-devel] [PATCH 13/13 v2] fftools/ffmpeg: convert to a threaded architecture
On Thu, Nov 30, 2023 at 02:34:59PM +0100, Anton Khirnov wrote: > Quoting Michael Niedermayer (2023-11-30 14:08:26) > > On Sat, Nov 25, 2023 at 09:32:06PM +0100, Anton Khirnov wrote: > > > Change the main loop and every component (demuxers, decoders, filters, > > > encoders, muxers) to use the previously added transcode scheduler. Every > > > instance of every such component was already running in a separate > > > thread, but now they can actually run in parallel. > > > > > > Changes the results of ffmpeg-fix_sub_duration_heartbeat - tested by > > > JEEB to be more correct and deterministic. > > > --- > > > fftools/ffmpeg.c | 374 + > > > fftools/ffmpeg.h | 97 +-- > > > fftools/ffmpeg_dec.c | 321 ++-- > > > fftools/ffmpeg_demux.c| 268 --- > > > fftools/ffmpeg_enc.c | 368 ++--- > > > fftools/ffmpeg_filter.c | 722 +- > > > fftools/ffmpeg_mux.c | 324 ++-- > > > fftools/ffmpeg_mux.h | 24 +- > > > fftools/ffmpeg_mux_init.c | 88 +-- > > > fftools/ffmpeg_opt.c | 6 +- > > > .../fate/ffmpeg-fix_sub_duration_heartbeat| 36 +- > > > 11 files changed, 598 insertions(+), 2030 deletions(-) > > > > I tried > > ./ffmpeg -f lavfi -i testsrc2 -bsf:v noise -bitexact -t 2 /tmp/.y4m > > > > with merged ffmpeg_threading into master > > > > and it gets stuck > > > > Stream #0:0 -> #0:0 (wrapped_avframe (native) -> wrapped_avframe (native)) > > Press [q] to stop, [?] for help > > [noise @ 0x55e8fbaea340] Wrapped AVFrame noising is unsupported > > [vost#0:0/wrapped_avframe @ 0x55e8fbae9840] Error initializing bitstream > > filter: noise > > [vf#0:0 @ 0x55e8fbaea880] Error sending frames to consumers: Not yet > > implemented in FFmpeg, patches welcome > > [vf#0:0 @ 0x55e8fbaea880] Task finished with error code: -1163346256 (Not > > yet implemented in FFmpeg, patches welcome) > > [vf#0:0 @ 0x55e8fbaea880] Terminating thread with return code -1163346256 > > (Not yet implemented in FFmpeg, patches welcome) > > Sorry, seems I forgot to update my branch. Did that now, it should not > get suck anymore. this still gets stuck: ./ffmpeg -y -i mm-short.mpg -af apad -shortest /tmp/.nut [...] thx -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I know you won't believe me, but the highest form of Human Excellence is to question oneself and others. -- Socrates signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 13/13 v2] fftools/ffmpeg: convert to a threaded architecture
Quoting Michael Niedermayer (2023-11-30 14:08:26) > On Sat, Nov 25, 2023 at 09:32:06PM +0100, Anton Khirnov wrote: > > Change the main loop and every component (demuxers, decoders, filters, > > encoders, muxers) to use the previously added transcode scheduler. Every > > instance of every such component was already running in a separate > > thread, but now they can actually run in parallel. > > > > Changes the results of ffmpeg-fix_sub_duration_heartbeat - tested by > > JEEB to be more correct and deterministic. > > --- > > fftools/ffmpeg.c | 374 + > > fftools/ffmpeg.h | 97 +-- > > fftools/ffmpeg_dec.c | 321 ++-- > > fftools/ffmpeg_demux.c| 268 --- > > fftools/ffmpeg_enc.c | 368 ++--- > > fftools/ffmpeg_filter.c | 722 +- > > fftools/ffmpeg_mux.c | 324 ++-- > > fftools/ffmpeg_mux.h | 24 +- > > fftools/ffmpeg_mux_init.c | 88 +-- > > fftools/ffmpeg_opt.c | 6 +- > > .../fate/ffmpeg-fix_sub_duration_heartbeat| 36 +- > > 11 files changed, 598 insertions(+), 2030 deletions(-) > > I tried > ./ffmpeg -f lavfi -i testsrc2 -bsf:v noise -bitexact -t 2 /tmp/.y4m > > with merged ffmpeg_threading into master > > and it gets stuck > > Stream #0:0 -> #0:0 (wrapped_avframe (native) -> wrapped_avframe (native)) > Press [q] to stop, [?] for help > [noise @ 0x55e8fbaea340] Wrapped AVFrame noising is unsupported > [vost#0:0/wrapped_avframe @ 0x55e8fbae9840] Error initializing bitstream > filter: noise > [vf#0:0 @ 0x55e8fbaea880] Error sending frames to consumers: Not yet > implemented in FFmpeg, patches welcome > [vf#0:0 @ 0x55e8fbaea880] Task finished with error code: -1163346256 (Not yet > implemented in FFmpeg, patches welcome) > [vf#0:0 @ 0x55e8fbaea880] Terminating thread with return code -1163346256 > (Not yet implemented in FFmpeg, patches welcome) Sorry, seems I forgot to update my branch. Did that now, it should not get suck anymore. -- Anton Khirnov ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 13/13 v2] fftools/ffmpeg: convert to a threaded architecture
On Sat, Nov 25, 2023 at 09:32:06PM +0100, Anton Khirnov wrote: > Change the main loop and every component (demuxers, decoders, filters, > encoders, muxers) to use the previously added transcode scheduler. Every > instance of every such component was already running in a separate > thread, but now they can actually run in parallel. > > Changes the results of ffmpeg-fix_sub_duration_heartbeat - tested by > JEEB to be more correct and deterministic. > --- > fftools/ffmpeg.c | 374 + > fftools/ffmpeg.h | 97 +-- > fftools/ffmpeg_dec.c | 321 ++-- > fftools/ffmpeg_demux.c| 268 --- > fftools/ffmpeg_enc.c | 368 ++--- > fftools/ffmpeg_filter.c | 722 +- > fftools/ffmpeg_mux.c | 324 ++-- > fftools/ffmpeg_mux.h | 24 +- > fftools/ffmpeg_mux_init.c | 88 +-- > fftools/ffmpeg_opt.c | 6 +- > .../fate/ffmpeg-fix_sub_duration_heartbeat| 36 +- > 11 files changed, 598 insertions(+), 2030 deletions(-) I tried ./ffmpeg -f lavfi -i testsrc2 -bsf:v noise -bitexact -t 2 /tmp/.y4m with merged ffmpeg_threading into master and it gets stuck Stream #0:0 -> #0:0 (wrapped_avframe (native) -> wrapped_avframe (native)) Press [q] to stop, [?] for help [noise @ 0x55e8fbaea340] Wrapped AVFrame noising is unsupported [vost#0:0/wrapped_avframe @ 0x55e8fbae9840] Error initializing bitstream filter: noise [vf#0:0 @ 0x55e8fbaea880] Error sending frames to consumers: Not yet implemented in FFmpeg, patches welcome [vf#0:0 @ 0x55e8fbaea880] Task finished with error code: -1163346256 (Not yet implemented in FFmpeg, patches welcome) [vf#0:0 @ 0x55e8fbaea880] Terminating thread with return code -1163346256 (Not yet implemented in FFmpeg, patches welcome) [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The day soldiers stop bringing you their problems is the day you have stopped leading them. They have either lost confidence that you can help or concluded you do not care. Either case is a failure of leadership. - Colin Powell signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 13/13 v2] fftools/ffmpeg: convert to a threaded architecture
Change the main loop and every component (demuxers, decoders, filters, encoders, muxers) to use the previously added transcode scheduler. Every instance of every such component was already running in a separate thread, but now they can actually run in parallel. Changes the results of ffmpeg-fix_sub_duration_heartbeat - tested by JEEB to be more correct and deterministic. --- fftools/ffmpeg.c | 374 + fftools/ffmpeg.h | 97 +-- fftools/ffmpeg_dec.c | 321 ++-- fftools/ffmpeg_demux.c| 268 --- fftools/ffmpeg_enc.c | 368 ++--- fftools/ffmpeg_filter.c | 722 +- fftools/ffmpeg_mux.c | 324 ++-- fftools/ffmpeg_mux.h | 24 +- fftools/ffmpeg_mux_init.c | 88 +-- fftools/ffmpeg_opt.c | 6 +- .../fate/ffmpeg-fix_sub_duration_heartbeat| 36 +- 11 files changed, 598 insertions(+), 2030 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index b8a97258a0..30b594fd97 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -117,7 +117,7 @@ typedef struct BenchmarkTimeStamps { static BenchmarkTimeStamps get_benchmark_time_stamps(void); static int64_t getmaxrss(void); -unsigned nb_output_dumped = 0; +atomic_uint nb_output_dumped = 0; static BenchmarkTimeStamps current_time; AVIOContext *progress_avio = NULL; @@ -138,30 +138,6 @@ static struct termios oldtty; static int restore_tty; #endif -/* sub2video hack: - Convert subtitles to video with alpha to insert them in filter graphs. - This is a temporary solution until libavfilter gets real subtitles support. - */ - -static void sub2video_heartbeat(InputFile *infile, int64_t pts, AVRational tb) -{ -/* When a frame is read from a file, examine all sub2video streams in - the same file and send the sub2video frame again. Otherwise, decoded - video frames could be accumulating in the filter graph while a filter - (possibly overlay) is desperately waiting for a subtitle frame. */ -for (int i = 0; i < infile->nb_streams; i++) { -InputStream *ist = infile->streams[i]; - -if (ist->dec_ctx->codec_type != AVMEDIA_TYPE_SUBTITLE) -continue; - -for (int j = 0; j < ist->nb_filters; j++) -ifilter_sub2video_heartbeat(ist->filters[j], pts, tb); -} -} - -/* end of sub2video hack */ - static void term_exit_sigsafe(void) { #if HAVE_TERMIOS_H @@ -499,23 +475,13 @@ void update_benchmark(const char *fmt, ...) } } -void close_output_stream(OutputStream *ost) -{ -OutputFile *of = output_files[ost->file_index]; -ost->finished |= ENCODER_FINISHED; - -if (ost->sq_idx_encode >= 0) -sq_send(of->sq_encode, ost->sq_idx_encode, SQFRAME(NULL)); -} - -static void print_report(int is_last_report, int64_t timer_start, int64_t cur_time) +static void print_report(int is_last_report, int64_t timer_start, int64_t cur_time, int64_t pts) { AVBPrint buf, buf_script; int64_t total_size = of_filesize(output_files[0]); int vid; double bitrate; double speed; -int64_t pts = AV_NOPTS_VALUE; static int64_t last_time = -1; static int first_report = 1; uint64_t nb_frames_dup = 0, nb_frames_drop = 0; @@ -533,7 +499,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti last_time = cur_time; } if (((cur_time - last_time) < stats_period && !first_report) || -(first_report && nb_output_dumped < nb_output_files)) +(first_report && atomic_load(_output_dumped) < nb_output_files)) return; last_time = cur_time; } @@ -544,7 +510,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti av_bprint_init(, 0, AV_BPRINT_SIZE_AUTOMATIC); av_bprint_init(_script, 0, AV_BPRINT_SIZE_AUTOMATIC); for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) { -const float q = ost->enc ? ost->quality / (float) FF_QP2LAMBDA : -1; +const float q = ost->enc ? atomic_load(>quality) / (float) FF_QP2LAMBDA : -1; if (vid && ost->type == AVMEDIA_TYPE_VIDEO) { av_bprintf(, "q=%2.1f ", q); @@ -565,22 +531,18 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti if (is_last_report) av_bprintf(, "L"); -nb_frames_dup = ost->filter->nb_frames_dup; -nb_frames_drop = ost->filter->nb_frames_drop; +nb_frames_dup = atomic_load(>filter->nb_frames_dup); +nb_frames_drop = atomic_load(>filter->nb_frames_drop); vid = 1; } -/* compute min output value */ -if (ost->last_mux_dts != AV_NOPTS_VALUE) { -if (pts == AV_NOPTS_VALUE ||