0

I use a Decklink to capture video and ffmpeg to stream it to a localhost rtmp server (low compression, HD) and to a remote CDN (high compression, low resolution). I have used this command with success for many mounths:

ffmpeg -hide_banner -loglevel info -xerror -err_detect buffer -format_code Hi59 -threads 1 -thread_queue_size 32 -f decklink -i 'DeckLink Mini Recorder' -vsync cfr -pix_fmt yuv420p -g 60 -preset medium -vf scale=1280:720 -profile:v high -level 4.1 -b:a 192k -b:v 3500K -r 30000/1001 -vcodec libx264 -acodec aac -f flv rtmp://127.0.0.1:1935/live/alta -vsync cfr -pix_fmt yuv420p -g 60 -preset medium -vf scale=896:504 -profile:v high -level 3.1 -b:a 96k -b:v 900k -r 30000/1001 -vcodec libx264 -acodec aac -f flv rtmp://user:pass@srv3.zoeweb.tv:1935/z474-live/aovivo 2> >(tee /mnt/ramdisk/ffmpeg_error.log >&2)

Some day I need a box for telephone number over HD output in a way that number can be script changed. So I used ZMQ library with sucess:

ffmpeg -hide_banner -loglevel info -xerror -err_detect buffer -format_code Hi59 -threads 1 -thread_queue_size 32 -f decklink -i 'DeckLink Mini Recorder' -vsync cfr -pix_fmt yuv420p -g 60 -preset medium -filter_complex '[0:v] zmq=bind_address=tcp\\\://127.0.0.1\\\:5557,drawtext=text=:fontfile=hp_impact.ttf:x=870:y=850:fontcolor=white:fontsize=105:bordercolor=black:borderw=3:boxcolor=0xC12235:box=1:boxborderw=20,scale=1280:720' -profile:v main -level 4.1 -b:a 192k -b:v 3500K -r 30000/1001 -vcodec libx264 -acodec aac -f flv rtmp://127.0.0.1:1935/live/alta -vsync cfr -pix_fmt yuv420p -g 60 -preset medium -vf scale=896:504 -profile:v high -level 3.1 -b:a 96k -b:v 900k -r 30000/1001 -vcodec libx264 -acodec aac -f flv rtmp://user:pass@srv3.zoeweb.tv:1935/z474-live/aovivo 2> >(tee /mnt/ramdisk/ffmpeg_error.log >&2)

(to change the text I use this command:

echo Parsed_drawtext_1 reinit text='xxxxxxxxxx' | zmqsend -b tcp://127.0.0.1:5557

and the result (working) is:

[decklink @ 0x555668d3bb40] Found Decklink mode 1920 x 1080 with rate 29.97(i)
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, decklink, from 'DeckLink Mini Recorder':
  Duration: N/A, start: 0.000000, bitrate: 995869 kb/s
    Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
    Stream #0:1: Video: rawvideo (UYVY / 0x59565955), uyvy422(top first), 1920x1080, 994333 kb/s, 29.97 tbr, 1000k tbn, 1000k tbc
[rtmp @ 0x555668d49d80] Ignoring unsupported var reason
Stream mapping:
  Stream #0:1 (rawvideo) -> zmq (graph 0)
  scale (graph 0) -> Stream #0:0 (libx264)
  Stream #0:0 -> #0:1 (pcm_s16le (native) -> aac (native))
  Stream #0:1 -> #1:0 (rawvideo (native) -> h264 (libx264))
  Stream #0:0 -> #1:1 (pcm_s16le (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x555668d6d180] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x555668d6d180] profile Main, level 4.1
[libx264 @ 0x555668d6d180] 264 - core 150 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=60 keyint_min=6 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=3500 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[libx264 @ 0x555668d4bc40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x555668d4bc40] profile High, level 3.1
[libx264 @ 0x555668d4bc40] 264 - core 150 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=60 keyint_min=6 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=1100 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, flv, to 'rtmp://127.0.0.1:1935/live/alta':
  Metadata:
    encoder         : Lavf58.3.100
    Stream #0:0: Video: h264 (libx264) ([7][0][0][0] / 0x0007), yuv420p(top coded first (swapped)), 1280x720, q=-1--1, 3500 kb/s, 29.97 fps, 1k tbn, 29.97 tbc
    Metadata:
      encoder         : Lavc58.9.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/3500000 buffer size: 0 vbv_delay: -1
    Stream #0:1: Audio: aac (LC) ([10][0][0][0] / 0x000A), 48000 Hz, stereo, fltp, 192 kb/s
    Metadata:
      encoder         : Lavc58.9.100 aac
Output #1, flv, to 'rtmp://pass:pass@srv3.zoeweb.tv:1935/z474-live/aovivo':
  Metadata:
    encoder         : Lavf58.3.100
    Stream #1:0: Video: h264 (libx264) ([7][0][0][0] / 0x0007), yuv420p(top coded first (swapped)), 896x504, q=-1--1, 1100 kb/s, 29.97 fps, 1k tbn, 29.97 tbc
    Metadata:
      encoder         : Lavc58.9.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/1100000 buffer size: 0 vbv_delay: -1
    Stream #1:1: Audio: aac (LC) ([10][0][0][0] / 0x000A), 48000 Hz, stereo, fltp, 96 kb/s
    Metadata:
      encoder         : Lavc58.9.100 aac
frame=   67 fps= 67 q=21.0 q=35.0 size=      90kB time=00:00:02.17 bitrate= 340.2kbits/s speed=2.16x

Great. It´s working!! :-)

But I need to create a box for another number over the second output too, with different numbers for eath output and in a way that can be manually/script changed. So I think in use ZMQ library again...

The problem is: When I try to use the same complex_filter (only with the correct scale and another udp port) on the second (lowres) rtmp output I receive this error message:

ffmpeg -hide_banner -loglevel info -xerror -err_detect buffer -format_code Hi59 -threads 1 -thread_queue_size 32 -f decklink -i 'DeckLink Mini Recorder' -vsync cfr -pix_fmt yuv420p -g 60 -preset medium -filter_complex ' zmq=bind_address=tcp\\\://127.0.0.1\\\:5557,drawtext=text=:fontfile=hp_impact.ttf:x=870:y=850:fontcolor=white:fontsize=105:bordercolor=black:borderw=3:boxcolor=0xC12235:box=1:boxborderw=20,scale=1280:720' -profile:v main -level 4.1 -b:a 192k -b:v 3500K -r 30000/1001 -vcodec libx264 -acodec aac -f flv rtmp://127.0.0.1:1935/live/alta -vsync cfr -pix_fmt yuv420p -g 60 -preset medium -filter_complex ' zmq=bind_address=tcp\\\://127.0.0.1\\\:5558,drawtext=text=:fontfile=hp_impact.ttf:x=870:y=850:fontcolor=white:fontsize=105:bordercolor=black:borderw=3:boxcolor=0xC12235:box=1:boxborderw=20,scale=896:504' -profile:v main -level 3.1 -b:a 96k -b:v 900k -r 30000/1001 -vcodec libx264 -acodec aac -f flv rtmp://user:pass@srv3.zoeweb.tv:1935/z474-live/aovivo 2> >(tee /mnt/ramdisk/ffmpeg_error.log >&2)

[decklink @ 0x56316fb6dcc0] Found Decklink mode 1920 x 1080 with rate
29.97(i) Guessed Channel Layout for Input Stream #0.0 : stereo Input #0, decklink, from 'DeckLink Mini Recorder':   Duration: N/A, start: 0.000000, bitrate: 995869 kb/s
    Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
    Stream #0:1: Video: rawvideo (UYVY / 0x59565955), uyvy422(top first), 1920x1080, 994333 kb/s, 29.97 tbr, 1000k tbn, 1000k tbc Cannot
find a matching stream for unlabeled input pad 0 on filter
Parsed_zmq_0

I think that is a mapping case, but as much as I read and try I could not get it right. :-(

Can someone put me in the right way?

0

Your input has only one video stream. To reuse it for multiple filter chains, you need either express labelled input pads or a split filter. You'll also need -map option for each output.

ffmpeg -hide_banner -loglevel info -xerror -err_detect buffer -format_code Hi59 -threads 1
       -thread_queue_size 32 -f decklink -i 'DeckLink Mini Recorder'
       -filter_complex '[0]zmq=bind_address=tcp\\\://127.0.0.1\\\:5557,split=2[720p][504p];[720p]drawtext@720p=text=:fontfile=hp_impact.ttf:x=870:y=850:fontcolor=white:fontsize=105:bordercolor=black:borderw=3:boxcolor=0xC12235:box=1:boxborderw=20,scale=1280:720[720p];[504p]drawtext@504p=text=:fontfile=hp_impact.ttf:x=870:y=850:fontcolor=white:fontsize=105:bordercolor=black:borderw=3:boxcolor=0xC12235:box=1:boxborderw=20,scale=896:504[504p]' 
       -map '[720p]' -map 0:a -vsync cfr -pix_fmt yuv420p -g 60 -preset medium  -profile:v main 
       -level 4.1 -b:a 192k -b:v 3500K -r 30000/1001 -vcodec libx264 -acodec aac 
       -f flv rtmp://127.0.0.1:1935/live/alta 
       -map '[504p]' -map 0:a -vsync cfr -pix_fmt yuv420p -g 60 -preset medium -profile:v main 
       -level 3.1 -b:a 96k -b:v 900k -r 30000/1001 -vcodec libx264 -acodec aac 
       -f flv rtmp://user:pass@srv3.zoeweb.tv:1935/z474-live/aovivo 2> >(tee /mnt/ramdisk/ffmpeg_error.log >&2)
  • Thanks Gyan ! I will test your solution. I think that it´s the way, perhaps it´s not the final answer because to create two different texts (on on each output stream) with different strings (each one feed by one different zmq filter in different udp ports) the filter and maps need to be changed, but I learn a lot with your answer. – Renato Romano Sep 10 '18 at 15:12
  • No, you only need one zmq filter, listening on one port. When you send command, change your target and string e.g. echo drawtext@720p reinit text='xx' | zmqsend -b tcp://127.0.0.1:5557 and echo drawtext@504p reinit text='yy' | zmqsend -b tcp://127.0.0.1:5557 – Gyan Sep 10 '18 at 15:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.