Skip to content

Commit ad60c0e

Browse files
eromomondvrogozh
andcommitted
Tests: fix tests if running with self-built ffmpeg
If self-building ffmpeg from the tag for development reasons, it's version is set as `n6.1.2` (with n-prefix). This causes failures in the torchcodec tests. This patch handles such a case accounting for the `n6.1.2` ffmpeg version format. Co-authored-by: Dmitry Rogozhkin <[email protected]> Signed-off-by: Edgar Romo Montiel <[email protected]>
1 parent b01942c commit ad60c0e

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

test/test_metadata.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ def test_get_metadata(metadata_getter):
7878
with pytest.raises(NotImplementedError, match="Decide on logic"):
7979
metadata.bit_rate
8080

81-
ffmpeg_major_version = int(
82-
get_ffmpeg_library_versions()["ffmpeg_version"].split(".")[0]
83-
)
81+
ffmpeg_major_version = get_ffmpeg_major_version()
8482
if ffmpeg_major_version <= 5:
8583
expected_duration_seconds_from_header = 16.57
8684
expected_bit_rate_from_header = 324915

test/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ def cpu_and_cuda():
2828

2929

3030
def get_ffmpeg_major_version():
31-
return int(get_ffmpeg_library_versions()["ffmpeg_version"].split(".")[0])
31+
ffmpeg_version = get_ffmpeg_library_versions()["ffmpeg_version"]
32+
if ffmpeg_version.startswith("n"):
33+
ffmpeg_version = ffmpeg_version.removeprefix("n")
34+
return int(ffmpeg_version.split(".")[0])
3235

3336

3437
# For use with decoded data frames. On CPU Linux, we expect exact, bit-for-bit

0 commit comments

Comments
 (0)