[FFmpeg-user] Sharing an audio encode among two outputs

PSPunch shima at pspunch.com
Tue Nov 8 08:37:48 EET 2016


On 2016/11/07 21:08, Moritz Barsnick wrote:
> On Mon, Nov 07, 2016 at 17:00:52 +0900, PSPunch wrote:
>> Is there a way to brush this up, do the audio encode just once?
>> A solution in a single process would be ideal. As CPU load is low
>> anyway, I would prefer to keep this in a single instance if piping is
>> the only solution.
>
> I haven't tried, but the "tee" muxer should be able to do that. The
> documentation even covers your specific case:
> https://trac.ffmpeg.org/wiki/Creating%20multiple%20outputs#Teepseudo-muxer

Thanks, this helped.


Just for the record, noting one pitfall I fell in while working on Windows.

The sample in the above Wiki shows the following example where the 
[select] section is broken into multiple lines.

The ^ sign is said to be the equivalent of \ in Windows.
However, breaking the [select] section over multiple lines resulted in 
an error. As long as avoiding this, all works great.

ffmpeg -i input -filter_complex \
"[0:v]split=2[s0][s1]; \
  [s0]scale=1280:-2[v0]; \
  [s1]scale=640:-2[v1]" \
-map "[v0]" -map "[v1]" -map 0:a -c:v libx264 -c:a aac -f tee \
"[select=\'v:0,a\']local0.mkv| \
  [select=\'v:0,a\':f=flv]rtmp://server0/app/instance/playpath| \
  [select=\'v:1,a\']local1.mkv| \
  [select=\'v:1,a\':f=flv]rtmp://server1/app/instance/playpath"

-- 
David Shimamoto



More information about the ffmpeg-user mailing list