[FFmpeg-user] How to optimize transcoding cpu usage

Tom Evans tevans.uk at googlemail.com
Mon Jun 3 18:38:46 CEST 2013


On Fri, May 31, 2013 at 2:41 PM, Rala Wa <ralawa at yahoo.fr> wrote:
> Hi,
>
>
> I am currently trying to transcode an udp TS stream which contains 1 video stream and 4 audio streams.
>
> I'm using this command line:
>
> ffmpeg -i "udp://239.255.0.10:1234?fifo_size=1000000" \
>     -map 0:0 -codec:v libx264 -s 1280x720 -profile:v baseline -preset:v superfast -g 125 -vb 1500k -map 0:1 -codec:a aac -ab 64000 -ar 48000 -ac 2 -strict experimental -f flv rtmp://host/1/720p \
>     -map 0:0 -codec:v libx264 -s 800x450 -profile:v baseline -preset:v superfast -g 125 -vb 800k -map 0:1 -codec:a aac -ab 64000 -ar 48000 -ac 2 -strict experimental -f flv rtmp://host/1/450p \
>     -map 0:0 -codec:v libx264 -s 384x216 -profile:v baseline -preset:v superfast -g 125 -vb 300k -map 0:1 -codec:a aac -ab 64000 -ar 48000 -ac 2 -strict experimental -f flv rtmp://host/1/216p \
>     -map 0:0 -codec:v libx264 -s 1280x720 -profile:v baseline -preset:v superfast -g 125 -vb 1500k -map 0:2 -codec:a aac -ab 64000 -ar 48000 -ac 2 -strict experimental -f flv rtmp://host/2/720p \
>     -map 0:0 -codec:v libx264 -s 800x450 -profile:v baseline -preset:v superfast -g 125 -vb 800k -map 0:2 -codec:a aac -ab 64000 -ar 48000 -ac 2 -strict experimental -f flv rtmp://host/2/450p \
>     -map 0:0 -codec:v libx264 -s 384x216 -profile:v baseline -preset:v superfast -g 125 -vb 300k -map 0:2 -codec:a aac -ab 64000 -ar 48000 -ac 2 -strict experimental -f flv rtmp://host/2/216p
>
>
> With this command line I encode 6 streams, 3 quality for 2 langs.
> In this command line I, for example, transcode two times the 1280x720 video resolution which I think is not optimized.
>
> Can you tell me, if it is possible to encode only one time the video and add different languages to this video?
>
> In fact, to optimize cpu usage I would like to encode only once each video resolution
>
>           ---- 1280x720 ------> 3 outputs with audio 0:1, 0:2, 0:3 ...
>          |
> TS input --------- 800x450 -------> 3 outputs with audio 0:1, 0:2, 0:3 ...
>          |
>          ----- 384x216 ------> 2 output with audio 0:1, 0:2, 0:3 ...
>
> I am also surprised by the cpu usage of this command line. With a 8 cores X3450, this command line use 30% on all cores. When I add 3 outputs the cpu usage increase slightly but ffmpeg is not able to do 25 fps transcoding and then I see buffering on the output streams. I tried to nice ffmpeg but It is not better. I hoped to encode more streams with this CPU.
>
>
> Regards,

Hi Ralla

Use ffmpeg to make one stream with 3 video streams and 2 audio
streams, pipe this to ffmpeg and use ffmpeg (and copy codec) to
produce your resulting 6 outputs. This way, all the transcoding work
is done in the first ffmpeg, once (and once only) for each resolution,
and then muxed in the second ffmpeg.

Cheers

Tom


More information about the ffmpeg-user mailing list