[FFmpeg-user] Performance: Multiple output, encode audio only once
tevans.uk at googlemail.com
Wed Aug 20 13:19:24 CEST 2014
On Sat, Aug 16, 2014 at 5:49 PM, Claudiu Rad <jazzman at misalpina.net> wrote:
> Trying to figure this one out but after searching over the internet and
> looking through ffmpeg/filter documentation, still isn't clear for me how to
> do it optimally:
> I want to take a video input source with the purpose of transcoding it to
> three different levels/bitrates. I also want to change audio codec, thus,
> need to reencode, but should be the same in all output streams. I know that
> the audio encoding doesn't take much CPU power, but, I still want to do it
> efficiently also in the cases where I have 5 or 6 outputs.
> Command line sample with two levels only of what I am doing now:
> ffmpeg -i input.mkv \
> -acodec libvo_aacenc -ac 2 -b:a 112k -vcodec libx264 -s 1280x720
> -acodec libvo_aacenc -ac 2 -b:a 112k -vcodec libx264 -s 640x360
> How can I avoid encoding to AAC twice in this case (5 or 6 times in
> real-case scenarios)?
> Is somewhat of a filter_complex recommended or should I just try to pipe
> from one ffmpeg instance to another? I am worried about eventual
> instabilities in this case involving a system pipe and that two ffmpeg
> instances may eat more system resources so this wouldn't be optimal from
> other points of view. This is why I would favor a filter_complex-like
This is how I would initially approach it, with a first ffmpeg process
to copy the video, encode the audio, and mux to mpegts, and a second
process to encode the video streams and copy the audio.
> And one more question to extend my performance worries a bit:
> How many times the input is demuxed/decoded when using multiple output? More
> precisely, in the above case, is the input video stream decoded once or
> If twice (or N times in case of N outputs), how can this be improved,
> because it may involve a lot of CPU.
With a multiple outputs, the input frame is demuxed and decoded once.
With a pipe, you are adding in an extra mux/demux from mpegts, but the
video is only decoded once. Mux/demux is fairly cheap, you would
probably need to determine if it is cheaper than re-encoding the audio
Presumably if you have 6 outputs, wouldn't at least one of them have a
low audio bitrate? My "lowest quality" output has just 32kb/s AAC.
I would experiment, there should be a way to do this with filter_complex..
More information about the ffmpeg-user