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.py read_video_timestamps calculate pts without storing full frames #2202

Merged
merged 3 commits into from
May 19, 2020

Conversation

mjunyent
Copy link
Contributor

To calculate the PTS the function is storing the full frame objects on memory. This makes it crash for longer videos as it can't fill everything. PTS can be calculated directly.

With this fix we don't call _read_from_stream. That's ok as most of the code deals with seeking which is not needed in this case, but video decoding is surrounded by a try/except that we're not doing here. I'm not sure if a try/except av.AVError should be added too as it's not done in the demux either. Also, do we really want to mute this exception?

Copy link
Member

@fmassa fmassa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot, this was an oversight I believe!

I do think that we had issues with AVError being raised for some cases though, so might be preferable to handle those exceptions in here as well.

My thinking is that if we have a corrupted file in the dataset, we should not break the training code right away but instead skip this file, which was handled in the previous implementation.

Let me know what you think

@mjunyent
Copy link
Contributor Author

It makes sense. I don't have any problem in adding a check for AVError but then shouldn't we add one too when _can_read_timestamps_from_packets is True? Or _can_read_timestamps_from_packets ensures demux won't crash.

Copy link
Member

@fmassa fmassa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move forward with this as this is a net improvement I think.
But I think for a follow-up PR we should add another check for if the decoding fails, so that we can keep the behavior as before.

Can you send a follow-up PR?

@fmassa fmassa merged commit e6b4078 into pytorch:master May 19, 2020
@fmassa
Copy link
Member

fmassa commented May 19, 2020

Thanks a lot!

fmassa pushed a commit that referenced this pull request May 29, 2020
* get pts directly instead of storing full frames to get pts later

* fix linting

* add initial pts value
sort pts

* catch decoding errors for read_video_timestamp
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.

2 participants