-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Why FFMPEGFrameGrabber doesn't correctly process the previous frame on some videos? #1849
Comments
For typical formats, seeking is a not a simple process. If the only frame you need to access is the previous frame, I would recommend to decode as usual, but copy each frame into another a "previousFrame" object or something, and use that one when you need to access the previous frame. |
@DeNRuDi , this is most likely because you are using |
@anotherche Didn't realize there was such a method, thanks. I tried to call the |
@DeNRuDi |
Well, after a careful study of the situation, I see - these are not b-frames. This is again the "good old" rounding errors. Since the timestamps do not strictly follow the FPS increment, the error in determining the frame number lies within + -1. Therefore, the error in determining the position of two adjacent frames can theoretically be in the range from -1 to +3. Perhaps this can be corrected. But the problem associated with the inconsistency of the time stamp increment in the general case seems insurmountable. All the same, to select adjacent frames, it is best to read them sequentially. |
@anotherche okay, I understand, thanks. In general, in my implementation, it is not known in advance when the previous frame should be received. Sometimes it needs to be received 1 time, sometimes 10, so allocating a frame buffer for my implementation is so-so. I have an idea for my implementation - I want to try, in case of receiving the previous frame, first check which frame was received, and if it is 2-3 less than I need, then simply use |
@DeNRuDi Improvements from @anotherche have been merged! |
@saudet perfectly. I'll try this. Thanks. |
@saudet finally got around to trying the |
The fix for this has been released with JavaCV 1.5.8. Thanks for the contribution! |
Hello! Sorry for my bad English, i am from Ukraine🙂
I am facing a problem on android when i want to get the previous frame. On some videos, the previous frame is set correctly, but on some it happens that instead of rewinding 1 frame, the grabber rewinds ~ 10-30 frames (most often equal to the number of fps). This only happens when rewinding of back, when I get the next frame - I always get the correct frame. My guess is that this problem is due to the closest frame capture (like as in MediaMetadataRetriever
OPTION_CLOSEST_SYNC
). Here is the most simplified code that can cause this problem:How can it be solved? Maybe I missed something in the documentation? Noticed this on mp4 video format.
Thank you.
The text was updated successfully, but these errors were encountered: