0

Here is basically what I'm trying to do.

I have three files : 1. image.png 2. music.wav 3. video.mp4

I'm trying to create a new video file (mp4) with :

  1. IMAGE.PNG for the first 5 seconds
  2. VIDEO.MP4 for the duration of the file VIDEO.MP4 (example 60 seconds)
  3. IMAGE.PNG + MUSIC.WAV for the duration of MUSIC.WAV (example 60 seconds)

is it possible in FFMPEG ?

and if yes, is it possible in one "go" meaning without creating several intermediate video files ?

thanks a lot !

2

It's possible. Use

ffmpeg -loop 1 -i image.png -f lavfi -t 5 -i anullsrc -i video.mp4 -i music.wav \
-filter_complex "[0]trim=duration=5,fps=N[pre];[3]showwaves=WxH:r=N[b]; \
                 [b][0]overlay=shortest=1[post]; \
                 [pre][1:a][2:v][2:a][post][3]concat=n=3:v=1:a=1[v][a]" \
-map [v] -map [a] out.mp4

The image and video have to be of the same dimensions. If not, you should scale one of them, likely the image.

The fps filter should be set to the framerate of the video.

The showwaves is a kludge. Since the looped image stream does not terminate, I generate a video stream using showwaves from the audio, which will be of the same length as the WAV. WxH should be the same as the video, and r the same as the video's framerate.

Then the image is overlaid on top the filter is set to terminate when the waves video ends.

Finally, the concat filter assembles the full video.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.