FFMPEG Multiple outputs from BlackMagic input - ffmpeg

I'm currently needing help to achieve multiple outputs from one input.
Right now, the outputs are set like this:
ffmpeg -re -f decklink -i "DeckLink Mini Recorder" -y -pix_fmt yuv420p -c:v h264 -preset fast -tune zerolatency -c:a aac -ac 2 -b:a 128k -ar 44100 -async 1 -b:v 2300k -g 5 -probesize 32 -framerate 30 -movflags +faststart -s 1280x720 -bufsize 1000k -maxrate 3072k -shortest -f flv "rtmp://10.0.0.172:1935/Testing/live_720p"
ffmpeg -re -i "rtmp://10.0.0.172:1935/Testing/live_720p" -c:v h264 -preset fast -tune zerolatency -c:a aac -ac 2 -b:a 114k -ar 44100 -async 1 -b:v 900k -g 5 -probesize 32 -framerate 30 -movflags +faststart -s 854x480 -bufsize 400k -maxrate 1000k -shortest -f flv "rtmp://10.0.0.172:1935/Testing/live_480p_hq"
ffmpeg -re -i "rtmp://10.0.0.172:1935/Testing/live_720p" -c:v h264 -preset fast -tune zerolatency -c:a aac -ac 2 -b:a 114k -ar 44100 -async 1 -b:v 550k -g 5 -probesize 32 -framerate 30 -movflags +faststart -s 854x480 -bufsize 400k -maxrate 500k -shortest -f flv "rtmp://10.0.0.172:1935/Testing/live_480p_lq"
ffmpeg -re -i "rtmp://10.0.0.172:1935/Testing/live_720p" -c:v h264 -preset fast -tune zerolatency -c:a aac -ac 2 -b:a 114k -ar 44100 -async 1 -b:v 450k -g 5 -probesize 32 -framerate 30 -movflags +faststart -s 640x360 -bufsize 400k -maxrate 500k -shortest -f flv "rtmp://10.0.0.172:1935/Testing/live_360p"
This uses quite a lot of processing power, and also generates unnecessary latency (since I have to stream to WOWZA first, then back to FFMPEG and then back to WOWZA).
And I want to optimize this.
I've been trying several methods, but I only managed to overflow the decklink buffer. How could I solve this?

As per #Brad's comment, you can select the source input and then create multiple outputs on a single command line, like this:
ffmpeg -re -f decklink -i "DeckLink Mini Recorder" -y -pix_fmt yuv420p \
-c:v h264 -preset fast -tune zerolatency -c:a aac -ac 2 -b:a 128k -ar 44100 -async 1 -b:v 2300k -g 5 -probesize 32 -framerate 30 -movflags +faststart -s 1280x720 -bufsize 1000k -maxrate 3072k -shortest -f flv "rtmp://10.0.0.172:1935/Testing/live_720p" \
-c:v h264 -preset fast -tune zerolatency -c:a aac -ac 2 -b:a 114k -ar 44100 -async 1 -b:v 900k -g 5 -probesize 32 -framerate 30 -movflags +faststart -s 854x480 -bufsize 400k -maxrate 1000k -shortest -f flv "rtmp://10.0.0.172:1935/Testing/live_480p_hq" \
-c:v h264 -preset fast -tune zerolatency -c:a aac -ac 2 -b:a 114k -ar 44100 -async 1 -b:v 550k -g 5 -probesize 32 -framerate 30 -movflags +faststart -s 854x480 -bufsize 400k -maxrate 500k -shortest -f flv "rtmp://10.0.0.172:1935/Testing/live_480p_lq" \
-c:v h264 -preset fast -tune zerolatency -c:a aac -ac 2 -b:a 114k -ar 44100 -async 1 -b:v 450k -g 5 -probesize 32 -framerate 30 -movflags +faststart -s 640x360 -bufsize 400k -maxrate 500k -shortest -f flv "rtmp://10.0.0.172:1935/Testing/live_360p"
(if you're running this on Windows then copy & paste the above into a single command - Windows command line doesn't support the backslash line-continuation feature).

Related

I trying to stream screen to multiple sources with ffmpeg and got error

My command
ffmpeg -thread_queue_size 1024 -f x11grab -draw_mouse 0 -video_size 1920x1080 -i :99.0+0,0 -f alsa -i pulse -channels 2 -c:a aac -b:a 160k -ar 44100 -threads 8 -c:v libx264 -x264-params nal-hrd=cbr -profile:v baseline -framerate 30 -level:v 4.2 -vf format=yuv420p -b:v 1000k -maxrate 1500k -minrate 1000k -bufsize 8000k -g 60 -preset ultrafast -tune zerolatency -f tee -flags +global_header -map 0:v -map 1:a "[f=flv:onfail=ignore]rtmp://stream1|[f=flv:onfail=ignore]rtmp://stream2"
Error in console:
[NULL # 0x55aaf9a54bc0] Unable to find a suitable output format for '"[f=flv:onfail=ignore]rtmp://strea1
[tee # 0x55aaf96f3200] Slave muxer #0 failed, aborting.
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:1 --
ffmpeg -thread_queue_size 1024 -f x11grab -draw_mouse 0 -video_size 1920x1080 -i :99.0+0,0 -f alsa -i pulse -channels 2 -c:a aac -b:a 160k -ar 44100 -threads 8 -c:v libx264 -x264-params nal-hrd=cbr -profile:v baseline -framerate 30 -level:v 4.2 -vf format=yuv420p -b:v 1000k -maxrate 2500k -minrate 800k -bufsize 8000k -g 60 -preset ultrafast -tune zerolatency -map 0:v -map 1:a -f tee -flags +global_header [f=flv:onfail=ignore:flvflags=no_duration_filesize]rtmp://stream1|[f=flv:onfail=ignore:flvflags=no_duration_filesize]rtmp://stream2
problem was with quotes

Burning subtitles different resolutions

I'm trying to create a live stream with three quality profiles with different resolutions (SD, HD and FullHD). The live stream has subtitles, and I have to burn them for compatibility reasons.
I know how to do it with one profile, but with many no idea.
ffmpeg -nostdin -loglevel error -hwaccel cuvid -deint 2 -drop_second_field 1 -surfaces 15 -c:v h264_cuvid -resize 1280x720 -y -i udp://xxx.xxx.xxx.xxx:xxxxx?pkt_size=1316\&buffer_size=409600\&fifo_size=1000000\&overrun_nonfatal=1 -filter_complex [i:0x2c6]hwdownload,format=nv12[base];[i:0x993]setpts=(2.5)/TB+PTS[subs];[subs]scale=1280:720[subtitle];[base][subtitle]overlay[v];[v]hwupload_cuda[v] -map [v] -c:v hevc_nvenc -preset llhq -rc vbr_hq -cq 23 -qp 23 -tier high -profile:v main10 -level 4.0 -b:v 2000k -maxrate 2400k -bufsize 1000k -map i:0x2bd -c:a libfdk_aac -ac 2 -b:a 64k -map i:0x2be -c:a libfdk_aac -ac 2 -b:a 64k -metadata:s:a:0 language=eng -metadata:s:a:1 language=spa -f mpegts -mpegts_flags resend_headers+pat_pmt_at_frames -mpegts_copyts 1 -pcr_period 40 udp://yyy.yyy.yyy.yyy:yyyy?ttl=31\?pkt_size=1316\&buffer_size=409600\&fifo_size=1000000\&overrun_nonfatal=1
Apparenlty, Iffmpeg doen't allow to use -vf filter with filter_complex.
I'm using ffmpeg 3.4, cuda 8.
Use
ffmpeg -nostdin -loglevel error -hwaccel cuvid -deint 2 -drop_second_field 1 -surfaces 15
-c:v h264_cuvid -y -i udp://xxx.xxx.xxx.xxx:xxxxx?pkt_size=1316\&buffer_size=409600\&fifo_size=1000000\&overrun_nonfatal=1
-filter_complex "[i:0x2c6]hwdownload,format=nv12,split=3[fhd][hd][sd];
[i:0x993]setpts=(2.5)/TB+PTS,split=3[subfhd][subhd][subsd];
[fhd]scale=1920:1080[fhd];
[hd]scale=1280:720[hd];
[sd]scale=960:540[sd];
[subfhd]scale=1920:1080[subfhd];
[subhd]scale=1280:720[subhd];
[subsd]scale=960:540[subsd];
[fhd][subfhd]overlay,hwupload_cuda[v-fhd];
[hd][subhd]overlay,hwupload_cuda[v-hd];
[sd][subsd]overlay,hwupload_cuda[v-sd]"
-map [v-fhd] -map [v-hd] -map [v-sd] -c:v hevc_nvenc -preset llhq -rc vbr_hq -cq 23 -qp 23 -tier high
-profile:v main10 -level 4.0 -b:v 2000k -maxrate 2400k -bufsize 1000k
-map i:0x2bd -map i:0x2be -c:a libfdk_aac -ac 2 -b:a 64k
-metadata:s:a:0 language=eng -metadata:s:a:1 language=spa
-f mpegts -mpegts_flags resend_headers+pat_pmt_at_frames -mpegts_copyts 1
-pcr_period 40 udp://yyy.yyy.yyy.yyy:yyyy?ttl=31\?pkt_size=1316\&buffer_size=409600\&fifo_size=1000000\&overrun_nonfatal=1
You'll have to adjust the video bitrates and buffer sizes as required, but this is the basic command template.

ffmpeg keyframerate can't setup

I need setting keyframe for youtube but not working. Is on linux Debian.
ffmpeg -i "test.flv" -vcodec libx264 -x264-params keyint=120:no-scenecut -sameq -pix_fmt yuv420p -re -ar 44100 -b:a 128k -bufsize 2048k -vb 400k -maxrate 800k -deinterlace -acodec libmp3lame -preset medium -g 30 -r 30 -f flv "rtmp://a.rtmp.youtube.com/live2/"
I have error Unrecognized option 'x264-params'

Which is the correct key frame intervall settings for ffmpeg stream to Periscope

I will stream to Periscope with ffmpeg.
The requirements of Periscope are:
•Framerate: 30fps
•Keyframe interval: every 2 seconds (OBS) or Keyframe every 45 frames (Wirecast)
I have follew ffmpeg command line:
ffmpeg -i INPUT -deinterlace -c:v libx264 -pix_fmt yuv420p -s 960x540 -preset superfast -vb 1200k -maxrate 1200k -r 30 -bufsize 8000k -c:a aac -b:a 96k -ar 44100 -ac 2 -f flv rtmp://de.pscp.tv:80/xxxxxxxxx
How can i set
Keyframe interval: every 2 seconds (OBS) or Keyframe every 45 frames (Wirecast)
on this command line
Add -g 60 for a 2 second interval.
ffmpeg -i INPUT -deinterlace -c:v libx264 -pix_fmt yuv420p -s 960x540 -preset superfast -vb 1200k -maxrate 1200k -r 30 -g 60 -bufsize 8000k -c:a aac -b:a 96k -ar 44100 -ac 2 -f flv rtmp://de.pscp.tv:80/xxxxxxxxx

What is difference between using ffmpeg GOP setting or x264opt keyint combination?

Here is a ffmpeg command:
ffmpeg -i input.mp4 -flags +global_header -c:v libx264 -vf scale="864x486",setsar=1:1,setdar=16:9 -profile:v main -level 31 -g 50 -keyint_min 50 -sc_threshold 0 -b:v 700k -pix_fmt yuv420p -c:a libfdk_aac -ar 44100 -ac 2 -b:a 128k output2.mp4
and here is the other one:
ffmpeg -i input.mp4 -flags +global_header -c:v libx264 -vf scale="864x486",setsar=1:1,setdar=16:9 -x264opts keyint=50:min-keyint=50:no-scenecut -profile:v main -level 31 -b:v 700k -pix_fmt yuv420p -c:a libfdk_aac -ar 44100 -ac 2 -b:a 128k output2.mp4
Are there any differences between using -g 50 -keyint_min 50 -sc_threshold 0 and -x264opts keyint=50:min-keyint=50:no-scenecut settings to gain constant keyframe interval?

Resources