Open berndfuhrmann opened 1 year ago
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
It would be helpful to have frame-based seeking in the LAV demuxer. I need it specifically for MP4. I saw https://github.com/Nevcairiel/LAVFilters/issues/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!