New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Force frame rate of FFMpegFileWriter input #5453
Conversation
The output video file was observed to skip frames, when input frame rate does not match output (e.g., when fps=1, or interval=1000). See https://www.ffmpeg.org/ffmpeg.html#Description for a description of the solution.
Interesting. Any idea if that's a new option (I've never noticed it before)? My only concern would be that it would break on some other version of ffmpeg. |
Good point, I've actually first observed the error with FFMPEG v2.6, then updated to v2.8.1, where I've validated the proposed solution. I could double check on other versions, what is the lowest supported, or which versions should I cover? |
On my CentOS6 machine, I see that the -r option is available and is documented to force a frame rate. Here is the version info:
|
And with
|
@@ -446,7 +446,7 @@ class FFMpegFileWriter(FileMovieWriter, FFMpegBase): | |||
def _args(self): | |||
# Returns the command line parameters for subprocess to use | |||
# ffmpeg to create a movie using a collection of temp images | |||
return [self.bin_path(), '-i', self._base_temp_name(), | |||
return [self.bin_path(), '-r', str(self.fps), '-i', self._base_temp_name(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is now too long.
Was wanting to double check when So, minus the pep8 issue, I'm 👍 on the change. As an aside, I really wish there were a better way to do this than to constantly tinker with the ffmpeg command line incantation. |
It's also in the RHEL 5 man page (ffmpeg 0.5.2) Is a similar fix needed for the pipe based writer? |
Looking at the pipe-based writer, I think it's already covered; the rate is set before the |
Ensure line length is <80.
@dopplershift See #4416 😉 |
FIX: Force frame rate of FFMpegFileWriter input
@auneri Thanks! |
@tacaswell, @dopplershift, here is another one that has cost me hours of frustration. It is fixing a big bug, so I would like to backport it. In fact, from my reading of the avconv and ffmpeg docs (it applies to both), the second '-r' option is at best superfluous; the critical thing is to have the '-r' option specified before the '-i' option. Any '-r' option after the '-i' serves to drop or duplicate frames in an attempt to match the rate of the input. |
👍 on backporting. |
FIX: Force frame rate of FFMpegFileWriter input
Backported to v2.x as c0c65e3. |
I am failing to see this change (or any change that addresses this issue) in master or 2.x, am I missing something? |
Good catch. This is very puzzling. Some changes--not just this one--seem to have gone missing. I suspect something went wrong in all the backwards and forwards between v2.x and master. Or maybe I simply fouled it up myself. I will try to track it down. |
I'm the culprit. Somehow, not long after merging this, I got mixed up and removed the wrong '-r'--and even left a comment in its place. I will fix it now. |
OK, it should be fixed in v2.x and master now. Thanks for catching that, @auneri. |
The output video file was observed to skip frames, when input frame rate does not match output (e.g., when fps=1, or interval=1000).
See https://www.ffmpeg.org/ffmpeg.html#Description for a description of the solution.