3

Here is basically what I'm trying to do.

I have two files : 1. image.png 2. video.mp4

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

IMAGE.PNG for the first 5 seconds

VIDEO.MP4 for the duration of the file VIDEO.MP4 (example 60 seconds)

IMAGE.PNG for 5 seconds

is it possible in FFMPEG?

thanks a lot !

2

One method is to use the concat filter:

ffmpeg -framerate 25 -loop 1 -t 5 -i image.png -i video.mp4 -f lavfi -t 0.1 -i anullsrc -filter_complex "[0][2][1:v][1:a][0][2]concat=n=3:v=1:a=1[v][a]" -map "[v]" -map "[a]" output.mp4
  • The anullsrc filter generates silent audio as filler for proper concatenation. The concat filter will automatically pad the silent audio, so you only need a very short duration for anullsrc (this example uses -t 0.1).

  • This assumes your image is the same width, height, and aspect ratio as video.mp4. If it is not then you'll have to filter the image to match with the scale, pad, crop, or scale2ref filters. There are plenty of example of how to do this on Stack Exchange.

  • You didn't provide any info on your inputs or ffmpeg build so I only provided this basic example.

  • An alternative method is to use the concat demuxer which can avoid re-encoding video.mp4, but it can be somewhat harder to use because you'll have to make the video from the image first and made sure all of the parameters are the same as video.mp4. See the FFmpeg Wiki, and again search Stack Exchange for dozens of examples.

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.