Pushing ip camera stream to live video url with scrolling text and scrolling logo using ffmpeg
Posted By : Chandan Kumar Singh | 28-Jul-2015
In this blog I am going to explain how to scroll the logo on top of the screen as well as text in the middle of the screen. As I have explained the input will be our live video source or ip camera stream and output also will we another live video source.
Lets see the command :
ffmpeg -thread_queue_size 32 -rtsp_transport tcp -i rtsp://admin:admin@69.58.126.201:554/h264/ch1/main/av_stream -framerate 25 -i /home/oodles/Desktop/logo.png -filter_complex "[0:v][1:v]overlay=x=(mod(3*n\,main_w+overlay_w)-overlay_w):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 -acodec aac -f flv -muxdelay 0.1 rtmp://oodles:oodles@192.168.67.128:1935/live-demo/mstream
Explanation of command:
-
-thread_queue_size - Allow to set the thread message queue size, here 32
-
-rtsp_transport - Set RTSP transport protocols, here tcp
-
-i - specifies the input file stored in local disk or live audio/video source.
-
rtsp://admin:admin@69.58.126.201:554/h264/ch1/main/av_stream - input live camera ip
-
-framerate - Set the framerate, here 25 fps. You can also use -r instead of -framerate
-
-filter_complex - to recognize filtergraph
-
[0:v][1:v]overlay=x=(mod(3*n\,main_w+overlay_w)-overlay_w):10 - [0:v] is our main input, rtsp://admin:admin@69.58.126.201:554/h264/ch1/main/av_stream
[1:v] is our overlay input, here /home/oodles/Desktop/logo.png.
overlay=x=(mod(3*n\,main_w+overlay_w)-overlay_w):10- means we want to scrolling position of logo to the left and 10px down, originating from the top left corner.
now,
n is number of input frames starting from 0.
main_w is the main input width.
overlay_w is the second (logo) input width. here what we are doing is for each frame we are calculating x axis
-
-f - output file format, here flv
-
pipe:1 - it is for stdout (standard output)
-
| - To connect two command together so that the output of one program becomes the input of the next program
-
pipe:0 - it is for stdin(standard input).
-
-vf - video filter
-
-drawtext - Draw a text string or text from a specified file on top of a video
-
text - text which you want to add on video
-
fontfile - the font of text
-
x=(mod(5*n\,w+tw)-tw):y=(h/2)
here
n is number of input frames starting from 0
w is the main input width.
tw is the rendered text width
h height of screen
-
fontsize - the size of font
-
fontcolor - color of text
-
shadowx - x axis,shadow on text
-
shadowy - y axis,shadow on text
-
-vcodec - Set the video codec. This is an alias for -codec:v , here libx264.
-
-acodec - set the audio codec ,here audio codec is aac
-
-muxdelay - Set the maximum demux-decode delay in secs. here 0.1 sec
-
rtmp://oodles:oodles@192.168.67.128:1935/live-demo/mstream - the target url where we pushed the video. oodles:oodles is username and password of wowza.
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.