Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions src/torchcodec/_core/custom_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,10 @@ std::string get_stream_json_metadata(

// Returns version information about the various FFMPEG libraries that are
// loaded in the program's address space.
// TODO: ideally we'd have a more robust way of getting the ffmpeg version,
// we're using av_version_info() which is not standardized and shouldn't be
// parsed by code (which we do!). See
// https://github.com/pytorch/torchcodec/issues/100
std::string _get_json_ffmpeg_library_versions() {
std::stringstream ss;
ss << "{\n";
Expand Down
5 changes: 1 addition & 4 deletions test/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
create_from_file,
get_container_metadata,
get_container_metadata_from_header,
get_ffmpeg_library_versions,
VideoStreamMetadata,
)
from torchcodec.decoders import AudioDecoder, VideoDecoder
Expand Down Expand Up @@ -78,9 +77,7 @@ def test_get_metadata(metadata_getter):
with pytest.raises(NotImplementedError, match="Decide on logic"):
metadata.bit_rate

ffmpeg_major_version = int(
get_ffmpeg_library_versions()["ffmpeg_version"].split(".")[0]
)
ffmpeg_major_version = get_ffmpeg_major_version()
if ffmpeg_major_version <= 5:
expected_duration_seconds_from_header = 16.57
expected_bit_rate_from_header = 324915
Expand Down
8 changes: 7 additions & 1 deletion test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ def cpu_and_cuda():


def get_ffmpeg_major_version():
return int(get_ffmpeg_library_versions()["ffmpeg_version"].split(".")[0])
ffmpeg_version = get_ffmpeg_library_versions()["ffmpeg_version"]
# When building FFmpeg from source there can be a `n` prefix in the version
# string. This is quite brittle as we're using av_version_info(), which has
# no stable format. See https://github.com/pytorch/torchcodec/issues/100
if ffmpeg_version.startswith("n"):
ffmpeg_version = ffmpeg_version.removeprefix("n")
return int(ffmpeg_version.split(".")[0])


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