11# This file exposes helpers to create and expose FFmpeg targets as torchcodec::ffmpeg${N}
22# where N is the FFmpeg major version.
33
4- # List of FFmpeg versions that TorchCodec can support - that's not a list of
5- # FFmpeg versions available on the current system!
4+ # List of FFmpeg versions that TorchCodec can support - that's not a list of
5+ # FFmpeg versions available on the current system!
66set (TORCHCODEC_SUPPORTED_FFMPEG_VERSIONS "4;5;6;7;8" )
77
8- # Below we define FFmpeg library names we expect to have for each FFmpeg
9- # major version on each platform we support.
10- if (LINUX)
11- set (
12- f4_library_file_names
13- libavutil.so.56
14- libavcodec.so.58
15- libavformat.so.58
16- libavdevice.so.58
17- libavfilter.so.7
18- libswscale.so.5
19- libswresample.so.3
20- )
21- set (
22- f5_library_file_names
23- libavutil.so.57
24- libavcodec.so.59
25- libavformat.so.59
26- libavdevice.so.59
27- libavfilter.so.8
28- libswscale.so.6
29- libswresample.so.4
30- )
31- set (
32- f6_library_file_names
33- libavutil.so.58
34- libavcodec.so.60
35- libavformat.so.60
36- libavdevice.so.60
37- libavfilter.so.9
38- libswscale.so.7
39- libswresample.so.4
40- )
41- set (
42- f7_library_file_names
43- libavutil.so.59
44- libavcodec.so.61
45- libavformat.so.61
46- libavdevice.so.61
47- libavfilter.so.10
48- libswscale.so.8
49- libswresample.so.5
50- )
51- set (
52- f8_library_file_names
53- libavutil.so.60
54- libavcodec.so.62
55- libavformat.so.62
56- libavdevice.so.62
57- libavfilter.so.11
58- libswscale.so.9
59- libswresample.so.6
60- )
61- elseif (APPLE )
62- set (
63- f4_library_file_names
64- libavutil.56.dylib
65- libavcodec.58.dylib
66- libavformat.58.dylib
67- libavdevice.58.dylib
68- libavfilter.7.dylib
69- libswscale.5.dylib
70- libswresample.3.dylib
71- )
72- set (
73- f5_library_file_names
74- libavutil.57.dylib
75- libavcodec.59.dylib
76- libavformat.59.dylib
77- libavdevice.59.dylib
78- libavfilter.8.dylib
79- libswscale.6.dylib
80- libswresample.4.dylib
81- )
82- set (
83- f6_library_file_names
84- libavutil.58.dylib
85- libavcodec.60.dylib
86- libavformat.60.dylib
87- libavdevice.60.dylib
88- libavfilter.9.dylib
89- libswscale.7.dylib
90- libswresample.4.dylib
91- )
92- set (
93- f7_library_file_names
94- libavutil.59.dylib
95- libavcodec.61.dylib
96- libavformat.61.dylib
97- libavdevice.61.dylib
98- libavfilter.10.dylib
99- libswscale.8.dylib
100- libswresample.5.dylib
101- )
102- set (
103- f8_library_file_names
104- libavutil.60.dylib
105- libavcodec.62.dylib
106- libavformat.62.dylib
107- libavdevice.62.dylib
108- libavfilter.11.dylib
109- libswscale.9.dylib
110- libswresample.6.dylib
111- )
112- elseif (WIN32 )
113- set (
114- f4_library_file_names
115- avutil.lib
116- avcodec.lib
117- avformat.lib
118- avdevice.lib
119- avfilter.lib
120- swscale.lib
121- swresample.lib
122- )
123- set (
124- f5_library_file_names
125- avutil.lib
126- avcodec.lib
127- avformat.lib
128- avdevice.lib
129- avfilter.lib
130- swscale.lib
131- swresample.lib
132- )
133- set (
134- f6_library_file_names
135- avutil.lib
136- avcodec.lib
137- avformat.lib
138- avdevice.lib
139- avfilter.lib
140- swscale.lib
141- swresample.lib
142- )
143- set (
144- f7_library_file_names
145- avutil.lib
146- avcodec.lib
147- avformat.lib
148- avdevice.lib
149- avfilter.lib
150- swscale.lib
151- swresample.lib
152- )
153- set (
154- f8_library_file_names
155- avutil.lib
156- avcodec.lib
157- avformat.lib
158- avdevice.lib
159- avfilter.lib
160- swscale.lib
161- swresample.lib
162- )
163- else ()
164- message (
165- FATAL_ERROR
166- "Unsupported operating system: ${CMAKE_SYSTEM_NAME} "
167- )
168- endif ()
169-
1708# Create and expose torchcodec::ffmpeg${ffmpeg_major_version} target which can
1719# then be used as a dependency in other targets.
17210# prefix is the path to the FFmpeg installation containing the usual `include`
@@ -182,6 +20,37 @@ function(add_ffmpeg_target ffmpeg_major_version prefix)
18220 message (FATAL_ERROR "No prefix defined calling add_ffmpeg_target()" )
18321 endif ()
18422
23+ # Define library names based on platform and FFmpeg version
24+ if (LINUX)
25+ if (ffmpeg_major_version EQUAL 4)
26+ set (library_file_names libavutil.so.56 libavcodec.so.58 libavformat.so.58 libavdevice.so.58 libavfilter.so.7 libswscale.so.5 libswresample.so.3)
27+ elseif (ffmpeg_major_version EQUAL 5)
28+ set (library_file_names libavutil.so.57 libavcodec.so.59 libavformat.so.59 libavdevice.so.59 libavfilter.so.8 libswscale.so.6 libswresample.so.4)
29+ elseif (ffmpeg_major_version EQUAL 6)
30+ set (library_file_names libavutil.so.58 libavcodec.so.60 libavformat.so.60 libavdevice.so.60 libavfilter.so.9 libswscale.so.7 libswresample.so.4)
31+ elseif (ffmpeg_major_version EQUAL 7)
32+ set (library_file_names libavutil.so.59 libavcodec.so.61 libavformat.so.61 libavdevice.so.61 libavfilter.so.10 libswscale.so.8 libswresample.so.5)
33+ elseif (ffmpeg_major_version EQUAL 8)
34+ set (library_file_names libavutil.so.60 libavcodec.so.62 libavformat.so.62 libavdevice.so.62 libavfilter.so.11 libswscale.so.9 libswresample.so.6)
35+ endif ()
36+ elseif (APPLE )
37+ if (ffmpeg_major_version EQUAL 4)
38+ set (library_file_names libavutil.56.dylib libavcodec.58.dylib libavformat.58.dylib libavdevice.58.dylib libavfilter.7.dylib libswscale.5.dylib libswresample.3.dylib)
39+ elseif (ffmpeg_major_version EQUAL 5)
40+ set (library_file_names libavutil.57.dylib libavcodec.59.dylib libavformat.59.dylib libavdevice.59.dylib libavfilter.8.dylib libswscale.6.dylib libswresample.4.dylib)
41+ elseif (ffmpeg_major_version EQUAL 6)
42+ set (library_file_names libavutil.58.dylib libavcodec.60.dylib libavformat.60.dylib libavdevice.60.dylib libavfilter.9.dylib libswscale.7.dylib libswresample.4.dylib)
43+ elseif (ffmpeg_major_version EQUAL 7)
44+ set (library_file_names libavutil.59.dylib libavcodec.61.dylib libavformat.61.dylib libavdevice.61.dylib libavfilter.10.dylib libswscale.8.dylib libswresample.5.dylib)
45+ elseif (ffmpeg_major_version EQUAL 8)
46+ set (library_file_names libavutil.60.dylib libavcodec.62.dylib libavformat.62.dylib libavdevice.62.dylib libavfilter.11.dylib libswscale.9.dylib libswresample.6.dylib)
47+ endif ()
48+ elseif (WIN32 )
49+ set (library_file_names avutil.lib avcodec.lib avformat.lib avdevice.lib avfilter.lib swscale.lib swresample.lib)
50+ else ()
51+ message (FATAL_ERROR "Unsupported operating system: ${CMAKE_SYSTEM_NAME} " )
52+ endif ()
53+
18554 set (target "torchcodec::ffmpeg${ffmpeg_major_version} " )
18655 set (include_dir "${prefix} /include" )
18756 if (LINUX OR APPLE )
@@ -193,7 +62,7 @@ function(add_ffmpeg_target ffmpeg_major_version prefix)
19362 endif ()
19463
19564 list (
196- TRANSFORM f ${ffmpeg_major_version} _library_file_names
65+ TRANSFORM library_file_names
19766 PREPEND ${lib_dir} /
19867 OUTPUT_VARIABLE lib_paths
19968 )
0 commit comments