I wanna overlay a picture on a video, as a watermark. How do I insert an animated watermark that randomly moves from side to side.
For example,
A watermark, placed on top/ upper-left corner, moves randomly to the top/upper-right corner and freezes there for five seconds before moving down to the lower- right corner.
I don't want the watermark to have a cross movement and move from the upper-right corner to the lower-left corner.
Here is an example of my code, using which the watermark randomly jumps to a corner each 200 frames without animate:
ffmpeg -i "source.mp4" -i "watermark.png" -filter_complex "[1:v]scale=50:-1[a]; [0:v][a]overlay=x='st(0,floor(random(n)*2)+1);if(eq(mod(n-1,200),0), if(eq(ld(0),1),0, main_w-overlay_w ) ,x)':y='st(0,floor(random(n)*2)+1);if(eq(mod(n-1,200),0),if(eq(ld(0),1),0, main_h-overlay_h ),y)'" -codec:a copy "out.mp4"
Related
I would like to animate panning within a 360 video. That is, base the panning on time or frame number.
The following does a fixed pan
ffmpeg -i "FileName" -vf v360=e:e:yaw=90:pitch=0:roll=0 "OutputFile"
Unfortunately my knowledge of expressions in ffmpeg is almost 0, how do I change the yaw=90 to a function of time?
I would like to know how to align the text in any sized photo/video frame in the top middle. I understand how to center the text on the x axis in any frame, so how do I make it always be at the top as well?
Heres what I've been doing so far:
ffmpeg -i input.jpg -vf "drawtext=font='Impact': text='Test Text': fontcolor=white: borderw=3: fontsize-75: x=(w-tw)/2:y=((h-text_h)/2)" output.jpg
By top-middle, I assume you mean horizontally centered and vertically centered within the top-third of the frame. That means the text has to be vertically centered around 1/6th the height. So, x=(w-tw)/2:y=h/6-th/2
Is it possible to continuously rotate an image or series of images and output as a video with ffmpeg? Rotating image should be centered over a background.
See example video.
Use the rotate filter to rotate the image, the color filter as a background, the overlay filter to place image over background, and the format filter to ensure widely compatible chroma subsampling for H.264 video.
ffmpeg -f lavfi -i color=c=00ff00:s=1280x720:d=10 -loop 1 -i image.png -filter_complex "[1]rotate=angle=PI*t:fillcolor=none:ow='hypot(iw,ih)':oh=ow[fg];[0][fg]overlay=x=(W-w)/2:y=(H-h)/2:shortest=1:format=auto,format=yuv420p" -movflags +faststart output.mp4
The speed is controlled by the rotate filter: specifically the angle parameter. Examples:
90 degrees clockwise per second: angle=90*PI/180*t
1 degree clockwise per frame: angle=PI/180*n
1 complete rotation (2 radians) per second counter-clockwise: angle=-2*PI*t
See the rotate filter documentation for more examples.
If you want GIF instead of MP4 see How do I output GIF using ffmpeg?
I want to add overlay images to videos with params
1: w:h --> is width and height of image on the video
2: r --> Radian is rotation of images
3: center (x,y) --> is center point of image in the video
This is my FFMPEG command :
-i video.mp4 -i image.png filter_complex [1:v]scale=w:h[scale];[scale]rotate=r:ow=iw:oh=ih[rotate];[0:v][rotate]overlay=x-(w/2):y-(h/2)
But the result not correct. It's Only work with scale=1 and rotate=0 radian
How can i do this ?
Ffmpeg command to rotate, scale, overlay and set image duration on a video
ffmpeg -i input.mp4 -i inputImg.png -filter_complex \"[1:v] rotate=90:c=none:ow=rotw(iw):oh=roth(ih) [rotate];[rotate]scale=100:-1[scale];[0:v][scale] overlay=0:0:enable='between(t,0,2)'[out]\" -map [out] -pix_fmt yuv420p -c:a copy output.mp4
Use
[1:v]scale=w:h,pad=iw+4:ih+4:black#0[scale];[scale]rotate=r:ow='rotw(r)':oh='roth(r)'[rotate]
A bit of transparent padding is added to the image before rotation. This is because the rotate filter will fill the gaps in the canvas with the input's border pixel color. Also, the output size has to be adjusted to accommodate the whole image after rotation. See the docs for the rotate filter.
I have a 720 x 1280 pixels video. How do I extend and scale it to 1920 x 1080 such that the aspect ratio is being kept and the black borders are a blurry version of the video, so you don't really notice that it's just a small vertical stripe.
Example
I started with
ffmpeg -i video720x1280.mp4 -vf "scale=608:1080,pad=width=1920:height=1080:x=656:y=0:color=black" video1920x1080.mp4
Use
ffmpeg -i video720x1280.mp4
-filter_complex
"[0]scale=hd1080,setsar=1,boxblur=20:20[b];
[0]scale=-1:1080[v];[b][v]overlay=(W-w)/2" video1920x1080.mp4
Adjust the two values in the boxblur filter for blur strength. Higher = more blurring.