Skip to content

Commit b08126c

Browse files
author
pytorchbot
committed
2025-02-26 nightly release (1670372)
1 parent 77939e5 commit b08126c

File tree

7 files changed

+30
-12
lines changed

7 files changed

+30
-12
lines changed

.github/workflows/cpp_tests.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ jobs:
1919
strategy:
2020
fail-fast: false
2121
matrix:
22-
ffmpeg-version-for-tests: ['4.4.2', '5.1.2', '6.1.1', '7.0.1']
22+
# TODO put back 6.1.1. See
23+
# https://github.com/pytorch/torchcodec/issues/518
24+
ffmpeg-version-for-tests: ['4.4.2', '5.1.2', '7.0.1']
2325
steps:
2426
- name: Check out repo
2527
uses: actions/checkout@v3

.github/workflows/linux_cuda_wheel.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ jobs:
6868
python-version: ['3.9']
6969
cuda-version: ['11.8', '12.4', '12.6']
7070
# TODO: put back ffmpeg 5 https://github.com/pytorch/torchcodec/issues/325
71-
ffmpeg-version-for-tests: ['6', '7']
71+
ffmpeg-version-for-tests: ['4.4.2', '6', '7']
72+
exclude:
73+
- cuda-version: '12.4' # TODO put this back it fails with infra issue.
74+
ffmpeg-version-for-tests: '4.4.2'
75+
7276
container:
7377
image: "pytorch/manylinux2_28-builder:cuda${{ matrix.cuda-version }}"
7478
options: "--gpus all -e NVIDIA_DRIVER_CAPABILITIES=video,compute,utility"
@@ -141,7 +145,7 @@ jobs:
141145
${CONDA_RUN} python test/decoders/manual_smoke_test.py
142146
- name: Run Python tests
143147
run: |
144-
${CONDA_RUN} FAIL_WITHOUT_CUDA=1 pytest test -vvv
148+
${CONDA_RUN} FAIL_WITHOUT_CUDA=1 pytest test -v --tb=short
145149
- name: Run Python benchmark
146150
run: |
147151
${CONDA_RUN} time python benchmarks/decoders/gpu_benchmark.py --devices=cuda:0,cpu --resize_devices=none

src/torchcodec/decoders/_core/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,7 @@ if(DEFINED ENV{BUILD_AGAINST_ALL_FFMPEG_FROM_S3})
7777
)
7878

7979

80-
if(NOT ENABLE_CUDA)
81-
# TODO: Enable more ffmpeg versions for cuda.
82-
make_torchcodec_library(libtorchcodec4 ffmpeg4)
83-
endif()
80+
make_torchcodec_library(libtorchcodec4 ffmpeg4)
8481
make_torchcodec_library(libtorchcodec7 ffmpeg7)
8582
make_torchcodec_library(libtorchcodec6 ffmpeg6)
8683
make_torchcodec_library(libtorchcodec5 ffmpeg5)

src/torchcodec/decoders/_core/VideoDecoderOps.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,12 @@ OpsFrameOutput get_next_frame(at::Tensor& decoder) {
240240

241241
OpsFrameOutput get_frame_at_pts(at::Tensor& decoder, double seconds) {
242242
auto videoDecoder = unwrapTensorToGetDecoder(decoder);
243-
auto result = videoDecoder->getFramePlayedAt(seconds);
243+
VideoDecoder::FrameOutput result;
244+
try {
245+
result = videoDecoder->getFramePlayedAt(seconds);
246+
} catch (const VideoDecoder::EndOfFileException& e) {
247+
C10_THROW_ERROR(IndexError, e.what());
248+
}
244249
return makeOpsFrameOutput(result);
245250
}
246251

test/decoders/test_video_decoder.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
assert_frames_equal,
1616
AV1_VIDEO,
1717
cpu_and_cuda,
18+
get_ffmpeg_major_version,
1819
H265_VIDEO,
19-
in_fbcode,
2020
NASA_VIDEO,
2121
)
2222

@@ -249,7 +249,7 @@ def test_getitem_slice(self, device, seek_mode):
249249
]
250250
)
251251
for sliced, ref in zip(all_frames, decoder):
252-
if not (in_fbcode() and device == "cuda"):
252+
if not (device == "cuda" and get_ffmpeg_major_version() == 4):
253253
# TODO: remove the "if".
254254
# See https://github.com/pytorch/torchcodec/issues/428
255255
assert_frames_equal(sliced, ref)
@@ -428,7 +428,7 @@ def test_get_frames_at_fails(self, device, seek_mode):
428428

429429
@pytest.mark.parametrize("device", cpu_and_cuda())
430430
def test_get_frame_at_av1(self, device):
431-
if in_fbcode() and device == "cuda":
431+
if device == "cuda" and get_ffmpeg_major_version() == 4:
432432
return
433433

434434
decoder = VideoDecoder(AV1_VIDEO.path, device=device)

test/decoders/test_video_decoder_ops.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,13 +308,17 @@ def test_get_frames_in_range(self, device):
308308
def test_throws_exception_at_eof(self, device):
309309
decoder = create_from_file(str(NASA_VIDEO.path))
310310
add_video_stream(decoder, device=device)
311+
311312
seek_to_pts(decoder, 12.979633)
312313
last_frame, _, _ = get_next_frame(decoder)
313314
reference_last_frame = NASA_VIDEO.get_frame_data_by_index(289)
314315
assert_frames_equal(last_frame, reference_last_frame.to(device))
315316
with pytest.raises(IndexError, match="no more frames"):
316317
get_next_frame(decoder)
317318

319+
with pytest.raises(IndexError, match="no more frames"):
320+
get_frame_at_pts(decoder, seconds=1000.0)
321+
318322
@pytest.mark.parametrize("device", cpu_and_cuda())
319323
def test_throws_exception_if_seek_too_far(self, device):
320324
decoder = create_from_file(str(NASA_VIDEO.path))

test/utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import torch
1313

14+
from torchcodec.decoders._core import get_ffmpeg_library_versions
15+
1416

1517
# Decorator for skipping CUDA tests when CUDA isn't available. The tests are
1618
# effectively marked to be skipped in pytest_collection_modifyitems() of
@@ -23,6 +25,10 @@ def cpu_and_cuda():
2325
return ("cpu", pytest.param("cuda", marks=pytest.mark.needs_cuda))
2426

2527

28+
def get_ffmpeg_major_version():
29+
return int(get_ffmpeg_library_versions()["ffmpeg_version"].split(".")[0])
30+
31+
2632
# For use with decoded data frames. On CPU Linux, we expect exact, bit-for-bit
2733
# equality. On CUDA Linux, we expect a small tolerance.
2834
# On other platforms (e.g. MacOS), we also allow a small tolerance. FFmpeg does
@@ -32,7 +38,7 @@ def assert_frames_equal(*args, **kwargs):
3238
if sys.platform == "linux":
3339
if args[0].device.type == "cuda":
3440
atol = 2
35-
if in_fbcode():
41+
if get_ffmpeg_major_version() == 4:
3642
assert_tensor_close_on_at_least(
3743
args[0], args[1], percentage=95, atol=atol
3844
)

0 commit comments

Comments
 (0)