Send output to multiple destinations
I'm really new on ffmpeg and have a question where I cannot find a solution. I really hope that somebody from you could help me with that.
On one server I receive a 1080p stream, with ffmpeg I create a new stream with multiple bitrates and resolution and send it afterwards to a rtmp destination on this server. Below CL the command that I use at the moment and it is working.
ffmpeg -i - -copyts -muxdelay 0 -c:a libfaac -ab 128k
-c:v libx264 -preset faster -profile:v main -level 3.1 -crf 20 -g 50 -b:v 1500k -s:v 1920x1080 -f flv rtmp://localhost/stream/output_stream
-c:a libfaac -ab 64k -c:v libx264 -preset faster -profile:v main -level 3.1 -crf 23 -g 50 -b:v 1000k -s:v 1280x720 -f flv rtmp://localhost/stream/output_stream
-c:a libfaac -ab 32k -c:v libx264 -preset faster -profile:v main -level 3.1 -crf 23 -g 50 -b:v 800k -s:v 960x540 -f flv rtmp://localhost/stream/output_stream
Now I have the challenge that I need to send it to multiple servers. Is there anyway to add multiple outputs?
At the end the incoming 1080p stream should get multiple bitrates and should be send to around 10 different RTMP server.
I really hope that somebody can help me with that.
You can use the tee muxer if any same stream(s) are to be sent to multiple outputs.
Simple example
ffmpeg -i input -map 0:v -map 0:a -c:v libx264 -b:v 4000k -maxrate 4000k -bufsize 8000k -b:a 128k -g 50 -c:a aac -flags +global_header -f tee "[f=flv:onfail=ignore]rtmp://localhost/stream/output_stream0|[f=flv:onfail=ignore]rtmp://localhost/stream/output_stream1"
Add -re
realtime input option if -i input
is not a live souce. Otherwise omit -re
for live inputs (web cams, https, rtmp, etc).
Different video sizes, but same audio
Audio doesn't take up much bitrate compared to video, so you can consider ditching the multiple audio bitrates, encode it only once, and use that same stream for all of the outputs. Basic example:
ffmpeg -i input -filter_complex \
"[0:v]split=2[s0][s1];[s0]scale=1280:-2[v0];[s1]scale=960:-2[v1]" \
-map "[v0]" -map "[v1]" -map 0:a -c:v libx264 -b:v:0 1000k -b:v:1 800k -c:a aac -flags +global_header -f tee \
"[select=\'v:0,a\':f=flv:onfail=ignore]rtmp://localhost/stream/output_stream0|[select=\'v:1,a\':f=flv:onfail=ignore]rtmp://localhost/stream/output_stream1"
Unrelated, but you're using libfaac which means your ffmpeg
is ancient. So you really should upgrade.