Use duration from streams as its more precise#6171
Conversation
BigRoy
left a comment
There was a problem hiding this comment.
I didn't test the code - so not sure if there are any annoying side effects to this.
It might be good to also add a comment above this code that states something like:
# Use duration of the individual streams since it is returned with
# higher decimal precision than 'format.duration'. We need this
# more precise value for calculating the correct amount of frames
# for higher FPS ranges or decimal ranges, e.g. 29.97 FPS
Just so someone doesn't come along in a year optimizing it back to what it was now.
It'd be extra nice if we can have a "test" implemented for this particular bug so that we can ensure the problem remains resolved over time. It might be quite some work to do so though, but it would be the best case scenario to implement with PRs like these. Unfortunately implementing tests currently is still quite a hefty and involved process than just a few lines of code.
Yeah, will do.
Yea, the testing framework needs to be more dev friendly. |
Changelog Description
When dealing with 30 fps mov of 2 frames, the duration was reduce to 3 decimal places (0.067) which meant that the flag for ffmpeg
-ssended up with a time that was not precise enough for ffmpeg to pick a frame;0.0335. Should be0.0333.Using the duration from the streams is more precise;
0.066667.Testing notes: