[FFmpeg-devel] [RFC]separation of multiple outputs' encoding
Tao Zhang
nowerzt at gmail.com
Thu May 14 11:12:35 EEST 2020
Hi,
FFmpeg supports multiple outputs created out of the same input in the
same process like
ffmpeg -i input -filter_complex '[0:v]yadif,split=3[out1][out2][out3]' \
-map '[out1]' -s 1280x720 -acodec … -vcodec … output1 \
-map '[out2]' -s 640x480 -acodec … -vcodec … output2 \
-map '[out3]' -s 320x240 -acodec … -vcodec … output3
In ffmpeg.c, multiple outputs are processed sequentially like
for (i = 0; i < nb_output_streams; i++)
encoding one frame;
As below wiki noted, the slowest encoder will slow down the whole
process. Some encoders (like libx264) perform their encoding "threaded
and in the background", but x264_encoder_encode still cost some time.
And it is noticeable when multiple x264_encoder_encodes run in the same thread.
https://trac.ffmpeg.org/wiki/Creating%20multiple%20outputs
For API users, they can use separate thread for multiple encoding in
their own code. But is there any way to rescue command line users?
I want to request for your comments on separation of multiple outputs'
encoding in ffmpeg. Refactoring ffmpeg.c seems not a tiny task. Is it
acceptable to create a pseudo encoder which run the actual encoding in
the separate thread?
Best Regards
More information about the ffmpeg-devel
mailing list