1

thanks to the answers to this superuser question Combine one image + one audio file to make one video using FFmpeg i was able to create a video from a single image and an audio track.

i used PJ Brunets code:

ffmpeg -r 1 -loop 1 -i 00.png -i 00.wav -acodec copy -r 1 -shortest 00.avi

it works fine, but i noticed that the duration of the generated video is longer than the original audio track. in my case the audio is 36,61 seconds and the resulting video is 38 seconds.

i think the issue comes from the low frame rate, therefore i rose the frame rate from 1 fps to 2 fps until 25 fps and compared the results: with higher frame rates you get more accuracy in duration.

now my question is: is there a way to still use 1 fps, but truncate the last frame when the audio finishes? in this way you could achieve faster encoding times without losing the original length.

stefano
  • 11
  • 1
  • AFAIK, not possible for AVI. AVIs don't store PTS, so duration of each frame is reciprocal of framerate, so your duration is quantized as per that value. – Gyan Aug 01 '16 at 18:59
  • is there another container like avi that can store lossless wav? – stefano Aug 01 '16 at 21:03
  • MOV, MKV, NUT.. – Gyan Aug 02 '16 at 04:51
  • mov & mkv are less accurate than avi (40-41s). nut is 37s but not accepted by youtube. i have to release lots of +1h long tracks and other single tracks which have to follow each other seamless like in a mix. i came to the conclusion to use avi 1fps (with +1,5s error) for the long tracks and avi 2fps (+1s) for the single tracks. 10fps (+0,2s) or 25 fps (almost accurate) would be better for seamless transition, but the image becomes blocky after 4fps and up. if i do the same job with sony vegas images don't become blocky, but it needs much more time to encode and min. framerate is 12fps. – stefano Aug 03 '16 at 15:02
  • If you need to append multiple audio/video segments precisely, use the concat filter. It should work with 1 fps, but in any case, with codec libx264 and 24 fps, it will work. – Gyan Aug 04 '16 at 09:49
  • i'm not interested in concatenating the videos. i want them in the same length as the original audio files, with the lowest possible frame rate since they're just single image videos. anyway, thank you for your help. – stefano Aug 04 '16 at 16:21
  • You're currently encoding with mpeg4 with a default bitrate of 200 kb/s. That's why they look blocky above 4 fps. If you encode with libx264 and a framerate of 25 fps, it won't take much more space, since x264 will store duplicate frames in 30-50 bytes each, and your duration will be more exact. – Gyan Aug 04 '16 at 16:35
  • i followed your instructions: images aren't blocky anymore, but x264 is slower in encoding and less accurate in duration, forcing me to use higher frame rates to achieve same accuracy. therefore i tried the native mpeg4 (fastest encoding) and libxvid (a little bit slower) with different bitrates. i noticed the 1st frame is always blocky (slightly smoother with xvid), after that it works fine. which bitrates do you recommend for single image videos at 10fps-20fps? – stefano Aug 05 '16 at 03:18
  • Don't worry about framerate. Use 25 fps or 30 fps if you need to. With `libx264`, add `-preset veryfast`. With mpeg4/xvid, use bitrate of 2000kb/s. Don't output to AVI, which is a 25 year old container. Use MOV or MKV. – Gyan Aug 05 '16 at 04:44

0 Answers0