Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

I have a video in mp4 with frame rate of .33 (i frame for 3 seconds). I want to increase the frame rate to 5 frames/sec. I have tried the below command but it does not do any thing...

ffmpeg -i <input.mp4> -r 5 <output.mp4>

Any idea why ffmpeg is ignoring -r option.

thank you

share|improve this question

migrated from stackoverflow.com Aug 7 '11 at 8:40

This question came from our site for professional and enthusiast programmers.

    
If you're trying to speed up / slow down a video, instead of duplicate / drop frames, see superuser.com/questions/854753/… and/or askubuntu.com/questions/370692/… – Peter Cordes Mar 1 '15 at 2:50

If the input file doesn't have a valid frame rate you might have to set it explicitly

ffmpeg -r 1 -i input.mp4 -r 24 output.mp4
share|improve this answer

I could only get the changed framerate to take effect if the input file was classed as a "raw" file:

ffmpeg -r 5 -f h264 -i input.h264 -vcodec copy -an output.mkv

Without specifying -f h264 it would default to 25 fps and it could not be changed. Apparently this was because the stream lacked any framerate information at all and this is ffmpeg's default framerate.

Apparently when you use -r as an output option it duplicates or drops frames so the video plays at the same speed - in this case, not what you want! But changing the input framerate as above will cause the video to speed up or slow down, with no frames lost or duplicated.

share|improve this answer

Such a feature - of changing framerate - is called "conforming" and is often used to produce slow-motion or fast-forward like showing a plant's growth in minutes insted of days. ffmpeg do not allow overwriting/changing framerate without re-encoding. If it does so, duration will change and audio would be out of sync unless separately mended. But I'm afraid audio is not of interest in your case with framerate of .33

You want conforming because you just want to change framerate, but ffmpeg ignores -r silently if framerate is specified in the input file. Since your input file is in .mp4 format, its own framerate take precedence of -r when re-encode isn't needed. For this you need a different tool: mencoder.

Assuming your input file contains no sound - likely true for any video with .33 framerate - what you need is:

$ mencoder -fps 5 -o <output> -ovc copy -nosound <input.mp4>

Notice that mencoder by default produce output in AVI format.

share|improve this answer
    
This is wrong. If r is specified as an output switch, ffmpeg will produce an output at that specified framerate, irrespective of the input's framerate. If r is specified as an input switch, ffmpeg will duplicate or drop frames as necessary to feed the specified number of frames per second of input to the filter/encoder. – Mulvya Jan 17 at 8:06
    
The behaviour you describe when r is an input switch contradicts with my earlier experiment on .mp4 format, Malvineous' note (on this page) and bug description 403 trac.ffmpeg.org/ticket/403 ; your description when r is used on output happens when re-encoding, while the scenario of OP seems to be a conforming case (fix framerate without re-encoding) by the fact that he had .33 framerate. – Zhang Weiwu Jan 18 at 20:01
    
Check report pasted here. Note the command line at the top, the input and output metadata and finally the no. of frames encoded. – Mulvya Jan 18 at 20:19
    
Agreed that the OP wants to just conform file but their given command is re-encoding since copy switch(es) isn't specified. In that scenario, ffmpeg should be generating new stream at r fps. – Mulvya Jan 18 at 20:25
    
Thank you Mulvya for the convincing sample output. Yes, you are right on the usage of -r. That usage couldn't affect my earlier experiments in response to OP because, thinking a conforming case, I never dropped copy parameter from ffmpeg, and -r is thus ignored. I wrote a feature request: trac.ffmpeg.org/ticket/5170 – Zhang Weiwu Jan 19 at 22:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.