I am trying to make a video with multiple input files. I have a bunch of PNG files and mp4 files and I want to create a video for the duration of my audio file body.mp3

The video should be made using multiple inputs.

  1. file 000000.PNG for duration 17.56
  2. file 01.mp4 (duration ~4.0)
  3. file 100074.PNG for duration 6.12
  4. file 02.mp4 (duration ~4.0)
  5. file 200074.PNG for duration 7.84
  6. file 03.mp4 (duration ~4.0)
  7. file 300074.PNG for duration 11.88

The total video will have only one audio from body.mp3. Assuming body.mp3 duration is equal to all the inputs duration combined (+/- 2.0)

Could you please show me how to achieve this?

Edit: Same resolution for all the input files and same frame rate in all the *.mp4 files. Some times, I may have 04.mp4 and 400074.PNG also.

  • 2
    Same resolution in all inputs? Same framerate in all MP4s? – Gyan Aug 20 '19 at 5:32
  • @Gyan Yeah... same resolution for all the inputs and framerate in all the MP4s. I've edited my question to reflect this. – Testaccount Aug 20 '19 at 12:50

Let's say the framerate of the MP4s is 30, then you would use

ffmpeg -i body.mp3
       -framerate 30 -loop 1 -t 17.56 -i 000000.PNG
       -i 01.mp4
       -framerate 30 -loop 1 -t 6.12  -i 100074.PNG
       -i 02.mp4
       -framerate 30 -loop 1 -t 7.84  -i 200074.PNG
       -i 03.mp4
       -framerate 30 -loop 1 -t 11.88 -i 300074.PNG
-filter_complex "[1][2][3][4][5][6][7]concat=n=7:v=1:a=0[v]"
-map "[v]" -map 0:a -pix_fmt yuv420p out.mp4

(All in one line; use single-quotes if you're on linux/OSX)

  • you are a life saver.. thank you very much! – Testaccount Aug 20 '19 at 17:34
  • Could you please explain what the -filter_complex and -map does? I'm trying to add more inputs(1-8 .mp4 and PNGs) to the above script and it won't encode the newly added inputs. – Testaccount Aug 22 '19 at 4:11

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.