File tree Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -656,6 +656,10 @@ std::string get_stream_json_metadata(
656656
657657// Returns version information about the various FFMPEG libraries that are
658658// loaded in the program's address space.
659+ // TODO: ideally we'd have a more robust way of getting the ffmpeg version,
660+ // we're using av_version_info() which is not standardized and shouldn't be
661+ // parsed by code (which we do!). See
662+ // https://github.com/pytorch/torchcodec/issues/100
659663std::string _get_json_ffmpeg_library_versions () {
660664 std::stringstream ss;
661665 ss << " {\n " ;
Original file line number Diff line number Diff line change 1515 create_from_file ,
1616 get_container_metadata ,
1717 get_container_metadata_from_header ,
18- get_ffmpeg_library_versions ,
1918 VideoStreamMetadata ,
2019)
2120from torchcodec .decoders import AudioDecoder , VideoDecoder
@@ -78,9 +77,7 @@ def test_get_metadata(metadata_getter):
7877 with pytest .raises (NotImplementedError , match = "Decide on logic" ):
7978 metadata .bit_rate
8079
81- ffmpeg_major_version = int (
82- get_ffmpeg_library_versions ()["ffmpeg_version" ].split ("." )[0 ]
83- )
80+ ffmpeg_major_version = get_ffmpeg_major_version ()
8481 if ffmpeg_major_version <= 5 :
8582 expected_duration_seconds_from_header = 16.57
8683 expected_bit_rate_from_header = 324915
Original file line number Diff line number Diff line change @@ -28,7 +28,13 @@ def cpu_and_cuda():
2828
2929
3030def 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+ # When building FFmpeg from source there can be a `n` prefix in the version
33+ # string. This is quite brittle as we're using av_version_info(), which has
34+ # no stable format. See https://github.com/pytorch/torchcodec/issues/100
35+ if ffmpeg_version .startswith ("n" ):
36+ ffmpeg_version = ffmpeg_version .removeprefix ("n" )
37+ return int (ffmpeg_version .split ("." )[0 ])
3238
3339
3440# For use with decoded data frames. On CPU Linux, we expect exact, bit-for-bit
You can’t perform that action at this time.
0 commit comments