FFmpeg learning (5) - video watermarking

1. To achieve logo appear alternately every 10 seconds

ffmpeg -y -t 60 -i input.mp4 -i logo1.png -i logo2.png -filter_complex "overlay=x=if(lt(mod(t\,20)\,10)\,10\,NAN ):y=10,overlay=x=if(gt(mod(t\,20)\,10)\,W-w-10\,NAN ) :y=10" output.mp4

When the 60-editing video, fill out only if the video processing and output the first 60 seconds, do not fill the entire video will handle
x x coordinate of the upper left corner of the watermark
y y coordinate of the upper left corner of the watermark
input.mp4 input video files (need to be addressed a)
output.mp4 output from the video file (the processing has been completed)
IF (gt (MOD (T, 20 is), 10), 10-Ww, from NAN) the length of said second logo 10 appears, that is the watermark It will display for 10 seconds


2. To achieve Marquee

ffmpeg -i input1 -i input2 -vcodec libx264 -an -filter_complex "overlay=x='if(gte(t,2), -w+(t-2)*20, NAN)':y=0" -s 320x240 output.mp4

on the bottom of the video input1
input2 video on top of
the width and height of the output video 320x240


3. logo achieved two seconds moves from left to right

ffmpeg -i input.mp4 -vf "movie=logo.png[logo];[in][logo]overlay=x='if(gte(t\,2)\,((t-2)*80)-w\,NAN)'" output.mp4

80 from movement in pixels


4. Implement logo gif format command cycle

ffmpeg -i video.mpg -ignore_loop 0 -i loop.gif -filter_complex  "[0:v][1:v]overlay=10:10:shortest=1" -vcodec mpeg2video out.mpg

5. Add captions for video

ffmpeg  -i  input  -vf  drawtext=fontfile=arial.ttf:text=welcome output

6. Implement periodic display of the input text watermark

ffmpeg -i input.mp4 -vf "drawtext=fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf:text='testtest':x=w-100:y=100:enable=lt(mod(t\,3)\,1):fontsize=24:[email protected]:shadowy=2" output.mp4

7. Write code has encountered an error

Cannot create buffer sink ret = -12 
修改
AVFilter *buffersrc  = avfilter_get_by_name("buffer");
AVFilter *buffersink = avfilter_get_by_name("buffersink");

 

Published 295 original articles · won praise 37 · views 30000 +

Guess you like

Origin blog.csdn.net/tianshan2010/article/details/104737501