Skip to content

Conversation

@Dan-Flores
Copy link
Contributor

@Dan-Flores Dan-Flores commented Oct 14, 2025

This PR enables encoding a video to file_like, similar to the AudioEncoder. The VideoEncoder constructor accept an AVIOContextHolder and file format. It is instantiated with AVIOFileLikeContext.

Testing:

  • test_video_encoder_round_trip and test_against_to_file are updated to test to_file_like method.
  • test_to_file_like_custom_file_object, test_to_file_like_real_file, test_to_file_like_bad_methods tests are added.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 14, 2025
@Dan-Flores Dan-Flores changed the title to_tensor, AVIOTensorContext fix Add to_filelike support for VideoEncoder Oct 14, 2025
@Dan-Flores Dan-Flores marked this pull request as ready for review October 14, 2025 19:51
@Dan-Flores Dan-Flores changed the title Add to_filelike support for VideoEncoder Add to_file_like support for VideoEncoder Oct 14, 2025
@Dan-Flores
Copy link
Contributor Author

Addressed feedback from 3e97d89:

  • Added more detailed file_like tests, similar to the ones that exist for AudioEncoder
  • Added TODO for tests that use different memory layouts (test_contiguity)
  • Removed seek(0)

Copy link
Contributor

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

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

Nice, thanks @Dan-Flores

test/test_ops.py Outdated
assert psnr(s_frame, rt_frame) > 30
assert_close(s_frame, rt_frame, atol=atol, rtol=0)

@pytest.mark.slow
Copy link
Contributor

Choose a reason for hiding this comment

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

QQ was the whole test slow or is it just webm?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching this, I should have deleted it after adding pytest.param("webm", marks=pytest.mark.slow).

@Dan-Flores Dan-Flores merged commit fe738a6 into meta-pytorch:main Oct 20, 2025
59 checks passed
@Dan-Flores Dan-Flores deleted the video_to_filelike branch October 20, 2025 23:25
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.

2 participants