mirror of
https://github.com/infiniteCable2/openpilot.git
synced 2026-08-05 00:05:57 +08:00
ffmpeg: use shared libraries (#38308)
This commit is contained in:
+17
-2
@@ -43,6 +43,21 @@ assert arch in [
|
||||
pkg_names = ['acados', 'bzip2', 'capnproto', 'catch2', 'eigen', 'ffmpeg', 'json11', 'libyuv', 'ncurses', 'zeromq', 'zstd']
|
||||
pkgs = [importlib.import_module(name) for name in pkg_names]
|
||||
acados = pkgs[pkg_names.index('acados')]
|
||||
ffmpeg = pkgs[pkg_names.index('ffmpeg')]
|
||||
# Shared package ships .so/.dylib; older device venvs still have static .a only.
|
||||
# Keep static link deps (x264/z/va/drm) when the installed package is static so
|
||||
# TICI CI works without upgrading the device venv yet.
|
||||
# TODO: drop the static fallback once device venvs have comma-deps-ffmpeg>=7.1.0.post94
|
||||
_ffmpeg_lib_names = os.listdir(ffmpeg.LIB_DIR) if os.path.isdir(ffmpeg.LIB_DIR) else []
|
||||
ffmpeg_shared = any(
|
||||
n.startswith('libavcodec.so') or (n.startswith('libavcodec') and n.endswith('.dylib'))
|
||||
for n in _ffmpeg_lib_names
|
||||
)
|
||||
ffmpeg_libs = ['avformat', 'avcodec', 'swresample', 'avutil']
|
||||
if not ffmpeg_shared:
|
||||
ffmpeg_libs += ['x264', 'z']
|
||||
if arch != "Darwin":
|
||||
ffmpeg_libs += ['va', 'va-drm', 'drm']
|
||||
acados_include_dirs = [
|
||||
acados.INCLUDE_DIR,
|
||||
os.path.join(acados.INCLUDE_DIR, "blasfeo", "include"),
|
||||
@@ -126,7 +141,7 @@ env = Environment(
|
||||
"#rednose/helpers",
|
||||
[x.LIB_DIR for x in pkgs],
|
||||
],
|
||||
RPATH=[],
|
||||
RPATH=[ffmpeg.LIB_DIR] if ffmpeg_shared else [],
|
||||
CYTHONCFILESUFFIX=".cpp",
|
||||
COMPILATIONDB_USE_ABSPATH=True,
|
||||
REDNOSE_ROOT="#",
|
||||
@@ -192,7 +207,7 @@ else:
|
||||
np_version = SCons.Script.Value(np.__version__)
|
||||
Export('envCython', 'np_version')
|
||||
|
||||
Export('env', 'arch', 'acados')
|
||||
Export('env', 'arch', 'acados', 'ffmpeg_libs')
|
||||
|
||||
# Setup cache dir
|
||||
cache_dir = '/data/scons_cache' if arch == "larch64" else '/tmp/scons_cache'
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
Import('env', 'arch', 'messaging', 'common', 'visionipc')
|
||||
Import('env', 'arch', 'messaging', 'common', 'visionipc', 'ffmpeg_libs')
|
||||
|
||||
libs = [common, messaging, visionipc,
|
||||
'avformat', 'avcodec', 'swresample', 'avutil', 'x264',
|
||||
'pthread', 'z', 'm', 'zstd']
|
||||
libs = [common, messaging, visionipc] + ffmpeg_libs + ['pthread', 'm', 'zstd']
|
||||
frameworks = []
|
||||
|
||||
src = ['logger.cc', 'zstd_writer.cc', 'video_writer.cc', 'encoder/encoder.cc', 'encoder/jpeg_encoder.cc']
|
||||
@@ -14,9 +12,6 @@ else:
|
||||
if arch == "Darwin":
|
||||
frameworks += ['VideoToolbox', 'CoreMedia', 'CoreFoundation', 'CoreVideo']
|
||||
|
||||
if arch != "Darwin":
|
||||
libs += ['va', 'va-drm', 'drm']
|
||||
|
||||
logger_lib = env.Library('logger', src)
|
||||
libs.insert(0, logger_lib)
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import shutil
|
||||
import bootstrap_icons
|
||||
import libusb
|
||||
|
||||
Import('env', 'arch', 'common', 'messaging', 'visionipc', 'cereal', 'replay_lib')
|
||||
Import('env', 'arch', 'common', 'messaging', 'visionipc', 'cereal', 'replay_lib', 'ffmpeg_libs')
|
||||
|
||||
# Detect Qt - skip build if not available
|
||||
if arch == "Darwin":
|
||||
@@ -75,9 +75,7 @@ cabana_env = qt_env.Clone()
|
||||
cabana_env['CPPPATH'] += [libusb.INCLUDE_DIR]
|
||||
cabana_env['LIBPATH'] += [libusb.LIB_DIR]
|
||||
|
||||
cabana_libs = [cereal, messaging, visionipc, replay_lib, 'avformat', 'avcodec', 'swresample', 'avutil', 'x264', 'z', 'bz2', 'zstd', 'yuv', 'usb-1.0'] + base_libs
|
||||
if arch != "Darwin":
|
||||
cabana_libs += ['va', 'va-drm', 'drm']
|
||||
cabana_libs = [cereal, messaging, visionipc, replay_lib] + ffmpeg_libs + ['bz2', 'zstd', 'yuv', 'usb-1.0'] + base_libs
|
||||
opendbc_path = '-DOPENDBC_FILE_PATH=\'"%s"\'' % (cabana_env.Dir("../../../opendbc/dbc").abspath)
|
||||
cabana_env['CXXFLAGS'] += [opendbc_path]
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ from opendbc.car.fingerprints import MIGRATION
|
||||
from opendbc.car.values import PLATFORMS
|
||||
from openpilot.common.basedir import BASEDIR
|
||||
|
||||
Import('env', 'arch', 'common', 'messaging', 'visionipc', 'cereal', 'replay_lib')
|
||||
Import('env', 'arch', 'common', 'messaging', 'visionipc', 'cereal', 'replay_lib', 'ffmpeg_libs')
|
||||
|
||||
jot_env = env.Clone()
|
||||
jot_env["LIBPATH"] += [imgui.MESA_DIR, libusb.LIB_DIR]
|
||||
@@ -101,12 +101,12 @@ event_extractors = jot_env.Command("generated_event_extractors.h", [
|
||||
generate_event_extractors,
|
||||
)
|
||||
|
||||
libs = [replay_lib, common, messaging, visionipc, cereal, File(f"{imgui.LIB_DIR}/libimgui.a"), File(f"{imgui.LIB_DIR}/libglfw3.a"),
|
||||
"avformat", "avcodec", "avutil", "x264", "yuv", "z", "bz2", "zstd", "m", "pthread", "usb-1.0"]
|
||||
libs = [replay_lib, common, messaging, visionipc, cereal, File(f"{imgui.LIB_DIR}/libimgui.a"), File(f"{imgui.LIB_DIR}/libglfw3.a")] + \
|
||||
ffmpeg_libs + ["yuv", "bz2", "zstd", "m", "pthread", "usb-1.0"]
|
||||
if arch == "Darwin":
|
||||
jot_env["FRAMEWORKS"] = ["OpenGL", "Cocoa", "IOKit", "CoreFoundation", "CoreVideo", "CoreMedia", "VideoToolbox"]
|
||||
else:
|
||||
libs += ["GL", "dl", "va", "va-drm", "drm"]
|
||||
libs += ["GL", "dl"]
|
||||
|
||||
program = jot_env.Program("jotpluggler", jot_env.Glob("*.cc"), LIBS=libs)
|
||||
jot_env.Depends(program, generated_dbc_stamp)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Import('env', 'arch', 'common', 'messaging', 'visionipc', 'cereal')
|
||||
Import('env', 'arch', 'common', 'messaging', 'visionipc', 'cereal', 'ffmpeg_libs')
|
||||
|
||||
replay_env = env.Clone()
|
||||
replay_env['CCFLAGS'] += ['-Wno-deprecated-declarations']
|
||||
@@ -12,9 +12,7 @@ if arch != "Darwin":
|
||||
replay_lib_src.append("qcom_decoder.cc")
|
||||
replay_lib = replay_env.Library("replay", replay_lib_src, LIBS=base_libs, FRAMEWORKS=base_frameworks)
|
||||
Export('replay_lib')
|
||||
replay_libs = [replay_lib, 'avformat', 'avcodec', 'swresample', 'avutil', 'x264', 'z', 'bz2', 'zstd', 'yuv', 'ncurses'] + base_libs
|
||||
if arch != "Darwin":
|
||||
replay_libs += ['va', 'va-drm', 'drm']
|
||||
replay_libs = [replay_lib] + ffmpeg_libs + ['bz2', 'zstd', 'yuv', 'ncurses'] + base_libs
|
||||
replay_env.Program("replay", ["main.cc"], LIBS=replay_libs, FRAMEWORKS=base_frameworks)
|
||||
|
||||
if GetOption('extras'):
|
||||
|
||||
@@ -274,12 +274,12 @@ wheels = [
|
||||
|
||||
[[package]]
|
||||
name = "comma-deps-ffmpeg"
|
||||
version = "7.1.0.post93"
|
||||
version = "7.1.0.post94"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/65/02/7e21345a4b6493b94dcacdf14024d24fc143469b3b596dbe0a0433b9055d/comma_deps_ffmpeg-7.1.0.post93-py3-none-macosx_11_0_arm64.whl", hash = "sha256:129f05e177ae8abfb758ff6b56efdb8caa4c10c435f73c774dd4470349c05502", size = 10673113, upload-time = "2026-07-08T19:31:20.253Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/18/ac/579bbb4d8724406738b0eef41f4e49bb0dff17eb4b9b5397296f5d65c84e/comma_deps_ffmpeg-7.1.0.post93-py3-none-manylinux_2_28_aarch64.whl", hash = "sha256:185bab6cd683448a1fba9338b11da7e7454b798e27a52d789ea02dd827e944fe", size = 11748947, upload-time = "2026-07-08T19:31:24.618Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/6e/bc/feb5dc8e2e75ecf147281801b1a2a864996c1e1a3be934aeb5cebdcf7323/comma_deps_ffmpeg-7.1.0.post93-py3-none-manylinux_2_28_x86_64.whl", hash = "sha256:161e3bcbee02b0d5d2b7bcff2c249904fe7b9c9b3f7820b954a4fb2d24c0fe21", size = 12433434, upload-time = "2026-07-08T19:31:28.965Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/7d/5c/47e10049fd96b581e8ddc9fba31c3397562732fcc99db6c062690e862300/comma_deps_ffmpeg-7.1.0.post94-py3-none-macosx_11_0_arm64.whl", hash = "sha256:2e87b4dd0fb0fc25d6992167ee266b5c9e92305aefa3d343ddd22a17219363b8", size = 7329953, upload-time = "2026-07-09T03:07:11.516Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a7/d5/c4edfbbe488983ff45fb6cacab78342fc56cc0f28010a946e8697613ffe2/comma_deps_ffmpeg-7.1.0.post94-py3-none-manylinux_2_28_aarch64.whl", hash = "sha256:7ea34368c5b564cecab0fd77d6423bc15d8f100051648f64ad79a3499f43dafb", size = 4441314, upload-time = "2026-07-09T03:07:15.679Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/80/8f/76a876a26572c52d52dbcf8ed39227f5023d343201a32af4b992c4b9f13e/comma_deps_ffmpeg-7.1.0.post94-py3-none-manylinux_2_28_x86_64.whl", hash = "sha256:5b2d6cfbba59ecd673dd0c8bd8eb5a5b3472bdfa025e1063c011e6234877fe84", size = 4685134, upload-time = "2026-07-09T03:07:19.596Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
Reference in New Issue
Block a user