Skip to content

Encoder: properly set frame pts values #726

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

Merged
merged 11 commits into from
Jul 3, 2025

Conversation

NicolasHug
Copy link
Member

@NicolasHug NicolasHug commented Jun 13, 2025

This PR makes sure we properly set the AVFrames's pts values before sending them to the encoder.

This removes a bunch of warnings that were visible when using TORCHCODEC_FFMPEG_LOG_LEVEL=DEBUG. I added tests to make sure these warnings have now disappeared. I also confirmed that the tests fail on main without the fixes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jun 13, 2025
@NicolasHug NicolasHug changed the title Encoder: validate pts of encoded frames Encoder: properly set frame pts values Jul 3, 2025
@NicolasHug NicolasHug marked this pull request as ready for review July 3, 2025 11:40
if method == "to_file":
validate_frames_properties(actual=encoded_by_us, expected=encoded_by_ffmpeg)
else:
assert method == "to_tensor", "wrong test parametrization!"
Copy link
Member Author

@NicolasHug NicolasHug Jul 3, 2025

Choose a reason for hiding this comment

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

Interestingly enough, the call to validate_frames_properties() was passing on main. That's because the underlying encoder was able to infer pts valid values. But it was emitting warnings that were visible in DEBUG mode.

The other tests we have above (assert ... not in captured.err) make sure those warnings aren't emitted anymore, confirming we are now correctly setting the pts values explicitly.

@NicolasHug NicolasHug merged commit ffb65f6 into pytorch:main Jul 3, 2025
42 of 44 checks passed
Dan-Flores pushed a commit to Dan-Flores/torchcodec that referenced this pull request Jul 17, 2025
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 Meta Open Source bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants