Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Starting with this file

Input #0, flac, from 'bar.flac':
  Duration: 00:02:52.48, bitrate: 503 kb/s
    Stream #0:0: Audio: flac, 44100 Hz, stereo, s16

running this command yields similar output duration, however slow to encode.

$ time ffmpeg -loop 1 -i foo.jpg -i bar.flac -shortest slow.mp4    
frame= 4371 fps= 46 q=-1.0 Lsize=    4497kB time=00:02:54.76 bitrate= 210.8kbits/s

real    1m34.318s
user    0m0.000s
sys     0m0.015s

I can lower the input framerate which speeds up the encode significantly, but now the duration is quite off

$ time ffmpeg -loop 1 -r 1 -i foo.jpg -i bar.flac -shortest fast.mp4    
frame=  232 fps= 31 q=-1.0 Lsize=    2860kB time=00:03:50.00 bitrate= 101.9kbits/s

real    0m7.566s
user    0m0.000s
sys     0m0.015s

Can I change my command so that encode speed is decent without messing the duration?

share|improve this question
I assume this is because you placed -r before -i, where ffmpeg takes one image every second. What happens when you put -r after the -i options? – slhck Mar 24 '13 at 10:16
How do you mean, it doesn't work? Does the command fail? Ideally that'd only change the output frame rate. But yeah, mark4o's suggestion seems reasonable. (Please don't flag comments such as the above as obsolete – they might still be useful to others. Thanks) – slhck Mar 24 '13 at 14:45
@slhck the time stays at 00:00:00, encode never ends – Steven Penny Mar 24 '13 at 14:54
For me, time stays at 00:00:00 for a while, but not forever. In any case, it delivers output that's off by a minute or more. Weird. – slhck Mar 24 '13 at 15:01
up vote 2 down vote accepted

Replace -shortest with -t 2:52.48 (i.e. the desired duration).

Unfortunately, -shortest is not completely accurate, as it only stops on internal buffer boundaries (which may have a very long duration in the case of 1 fps static looping video).

share|improve this answer
True, even without -r 1, it's off by more than two seconds for me. Didn't know it was that inaccurate. – slhck Mar 24 '13 at 15:01

You must log in to answer this question.

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