Skip to content

pytorch/torchcodec - 3.12 fixes #744

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 1 commit into from
Jun 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 27 additions & 20 deletions test/test_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

import contextlib
import io
import os
from functools import partial
Expand Down Expand Up @@ -555,11 +556,7 @@ def test_color_conversion_library_with_dimension_order(
def test_color_conversion_library_with_generated_videos(
self, tmp_path, width, height, width_scaling_factor, height_scaling_factor
):
ffmpeg_cli = "ffmpeg"
if os.environ.get("IN_FBCODE_TORCHCODEC") == "1":
import importlib.resources

ffmpeg_cli = importlib.resources.path(__package__, "ffmpeg")
# We consider filtergraph to be the reference color conversion library.
# However the video decoder sometimes uses swscale as that is faster.
# The exact color conversion library used is an implementation detail
Expand All @@ -573,22 +570,32 @@ def test_color_conversion_library_with_generated_videos(
# We don't specify a particular encoder because the ffmpeg binary could
# be configured with different encoders. For the purposes of this test,
# the actual encoder is irrelevant.
command = [
ffmpeg_cli,
"-y",
"-f",
"lavfi",
"-i",
"color=blue",
"-pix_fmt",
"yuv420p",
"-s",
f"{width}x{height}",
"-frames:v",
"1",
video_path,
]
subprocess.check_call(command)
with contextlib.ExitStack() as stack:
ffmpeg_cli = "ffmpeg"

if os.environ.get("IN_FBCODE_TORCHCODEC") == "1":
import importlib.resources

ffmpeg_cli = stack.enter_context(
importlib.resources.path(__package__, "ffmpeg")
)

command = [
ffmpeg_cli,
"-y",
"-f",
"lavfi",
"-i",
"color=blue",
"-pix_fmt",
"yuv420p",
"-s",
f"{width}x{height}",
"-frames:v",
"1",
video_path,
]
subprocess.check_call(command)

decoder = create_from_file(str(video_path))
add_video_stream(decoder)
Expand Down
Loading