0

I am trying to create a video out of two images figure1.png and figure2.png (which may be of different sizes) and two audio files audio1.wav and audio2.wav. I want to do it such that figure1.png shows until audio1.wav stops playing and then figure2.png shows until audio2.wav stops playing (with audio2.wav starting after audio1.wav). I am having no real luck doing this. My best attempt so far is to create two videos and try and merge them but due to formating issues this does not seem to work. I was therefore wondering is there was a way to do this with a single ffmpeg command and if so what?

0

2 Answers 2

2

Let's say the size of the first image is larger and is WxH. If not scale down the 2nd size and then pad. Either way, both images should have the same size.

ffmpeg -i image1.png -i image2.png -i audio1.wav -i audio2.wav
  -filter_complex
     "[0]setsar=1[a];
      [1]pad=W:H:(ow-iw)/2:(oh-ih)/2:color=white,setsar=1[b];
      [2]abitscope=r=25:s=WxH[a1v]; 
      [3]abitscope=r=25:s=WxH[a2v];
      [a1v][a]overlay[v1];
      [a2v][b]overlay[v2];
      [v1][2:a][v2][3:a]concat=n=2:v=1:a=1"  out.mp4    
8
  • Hi Mulvya this looks like it should work but I am getting an error: [AVFilterGraph @ 0x2317500] No output pad can be associated to link label '1'. Error initializing complex filters. Invalid argument Any ideas? May 15, 2017 at 11:15
  • 1
    Missed a semicolon; added.
    – Gyan
    May 15, 2017 at 11:26
  • Sorry to be a pain, I am now getting the error No such filter: 'abitscope' I can't seem to find how to download/install this filter - do you know how I can get it? May 15, 2017 at 14:23
  • Use a very recent build.
    – Gyan
    May 15, 2017 at 14:25
  • I am using linux (mint) and I appear to have the most recent version, I have also tried downloading libavfilter-dev but I still get this error. May 15, 2017 at 15:05
0

You should first create the video without audio i guess. To do that:

ffmpeg -framerate 24 -i figure%01d.png output.mp4

%01d is the pattern of your png file names. I assume mp4 container format will be suitable.

After that, according to the duration of your audio files (you should adjust calculate them manually, there is no automatic fitting mechanism as far as i know).

ffmpeg -loop 1 -i figure%01d.png -i audio.wav -c:v libx264 -c:a aac -b:a 192k -shortest out.mp4

Here internal AAC encoder is used but you can use any other AAC encoding mechanism as well.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .