Thursday, April 6, 2017

How to Implement Running Text in Streaming with NGINX RTMP



In my previous tutorial, I have explained on How to Build NGINX RTMPSetup Live Streaming with NGINX RTMPCreate Adaptive Streaming with NGINX RTMP and Implementing Filtergraph in Streaming with NGINX RTMP.  Please read it before start to learn this tutorial.

Running Text is one of the very useful electronic or digital media to convey messages and information can also be used as a means of advertising.

In its development, the display running text now comes not only show a series of posts to walk alone but also able to display images or logos.

Running Text was elected by a lot of people as a means of advertising, as a means of advertising for reasons other than a very beatiful display, running text in itself proved to have an attaction for people around who saw it, as well as know, that the human visual sense be the eyes are very interested in a view that is bright, colorful, striking and others around him. This is the underlying color of the display running text inviting people around her eyes to look at him.

Here is the command on how to create "Hello World" Running Text in streaming

ffmpeg -i storm_spirit.mp4 -filter:v drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSans.ttf:text='Hello World':fontcolor=white@1.0:fontsize=16:y=h-line_h-100:x=w/10*mod(t\,10):enable=gt(mod(t\,20)\,10)" -vcodec libx264 -acodec aac -strict -2 -b:v 256k -b:a 32k -f flv rtmp://192.168.135.128:1935/myapp/mystream


Result shown as picture below


Pic 1.  Running Text "Hello World"



This is to show 'Running Text in Streaming with NGINX RTMP'

ffmpeg -i storm_spirit.mp4 -filter:v drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSans.ttf:text='Running Text in Streaming with NGINX RTMP':fontcolor=white@1.0:fontsize=16:y=h-line_h-100:x=w/10*mod(t\,10):enable=gt(mod(t\,20)\,10)" -vcodec libx264 -acodec aac -strict -2 -b:v 256k -b:a 32k -f flv rtmp://192.168.135.128:1935/myapp/mystream

Result shown as below:


Pic 2. Running Text "Running Text in Streaming with NGINX RTMP"

All above sample, Text is running from left to right.

Horizontal movement:

            x=w/10*mod(t\,10)

            where w is the input width
                        t is the time
                       w/10 is the speed of movement (whole width in 10s)
                        t mod 10 is used to repeat every 10s

Enabling:
           enable=gt(mod(t\,20)\,10)
           every 20s show the text animation for 10s after the initial 10s

                   

This is an example Running Text with Background. The command as below

ffmpeg -i /mnt/e/kurento/compile\ NGIX/storm_spirit.mp4 -filter:v "drawbox=y=ih/PHI:color=black@0.4:width=iw:height=30:t=max, drawtext=fontfile=/usr/share/fonts/truetype/freefont/FreeSans.ttf:text='Addiestar Silaban Running Text':fontcolor=white@1.0:fontsize=16:y=h-line_h-115:x=w/10*mod(t\,10):enable=gt(mod(t\,20)\,10)" -vcodec libx264 -acodec aac -strict -2 -b:v 256k -b:a 32k -f flv rtmp://192.168.135.128:1935/myapp/mystream

Result shown as below


Pic 3. Running Text with Black Background



Don't forget to change the RTMP IP address (red color)
rtmp://192.168.135.128:1935/myapp/mystream  to your NGINX RTMP server IP Address


Thank you




Other Topics:



No comments:

Post a Comment