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(
656
656
657
657
// Returns version information about the various FFMPEG libraries that are
658
658
// 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
659
663
std::string _get_json_ffmpeg_library_versions () {
660
664
std::stringstream ss;
661
665
ss << " {\n " ;
Original file line number Diff line number Diff line change 15
15
create_from_file ,
16
16
get_container_metadata ,
17
17
get_container_metadata_from_header ,
18
- get_ffmpeg_library_versions ,
19
18
VideoStreamMetadata ,
20
19
)
21
20
from torchcodec .decoders import AudioDecoder , VideoDecoder
@@ -78,9 +77,7 @@ def test_get_metadata(metadata_getter):
78
77
with pytest .raises (NotImplementedError , match = "Decide on logic" ):
79
78
metadata .bit_rate
80
79
81
- ffmpeg_major_version = int (
82
- get_ffmpeg_library_versions ()["ffmpeg_version" ].split ("." )[0 ]
83
- )
80
+ ffmpeg_major_version = get_ffmpeg_major_version ()
84
81
if ffmpeg_major_version <= 5 :
85
82
expected_duration_seconds_from_header = 16.57
86
83
expected_bit_rate_from_header = 324915
Original file line number Diff line number Diff line change @@ -28,7 +28,13 @@ def cpu_and_cuda():
28
28
29
29
30
30
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
+ # 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 ])
32
38
33
39
34
40
# 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