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

[Video Reader] add caching and retry limit for bad video tolerance #119

Merged
merged 5 commits into from
Dec 22, 2020

Conversation

zhreshold
Copy link
Member

@zhreshold zhreshold commented Dec 19, 2020

Add cached frame in case some video is corrupted and in the previous version it's silently handled by rewinding to nearest "good" frame, this will increase the chance of infinite rewinding if the video is completely corrupted.

So if a corrupted video is read by VideoReader with some bad frames(e.g., 200-300 out of 300 frames), retrieving vr[200] to `vr[299] will return vr[199] instead.

If you don't care about duplicate frames in this case, no worries.
If you want to prevent this from happening frequently(not ideal for training), then set the hard limit and catch the error on the fly to detect bad videos:

from decord import DECORDLimitReachedError
# accept at most 10 corrupted and recovered frames:
for video in videos:
    vr = VideoReader(video, fault_tol=10)
    # or percentage, e.g. 10% bad frames allowed
    # vr = VideoReader(video, fault_tol=0.1)
    try:
         # do what ever, read batch or loop
    except DECORDLimitReachedError:
        # handle bad video
    except DECORDError:
        # handle other types of error raised from decord

@zhreshold zhreshold merged commit 9e34141 into master Dec 22, 2020
@zhreshold zhreshold deleted the fail-tolerance branch December 22, 2020 21:13
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

Successfully merging this pull request may close these issues.

None yet

1 participant