I have multiple images that I want to fade and zoompan for each image but when I do what others have said, the first image works perfect and the second is black. I want to have 25 images and the same thing occurs with every image black except the first one. I am sure I am missing something elementary. Please help.
ffmpeg -r .1 -i image_1.jpg -i image_2.jpg -vf "zoompan=z='min(zoom+0.0015,1.5)':d=125,fade=t=in:st=0:d=0.5,fade=t=out:st=4.5:d=0.5" -pix_fmt yuv420p output.mp4
Try using making a complex filtergraph similar to the following
-filter_complex "[0:v] panzoom, fadeout [scene1]; [1:v] panzoom, fadeout [scene2]; [scene1][scene2] concat=n=2 [output]" -map "output" output.mp4
Related
I have this example video, recorded by Kazam:
https://user-images.githubusercontent.com/1997316/178513325-98513d4c-49d4-4a45-bcb2-196e8a76fa5f.mp4
It's a 1022x728 video.
I need to add a drop shadow identical to the one generated by the "Drop shadow (legacy)" filter of Gimp with the default settings. So, I generated with Gimp a PNG containing only the drop shadow. It's a 1052x758 image:
Now I want to put the video over the image to get a new video with the drop shadow. The wanted effect for the first frame is:
So, the video must be placed over the image. The top-left corner of the video must be in the position 11x11 of the background image.
How can I achieve this result?
I tried without success the following command. What's wrong?
ffmpeg -i shadow.png -i example.mp4 -filter_complex "[0:v][1:v] overlay=11:11'" -pix_fmt yuv420p output.mp4
About the transparency of the PNG background image, if it can't be maintained, then it's okay for the shadow to be on a white background. Otherwise, if it can be maintained by using an animated GIF as the output format, it is better.
The solution is to remove the transparency from shadow.png. Then:
ffmpeg -i example.mp4 -filter_complex "[0:v] palettegen" palette.png
ffmpeg -loop 1 -i shadow.png -i example.mp4 -i palette.png -filter_complex "[1:v] fps=1,scale=1022:-1[inner];[0:v][inner]overlay=11:11:shortest=1[new];[new][2:v] paletteuse[out]" -map '[out]' -y output.gif
The result is exactly what I wanted:
This solution is inspired by the answer https://stackoverflow.com/a/66318325 and by the article https://www.baeldung.com/linux/convert-videos-gifs-ffmpeg
I am adding an animated gif as an overlay to a video with a command like this:
ffmpeg -y -i video.mp4 -i overlay.gif -filter_complex "[0:v][1:v] overlay=38:11:enable='between(t,1.35,15.042000)'" -pix_fmt yuv420p -c:a copy -safe 0 output.mp4
In that command I'm asking it to show the gif from 1.35 to 15, and that works insofar as the overlay is only shown between those times, but it's as if the animation starts before it reaches 1.35, because the bit of the animation before that point doesn't ever appear on the screen. The start of the animation is missing from the final video.
Tried in ffmpeg-20180925-a7429d8 and ffmpeg-N-100581-ga454a0c14f
Typically, I find the answer after posting:
https://dev.to/oskarahl/ffmpeg-overlay-a-video-on-a-video-after-x-seconds-4fc9
Solution:
Use the setpts filter to delay the overlay video (gif.mp4) start with x seconds.
ffmpeg -i main_video.mp4 -i gif.mp4 -filter_complex
“[1:v]setpts=PTS-STARTPTS+1/TB[delayedGif];
[0:v][delayedGif]overlay=enable='between(t,1,3)'[out]”
-map [out] complete.mp4
The setpts filter evaluates its expression and assigns the value as the timestamp for the current frame it is processing.
I am overlaying a video on top of an image.
Using this command:
ffmpeg -i image.png -i input.mp4 -filter_complex "[0:v][1:v] overlay=10:10:enable='between(t,0,38)'" -pix_fmt yuv420p -c:a copy output.mp4
I understand the overlay=10:10 is the positioning but I can't seem to work out how to resize the overlay video (input.mp4).
I think I need to use scale but not sure how to.
Any help on scaling the overlay video would be appreciated!
With filter_complex you can combine commands and make named outputs
Try something like this:
ffmpeg -i image.png -i input.mp4 -filter_complex "[1:v]scale=320x240[scaled_v];[0:v][scaled_v] overlay=10:10:enable='between(t,0,38)'" -pix_fmt yuv420p -c:a copy output.mp4
Just change resolution to what you need instead of 320x240.
If you need image overlay on top of video, swap [1:v] and [0:v]
I have bunch of images that i have to convert to slideshow with curtain effect. currently i am running this command that convert images to video.
ffmpeg -r 1/5 -i img%d.png -c:v libx264 -vf "fps=25,format=yuv420p" video.mp4
But how to achieve this kind of effect with ffmpeg. Image link Required result
I searched online but not found any solution. I have clue of alpha mask but no idea how to use it for such result.
ffmpeg -y -i img1.png -i img2.png -i img3.png -filter_complex "[0:v]zoompan=z='zoom+0.0000':d=50[img1];[1:v]zoompan=z='if(lte(zoom,1.0),1.1,max(1.001,zoom-0.0030))':d=200[img2];[img1][img2]blend=all_expr='if(lte((H/2-sqrt((Y-H/2)*(Y-H/2)))+N*8*SH,H/2),A,B)'[img1img2];[1:v]zoompan=z='zoom+0.0000':d=50[img2];[2:v]zoompan=z='if(lte(zoom,1.0),1.1,max(1.001,zoom-0.0030))':d=200[img3];[img2][img3]blend=all_expr='if(lte((H/2-sqrt((Y-H/2)*(Y-H/2)))+N*8*SH,H/2),A,B)'[img2img3];[img1img2][img2img3]concat=n=2[final]" -map "[final]" out.mp4
This ffmpeg command will generate door open (curtain) effect.
Here is logic.
Suppose you have there images you want to create this effect. First create blend effect of first img1 and img2. Then create another blend effect with img2 and img3. then merge these 2 generated videos.
Im trying to build a simple video editor and im using ffmpeg on the background. I want as much different filters/properties in one command but im not succeeding in placing a still image before everything else (first frame). I want a vstack after the image has shown in a video.
I tried a lot of different commands etc. and most of the time the video renders but the image included in the vstack, or the video doesn't start for the amount of seconds I want the still image to be shown.
ffmpeg -hide_banner -i "header.jpg" -i "video.mp4" -i "footer" -i "still-image.jpg" -filter_complex "[1][3]overlay=0:0:enable='between(t,0,4)';vstack=inputs=3" -pix_fmt yuv420p -c:a copy -y output.mp4
Most of the time I don't get an error. It just isn't doing what's expected. The above command is one of the many I tried but is basically what I want. Can someone help please?
There are several ways to do this. This method delays the vstack and overlays still-image.jpg during the delay.
ffmpeg -i "header.jpg" -i "video.mp4" -i "footer.jpg" -i "still-image.jpg" -filter_complex "[0][1][2]vstack=inputs=3[v0];[v0]tpad=start_duration=4[bg];[bg][3]overlay=(W-w)/2:(H-h)/2:enable='between(t,0,4)',format=yuv420p[v];[1:a]adelay=4s:all=true[a]" -map "[v]" -map "[a]" output.mp4
Requires FFmpeg 4.2 or newer.