Skip to content
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

Support for seeking by frame via ConvertTimeFormat #526

Open
berndfuhrmann opened this issue Dec 21, 2022 · 1 comment
Open

Support for seeking by frame via ConvertTimeFormat #526

berndfuhrmann opened this issue Dec 21, 2022 · 1 comment

Comments

@berndfuhrmann
Copy link

It would be helpful to have frame-based seeking in the LAV demuxer. I need it specifically for MP4.
I saw #338 and wondered, if it would be possible to use FFMPEG to seek to the right frame, maybe by using libavformat av_index_search_timestamp.
Fully supporting frames in SetTimeFormat could be a bit much to ask. But maybe adding support for ConvertTimeFormat would be less work. IMHO it would just be a call to FFMPEG and if in luck, a result is returned, if not, an error is returned. That could make frame-based seeking doable for some applications.

I hope I understand DirectShow correct there, but it seems IsFormatSupported would then still label frames as unsupported format. It would just happen to work in ConvertTimeFormat, if conditions are right.

Do you think that approach makes sense? If you think that is acceptable, I could try to make a PR.

Thanks in advance for considering!

@clsid2
Copy link
Contributor

clsid2 commented Dec 21, 2022

Converting from timestamp to frame number or vice-versa will never be very accurate due to rounding errors, gaps, or even variable frame rate. But I guess you could do something like this:
seek_time = start_time + (frame_number + 0.5) * frame_rate
(the +0.5 is to calculate the time in middle of start and end of frame, so least chance of getting wrong one)

For frame by frame playback you can also use this:
https://learn.microsoft.com/en-us/windows/win32/api/strmif/nn-strmif-ivideoframestep

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants