VideoHelp Forum
+ Reply to Thread
Results 1 to 7 of 7
Thread
  1. Hi, I need to combine a single image and an audio file to get a video of the same duration as the audio. The reason is that the image is the waveform of the audio track and with this trick the playback bar of the videoplayer seems to follow the shape of the audio.
    I'm perfectly capable of doing this with Premiere Pro but for convenience I'd like to do it with FFmpeg.

    I tried but the video duration is always a few seconds longer than the audio. Always...
    I used this script, what am I doing wrong?
    Code:
    ffmpeg -loop 1 -i 01.png -i 01.wav -c:v libx264 -pix_fmt yuv420p -tune stillimage -c:a aac -b:a 256k -shortest -y output.mp4

    01.wav is 7 s 249 ms long, the video obtained with this script is 9 s 200 ms long..
    I attach the files of my test
    Click image for larger version

Name:	01.png
Views:	119
Size:	10.8 KB
ID:	64170
    01.wav
    Quote Quote  
  2. I think this may solve your issue https://ffmpeg.org/ffmpeg-filters.html#amovie

    I think explicitly specifying frame rate may improve overall behavior.

    (not sure as i can only assume where is the issue - to small framerate + too long GOP may lead to such behavior)
    Quote Quote  
  3. I didn't understand how to use the information on that page. What should I use?

    I've tried to add -framerate option but the result is still wrong
    Code:
    ffmpeg -loop 1 -framerate 50 -i 01.png -i 01.wav -c:v libx264 -pix_fmt yuv420p -tune stillimage -c:a aac -b:a 256k -shortest -y output.mp4
    Meanwhile I found this but it still does not solve my problem
    https://stackoverflow.com/questions/55800185/my-ffmpeg-output-always-add-extra-30s-of-...04507#55804507
    Quote Quote  
  4. Originally Posted by frenksisco View Post
    I didn't understand how to use the information on that page. What should I use?

    I've tried to add -framerate option but the result is still wrong
    Code:
    ffmpeg -loop 1 -framerate 50 -i 01.png -i 01.wav -c:v libx264 -pix_fmt yuv420p -tune stillimage -c:a aac -b:a 256k -shortest -y output.mp4
    Meanwhile I found this but it still does not solve my problem
    https://stackoverflow.com/questions/55800185/my-ffmpeg-output-always-add-extra-30s-of-...04507#55804507
    I was able to duplicate your problem. And using the information from that link I was able to fix it.

    Code:
    ffmpeg -loop 1 -i 01.png -i 01.wav -c:v libx264 -pix_fmt yuv420p -tune stillimage -c:a aac -b:a 256k -shortest -fflags +shortest -y output.mp4
    Quote Quote  
  5. Great! Yes problem solved! The video duration is 7 s 400 ms while the audio duration is 7 s 249 ms. I think they can't really be coincident because of the difference between audio samples and frames. Anyway I'm totally satisfied! Thank you very much!
    Quote Quote  
  6. Yes, the default frame rate in ffmpeg is 25 fps. So the granularity of video is 40 ms. 7.4 seconds is exactly 185 frames at 25 fps.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!