Tuesday, April 11, 2017

Creating Overlay Image and Running Text in Multiple Output Streaming with NGINX RTMP


Creating Multiple Output with No Filter

Creating multiple output without implement filtering can be done by using command

syntax:
           ffmpeg -i input1 -i input2 \
               -acodec … -vcodec … output1 \
               -acodec … -vcodec … output2 \
               -acodec … -vcodec … output3



Pic 1.  Multiple Outputs


Here is an example to create several different outputs out HD, VGA and QVGA resolution at the same time with one command

syntax:
           ffmpeg -i input \
               -s 1280x720 -acodec … -vcodec … output1 \
               -s 640x480  -acodec … -vcodec … output2 \
               -s 320x240  -acodec … -vcodec … output3


Creating Multiple Output with Same Filter to All Output

To implement same filter in multiple output can be done by using -filter_complex with split filter.
Command below to split=3 means split to three streams

syntax:
         ffmpeg -i input -filter_complex '[0:v]yadif,split=3[out1][out2][out3]' \
                           -map '[out1]' -s 1280x720 -acodec … -vcodec … output1 \
                           -map '[out2]' -s 640x480  -acodec … -vcodec … output2 \
                           -map '[out3]' -s 320x240  -acodec … -vcodec … output3


Creating Multiple Output with Specific Filter per each Output

To create multiple output with specific filter per each output can be done by using  -filter_complex with split filter, but split goes to input directly.

Below syntax to encode video to three different output at the same time, but boxblur will impact to output1, negate will impact to output2 and yadif will impact to output3.
syntax:
      ffmpeg -i input -filter_complex \
         '[0:v]split=3[in1][in2][in3];[in1]boxblur[out1];\
          [in2]negate[out2];[in3]yadif[out3]' \
        -map '[out1]' -acodec … -vcodec … output1 \
        -map '[out2]' -acodec … -vcodec … output2 \
        -map '[out3]' -acodec … -vcodec … output3


Creating Overlay Image and Running Text with Multiple Output

Here is my own experiment to implement Overlay Image and Running Text in Streaming with multiple resolution and multiple output. The main concern when implement this filter is the Overlay Image and Running Text will only display in output1 and dissappear in other output due to wrong placement of filtering. This is become my concern and do some experiment to find solution on how to put carefully of filtering placement.

Syntax:
ffmpeg -i storm_spirit.mp4 -i addies.jpg -filter_complex \
"[1:v]scale=iw/2:ih/2[logo];[0:v][logo]overlay=W-w-5:H-h-5, \
scale=320:-2,drawbox=x=0:y=122:color=yellow@0.4:width=iw:height=30:t=max, \
drawtext=fontfile=/usr/share/fonts/truetype/freefont/FreeSans.ttf:text='This Is Running Text':\
fontcolor=white@1.0:fontsize=16:y=h-line_h-30:x=w/10*mod(t\,10):\
enable=gt(mod(t\,20)\,10),split=3[a][b][c]" \
-map "[a]" -map 0:a -vcodec libx264 -acodec aac -strict -2 -b:v 256k -b:a 32k -f flv rtmp://192.168.135.128:1935/myapp/mystream \
-map "[b]" -map 0:a -vcodec libx264 -acodec aac -strict -2 -b:v 128k -b:a 32k -f flv rtmp://192.168.135.128:1935/myapp/mystream2 \
-map "[c]" -map 0:a -vcodec libx264 -acodec aac -strict -2 -b:v 96k -b:a 32k -f flv rtmp://192.168.135.128:1935/myapp/mystream3


Result, Ovelay Image and Running Text can be seen in each output of streaming.



Pic 2. Overlay Image and Running Text can be implemented in each stream output

Thank you
Other Topics:





No comments:

Post a Comment