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

Fix decoding issue with PYAV due to new support for multiple training… #541

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

dfan
Copy link

@dfan dfan commented May 10, 2022

See issue #181. When using pyav as a backend, we get the exception pyav with exception: unsupported operand type(s) for -: 'list' and 'int'. This is because num_frames is now a list. torchvision_decode() is correct but not pyav_decode().

@facebook-github-bot
Copy link
Contributor

Hi @dfan!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 22, 2022
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

1 similar comment
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot
Copy link
Contributor

@lyttonhao has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@XinyuSun
Copy link

Hi! There is an error in the code:
Line 442 and 443 should be:
442: video_start_pts = int(start_idx * timebase)
443: video_end_pts = int(end_idx * timebase)

@facebook-github-bot
Copy link
Contributor

@lyttonhao has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@dfan
Copy link
Author

dfan commented Jun 12, 2022

Very sorry ... yes you are right. With this additional fix I am now able to achieve correct results with the new code. Thanks and sorry again!

@lyttonhao
Copy link
Contributor

Very sorry ... yes you are right. With this additional fix I am now able to achieve correct results with the new code. Thanks and sorry again!

Do you want to update the code? Thanks!

@junchen14
Copy link

See issue #181. When using pyav as a backend, we get the exception pyav with exception: unsupported operand type(s) for -: 'list' and 'int'. This is because num_frames is now a list. torchvision_decode() is correct but not pyav_decode().

this can solve the problems that I faced

@StawEndl
Copy link

Very sorry ... yes you are right. With this additional fix I am now able to achieve correct results with the new code. Thanks and sorry again!

hi,
i use the pyav_decode functiopn to read the video, but this function return the decode_all_video which is False. When decode_all_video is False, the start_end_delta_time is not created.
#557
how to fix it?

@XinyuSun
Copy link

pyav is much slower than other decode backends. I'm considering adding support to the decord backend.

@facebook-github-bot
Copy link
Contributor

@lyttonhao has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@dfan has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@lyttonhao has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Copy link
Contributor

@lyttonhao lyttonhao left a comment

Choose a reason for hiding this comment

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

Looks great! We should also handle the case when duration is None

@@ -414,35 +418,49 @@ def pyav_decode(
else:
Copy link
Contributor

Choose a reason for hiding this comment

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

For line 414-417, we should also decode the whole videos and return the frames. Example code could be:

        decode_all_video = True
        video_start_pts, video_end_pts = 0, math.inf
        start_end_delta_time = None

        frames = None
        if container.streams.video:
            video_frames, max_pts = pyav_decode_stream(
                container,
                video_start_pts,
                video_end_pts,
                container.streams.video[0],
                {"video": 0},
            )

            frames = [frame.to_rgb().to_ndarray() for frame in video_frames]
            frames = torch.as_tensor(np.stack(frames))
        frames_out = [frames]

@facebook-github-bot
Copy link
Contributor

@dfan has updated the pull request. You must reimport the pull request before landing.

@dfan
Copy link
Author

dfan commented Jun 23, 2022

Good catch! I saw there were additional fixes to the decoder.py in 6069ea9 - do you want me to include those changes or will you merge those in?

@lyttonhao
Copy link
Contributor

Good catch! I saw there were additional fixes to the decoder.py in 6069ea9 - do you want me to include those changes or will you merge those in?

Yeah, that would be great if you could also include those changes!

@facebook-github-bot
Copy link
Contributor

@dfan has updated the pull request. You must reimport the pull request before landing.

@dfan
Copy link
Author

dfan commented Jul 23, 2022

Apologies for the delay

JerryYLi pushed a commit to JerryYLi/SlowFast that referenced this pull request Jul 23, 2022
@cir7
Copy link

cir7 commented Oct 12, 2022

@dfan hi, i am curious why remove parameter use_offset when call get_multiple_start_end_idx in line 456

@M-Masuhara
Copy link

Hi. I started using SlowFast last week and I get the same error as you.

As for DECODING_BACKEND, I have tried pyav and torchvision, but both show the following error.

pyav:
Failed to decode by pyav with exception: unsupported operand type(s) for -: 'list' and 'int'
Failed to decode video idx 63 from C:/ ~ video path ; trial 99

torchvision:
Failed to decode by torchvision with exception: 'OpNamespace' object has no attribute 'probe_video_from_memory'
Failed to decode video idx 63 from C:/ ~ video path ; trial 99

As for slowfast>datasets>decoder.py, it has already been corrected as described here.

The libraries version are as follows:

PyTorch = 1.12.1
torchvision = 0.13.1
ffmpeg = 1.4
pyav = 9.2.0

What is not good?
I would like to solve this problem somehow with pyav.
Please help.

@zsz00
Copy link

zsz00 commented Dec 21, 2022

I meet leaks issue too.

haritha91 added a commit to haritha91/SlowFast that referenced this pull request Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet