How to stick logo and scrolling text on video using ffmpeg
Posted By : Chandan Kumar Singh | 27-Jul-2015
In this blog we will come to know how to add our own logo in a video as well as custom text which will scroll left to right in the middle postion of screen.
Lets see the command:
ffmpeg -rtsp_transport tcp -i rtsp://52.5.184.1:1935/Live/manual.stream -i /home/oodles/Desktop/logo.png -filter_complex "[0:v][1:v]overlay=main_w-overlay_w-10:10" -f flv pipe:1 | ffmpeg -i pipe:0 -vf "drawtext=text=oodlestechnologies :fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf: y=((h)/2):x=(mod(5*n\,w+tw)-tw): fontcolor=red: fontsize=40: shadowx=-5: shadowy=-15" -vcodec libx264 -vb 400k -acodec aac -ab 100k -ar 48000 -ac 2 -f flv -muxdelay 0.1 rtmp://oodles:[email protected]:1935/live-demo/mstream
The sample output:-
- Explanation of command:
-
"-rtsp_transport tcp " - Set RTSP transport protocols tcp.
-
"-i "- specifies the input file stored in local disk or live audio/video source.
-
"-filter_complex" - to recognize filtergraph.
-
"[0:v][1:v]overlay=main_w-overlay_w-10:10" - main_w refers to the width of the "main" input (the background or [0:v] or our main input here rtsp://52.5.184.1:1935/Live/manual.stream),and overlay_w refers to the width of the "overlay" input (the logo.png or [1:v]).This is how you can tell overlay what inputs to use. You can omit [0:v][1:v], and overlay will still work, but it is recommended to be explicit and not rely on possibly unknown defaults
-
"-f flv"- output file format flv.
-
"pipe:1" - stdout
-
" | " - to connect two command together so that the output of one program becomes the input of the next program.
-
"-vf " - for creating filter graph on video
-
"drawtext" - Draw a text string or text from a specified file on top of a video
-
"text"- the text which we want to scroll.
-
"Fontfile" - the font of text
-
"y=((h)/2) " - y axis of the scrolling text, for middle h/2.
-
"x=(mod(5*n\,w+tw)-tw) "- For scrolling text we are setting x axis for each frame.
-
"fontcolor" - font color of text
-
"shadowx" - x axis shadow on text
-
"shadowy" - y axis shadow on text
-
"-vcodec" - video codec
-
"-vb" - video bitrate
-
"-acodec" - audio codec
-
"-ab " - audio bitrate
-
"-ar" - audio sampling rate
-
" -ac" - audio channel
-
"-muxdelay" - Set the maximum demux-decode delay in secs.
-
-
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Chandan Kumar Singh
Chandan is a bright Web Developer with expertise in Java and Spring framework and ORM tools Hibernate. He loves technologies like Blockchain and IoT.