-
Notifications
You must be signed in to change notification settings - Fork 395
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 multiple video backends (OpenCV sometimes drops frames resulting in correct timecodes) #213
Comments
This seems like a good approach, and may solve some other issues (e.g. #93). I need to learn a bit about the overall API to make it compatible with the Is VideoCapture not using ffmpeg on your system, or using a different version? I'm curious as to why this occurs. Very interesting, and thank you for the code sample! Edit: It may be worth supporting several backends for video input such as decord and pass this as a command line parameter. |
VideoCapture also use ffmpeg (libav) as backend on my system, but I have no idea why VideoCapture lost frames. I had noticed PyAV because of the slow speed of VideoCapture.seek(). PyAV might be helpful to speedup VideoManager.seek(). And, there is one more suggetion I want to give to. With PyAV, SceneDetector could detect more accurately/quickly by using the keyframe property. And it may be possible to control split accuration without re-encode (like this). |
TODO: Add a command line argument to expose the requested video input library. The current plan will be to default to PyAV, if installed, otherwise fall back to OpenCV. Will create a separate issue for supporting any other requested IO backends. It may also be possible to use PyAV directly for re-encoding videos, rather than invoking ffmpeg by command line. One major advantage of that approach would be that it could avoid passing timestamps to an external tool, ensuring everything lines up frame-by-frame. This also may influence how FrameTimecodes work - in particular, different backends could theoretically use different objects that have different representations. For now though will probably use what you posted above as a basis to start the transition. |
@elxy did you download the video using I plan on starting this as the first major task for the v1.0 refactor as this should also resolve several other linked issues. |
I had downloaded 4K format of https://www.youtube.com/watch?v=WzD_PREISiM with youtube-dl. I just checked that it's 4K format is 313 (webm vp9). |
Passes all non-seeking related tests. (#213)
Open items before v0.6 release discovered in #262:
|
Complete in v0.6-beta3 including multithreaded decoding. |
Description of Problem & Solution
I want to use the FrameTimecode to instruct ffmpeg process. But the FrameTimecode is different with ffmpeg.
For belowing media, the first 2 scenes detected of command
scenedetect -i Blossoms_at_the_Basin.mp4 detect-content list-scenes -n save-images
is:But the actual end frame number of scene 1 is 508 (start from 0), not 462. Look this:
I think the reason is that VideoCapture has dropped frames. I suggest to use PyAV to read frame. Because PyAV can decode frame with index and pts props.
Media Examples:
Blossoms_at_the_Basin.mp4
is the 4K format of https://www.youtube.com/watch?v=WzD_PREISiMProposed Implementation:
Here is a demo to read frames with PyAV:
The text was updated successfully, but these errors were encountered: