diff options
| author | dec05eba <dec05eba@protonmail.com> | 2026-08-05 02:06:11 +0200 |
|---|---|---|
| committer | dec05eba <dec05eba@protonmail.com> | 2026-08-05 02:06:11 +0200 |
| commit | b9d252214a46aa64047893cb557f060a8978b006 (patch) | |
| tree | 63bafc0eb9d2a9b6bc23aa7242e81e0cac86794c /subprojects/packagefiles/ffmpeg/meson.build | |
| parent | 1869cf30519fc61c7f9852f8f25f8b1c2b2e8c3b (diff) | |
Add option to statically compile ffmpeg from source
Diffstat (limited to 'subprojects/packagefiles/ffmpeg/meson.build')
| -rw-r--r-- | subprojects/packagefiles/ffmpeg/meson.build | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/subprojects/packagefiles/ffmpeg/meson.build b/subprojects/packagefiles/ffmpeg/meson.build new file mode 100644 index 0000000..38df7e9 --- /dev/null +++ b/subprojects/packagefiles/ffmpeg/meson.build @@ -0,0 +1,35 @@ +project('ffmpeg', 'c', version : '8.1') + +# Neither ffmpeg nor the libraries it depends on use meson, so they are built with their +# own build systems into a shared prefix and then exposed to gpu-screen-recorder as +# regular pkg-config dependencies. + +install_prefix = meson.current_build_dir() / 'install' +c_compiler = ' '.join(meson.get_compiler('c').cmd_array()) +build_library = find_program(meson.global_source_root() / 'extra' / 'build_ffmpeg.sh') + +# srt links against openssl and ffmpeg links against all of them, so the order matters. +libraries = ['nv-codec-headers', 'x264', 'opus', 'openssl', 'srt', 'ffmpeg'] + +foreach library : libraries + source_dir = library == 'ffmpeg' ? meson.current_source_dir() : subproject(library).get_variable('source_dir') + build_result = run_command(build_library, library, source_dir, meson.current_build_dir() / library, install_prefix, c_compiler, check : true) + if build_result.stderr().strip() != '' + message(build_result.stderr().strip()) + endif +endforeach + +ffmpeg_libs = ['libavformat', 'libavfilter', 'libavcodec', 'libswresample', 'libavutil'] + +pkgconfig = find_program('pkg-config') +pkgconfig_env = environment() +pkgconfig_env.prepend('PKG_CONFIG_PATH', install_prefix / 'lib' / 'pkgconfig') + +ffmpeg_cflags = run_command(pkgconfig, '--cflags', ffmpeg_libs, env : pkgconfig_env, check : true).stdout().split() +ffmpeg_ldflags = run_command(pkgconfig, '--static', '--libs', ffmpeg_libs, env : pkgconfig_env, check : true).stdout().split() + +ffmpeg_dep = declare_dependency(compile_args : ffmpeg_cflags, link_args : ffmpeg_ldflags) + +foreach ffmpeg_lib : ffmpeg_libs + meson.override_dependency(ffmpeg_lib, ffmpeg_dep) +endforeach |
