Here is what I'm trying to achieve:
- Inputs are an MP3 or WAV, and an image (JPG or PNG)
- The output should be an MP4 video with the MP3 audio with the image, at 60FPS for a very smooth fade in/fade out (black) on the video (1s each)
I strugguling to make this fade in / fade out. Here is what I have:
ffmpeg -r 1 -loop 1 -i image.jpg -i audio.mp3 -acodec copy -r 60 -shortest -vf fade=in:0:01 -pix_fmt yuv420p output.mp4
My fadein is static, so black image and then my video, not smooth. How do I get a smooth 60FPS fade?
I also have another request, let's say I have an overlay video that I want to concatenate to my video. If I concatenate a video to the existing video, the overlay will also be on top of the fades which is not right, how can I achieve this? Thank you so much.
You're setting
nb_frame=1with your filter optionsin:0:01. If you wish to fade duration, you need to specify the option name:in:duration=1(start_time=0option is unnecessary as 0 is the default).For fadeout, you need to specify the
start_timeoption so runffprobefirst to get the duration of the mp3 file.As for the overlay, you must do it before fading. Your filterchain should look like
[0:v][1:v]overlay,fade:in,fade:out[addendum] Fading effect requires frames to realize it, increase the framerate before the filter
fade:[0:v][1:v]overlay,fps=60,fade:in,fade:out. And remove-r 60from the output option (or leave it in as it shouldn't do anything anyway).