Skip to content

Conversation

@Dan-Flores
Copy link
Contributor

@Dan-Flores Dan-Flores commented Nov 17, 2025

This PR resolves the first two bullet points in #1057:

  • parametrize test_video_encoder_against_ffmpeg_cli over the other encoding methods (to_file_like, to_tensor)
  • call self._get_video_metadata in this test to ensure the expected metadata is the same

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 17, 2025
# There may be additional subtle differences in the encoder.
percentage = 94 if ffmpeg_version == 6 or format == "avi" else 99
# MPEG codec used for avi format does not accept CRF
percentage = 94 if format == "avi" else 99
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had difficulty returning identical frames for avi with the default codec, mpeg4. We could consider choosing a specific codec for this test to enforce quality, but I think its ok to keep the relaxed exactness check in this case.

@Dan-Flores Dan-Flores marked this pull request as ready for review November 17, 2025 18:42
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.

Thanks @Dan-Flores

fields=fields,
)
for key in ffmpeg_metadata:
assert ffmpeg_metadata[key] == encoder_metadata[key]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should be able to just assert ffmpeg_metadata == encoder_metadata ?

Comment on lines 995 to 997
# Write tensor to file to check with ffprobe
with open(encoder_output_path, "wb") as f:
f.write(encoded_output.numpy().tobytes())
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's OK to only validate to_file against ffprobe, that's what we do for the audio encoder and it makes this test a tiny bit easier to follow. No strong opinion. If you remove it from here, make sure to remove it from to_file_like as well.

if method == "to_file":
validate_frames_properties(actual=encoded_by_us, expected=encoded_by_ffmpeg)

@Dan-Flores Dan-Flores merged commit b0097cc into meta-pytorch:main Nov 18, 2025
97 of 99 checks passed
@Dan-Flores Dan-Flores deleted the encoder_test_against_cli_improvements branch November 18, 2025 19:05
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