minimal ffmpeg build (#36138)

* min ffmpeg

* remove avfilter

* x264

* merge x264

* simpler

* pin x264

* mac

* rm that

* lil more

* move includes to lfs

* try this

* cleanup

* larch

---------

Co-authored-by: Comma Device <device@comma.ai>
This commit is contained in:
Adeeb Shihadeh
2025-09-12 18:59:15 -07:00
committed by GitHub
parent cbea5f198f
commit 347b23055d
147 changed files with 517 additions and 13 deletions

1
.gitattributes vendored
View File

@@ -15,6 +15,7 @@ third_party/**/*.a filter=lfs diff=lfs merge=lfs -text
third_party/**/*.so filter=lfs diff=lfs merge=lfs -text
third_party/**/*.so.* filter=lfs diff=lfs merge=lfs -text
third_party/**/*.dylib filter=lfs diff=lfs merge=lfs -text
third_party/ffmpeg/include/**/*.h filter=lfs diff=lfs merge=lfs -text
third_party/acados/*/t_renderer filter=lfs diff=lfs merge=lfs -text
third_party/qt5/larch64/bin/lrelease filter=lfs diff=lfs merge=lfs -text
third_party/qt5/larch64/bin/lupdate filter=lfs diff=lfs merge=lfs -text

View File

@@ -91,6 +91,7 @@ if arch == "larch64":
]
libpath = [
f"#third_party/ffmpeg/{arch}/lib",
"/usr/local/lib",
"/system/vendor/lib64",
f"#third_party/acados/{arch}/lib",
@@ -114,6 +115,7 @@ else:
libpath = [
f"#third_party/libyuv/{arch}/lib",
f"#third_party/acados/{arch}/lib",
f"#third_party/ffmpeg/{arch}/lib",
f"{brew_prefix}/lib",
f"{brew_prefix}/opt/openssl@3.0/lib",
"/System/Library/Frameworks/OpenGL.framework/Libraries",
@@ -130,6 +132,7 @@ else:
libpath = [
f"#third_party/acados/{arch}/lib",
f"#third_party/libyuv/{arch}/lib",
f"#third_party/ffmpeg/{arch}/lib",
"/usr/lib",
"/usr/local/lib",
]
@@ -177,6 +180,7 @@ env = Environment(
"#third_party/libyuv/include",
"#third_party/json11",
"#third_party/linux/include",
"#third_party/ffmpeg/include",
"#third_party",
"#msgq",
],

View File

@@ -1,8 +1,8 @@
Import('env', 'arch', 'messaging', 'common', 'visionipc')
libs = [common, messaging, visionipc,
'avformat', 'avcodec', 'avutil',
'yuv', 'OpenCL', 'pthread', 'zstd']
'yuv', 'OpenCL', 'pthread', 'zstd',
'avformat', 'avcodec', 'avutil', 'x264']
src = ['logger.cc', 'zstd_writer.cc', 'video_writer.cc', 'encoder/encoder.cc', 'encoder/v4l_encoder.cc', 'encoder/jpeg_encoder.cc']
if arch != "larch64":

View File

@@ -316,8 +316,18 @@ class TestLoggerd:
self._publish_camera_and_audio_messages()
qcamera_ts_path = os.path.join(self._get_latest_log_dir(), 'qcamera.ts')
ffprobe_cmd = f"ffprobe -i {qcamera_ts_path} -show_streams -select_streams a -loglevel error"
has_audio_stream = subprocess.run(ffprobe_cmd, shell=True, capture_output=True).stdout.strip() != b''
# simplest heuristic: look for AAC ADTS syncwords in the TS file
def ts_has_audio_stream(ts_path: str) -> bool:
try:
with open(ts_path, 'rb') as f:
data = f.read()
# ADTS headers typically start with 0xFFF1 or 0xFFF9
return (b"\xFF\xF1" in data) or (b"\xFF\xF9" in data)
except Exception:
return False
has_audio_stream = ts_has_audio_stream(qcamera_ts_path)
assert has_audio_stream == record_audio
raw_audio_in_rlog = any(m.which() == 'rawAudioData' for m in LogReader(os.path.join(self._get_latest_log_dir(), 'rlog.zst')))

View File

@@ -1 +1,3 @@
*.pyc
src/
build/

BIN
third_party/ffmpeg/Darwin/lib/libavcodec.a LFS vendored Normal file

Binary file not shown.

BIN
third_party/ffmpeg/Darwin/lib/libavformat.a LFS vendored Normal file

Binary file not shown.

BIN
third_party/ffmpeg/Darwin/lib/libavutil.a LFS vendored Normal file

Binary file not shown.

BIN
third_party/ffmpeg/Darwin/lib/libx264.a LFS vendored Normal file

Binary file not shown.

83
third_party/ffmpeg/build.sh vendored Executable file
View File

@@ -0,0 +1,83 @@
#!/usr/bin/env bash
set -e
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
cd $DIR
# Detect arch
ARCHNAME="x86_64"
if [ -f /TICI ]; then
ARCHNAME="larch64"
fi
if [[ "$OSTYPE" == "darwin"* ]]; then
ARCHNAME="Darwin"
fi
VERSION="6.1.1" # LTS
PREFIX="$DIR/$ARCHNAME"
BUILD_DIR="$DIR/build/"
mkdir -p "$BUILD_DIR"
rm -rf include/ && mkdir -p include/
rm -rf "$PREFIX" && mkdir -p "$PREFIX"
# *** build x264 ***
if [[ ! -d "$DIR/src/x264/" ]]; then
# TODO: pin to a commit
git clone --depth=1 --branch "stable" https://code.videolan.org/videolan/x264.git "$DIR/src/x264/"
fi
cd $DIR/src/x264
git fetch origin b35605ace3ddf7c1a5d67a2eb553f034aef41d55
git checkout -f FETCH_HEAD
./configure --prefix="$PREFIX" --enable-static --disable-opencl --enable-pic --disable-cli
make -j8
make install
cp -a "$PREFIX/include/." "$DIR/include/"
# *** build ffmpeg ***
mkdir -p "$DIR/src"
if [[ ! -d "$DIR/src/ffmpeg-$VERSION" ]]; then
echo "Downloading FFmpeg $VERSION ..."
curl -L "https://ffmpeg.org/releases/ffmpeg-${VERSION}.tar.xz" -o "$DIR/src/ffmpeg-${VERSION}.tar.xz"
tar -C "$DIR/src" -xf "$DIR/src/ffmpeg-${VERSION}.tar.xz"
fi
cd $BUILD_DIR
export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:${PKG_CONFIG_PATH:-}"
export EXTRA_CFLAGS="-I$PREFIX/include ${EXTRA_CFLAGS:-}"
export EXTRA_LDFLAGS="-L$PREFIX/lib ${EXTRA_LDFLAGS:-}"
# Configure minimal static FFmpeg for desktop Linux tools
"$DIR/src/ffmpeg-$VERSION/configure" \
--prefix="$PREFIX" \
--datadir="$PREFIX" \
--docdir="$PREFIX" \
--mandir="$PREFIX" \
--enable-static --disable-shared \
--disable-programs --disable-doc --disable-debug \
--disable-network \
--disable-avdevice --disable-swscale --disable-swresample --disable-postproc --disable-avfilter \
--disable-autodetect --disable-iconv \
--enable-avcodec --enable-avformat --enable-avutil \
--enable-protocol=file \
--pkg-config-flags=--static \
--enable-gpl --enable-libx264 \
--disable-decoders --enable-decoder=h264,hevc,aac \
--disable-encoders --enable-encoder=libx264,ffvhuff,aac \
--disable-demuxers --enable-demuxer=mpegts,hevc,h264,matroska,mov \
--disable-muxers --enable-muxer=matroska,mpegts \
--disable-parsers --enable-parser=h264,hevc,aac,vorbis \
--disable-bsfs \
--enable-small \
--extra-cflags="${EXTRA_CFLAGS:-}" \
--extra-ldflags="${EXTRA_LDFLAGS:-}"
make -j$(nproc)
make install
cp -a "$PREFIX/include/." "$DIR/include/"
# *** cleanup ***
cd $PREFIX
rm -rf share/ doc/ man/ examples/ examples/ include/ lib/pkgconfig/
rm -f lib/libavfilter* "$DIR/include/libavfilter*"

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
third_party/ffmpeg/include/libavcodec/avdct.h LFS vendored Normal file

Binary file not shown.

BIN
third_party/ffmpeg/include/libavcodec/avfft.h LFS vendored Normal file

Binary file not shown.

BIN
third_party/ffmpeg/include/libavcodec/bsf.h LFS vendored Normal file

Binary file not shown.

BIN
third_party/ffmpeg/include/libavcodec/codec.h LFS vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
third_party/ffmpeg/include/libavcodec/defs.h LFS vendored Normal file

Binary file not shown.

BIN
third_party/ffmpeg/include/libavcodec/dirac.h LFS vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
third_party/ffmpeg/include/libavcodec/dxva2.h LFS vendored Normal file

Binary file not shown.

BIN
third_party/ffmpeg/include/libavcodec/jni.h LFS vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
third_party/ffmpeg/include/libavcodec/packet.h LFS vendored Normal file

Binary file not shown.

BIN
third_party/ffmpeg/include/libavcodec/qsv.h LFS vendored Normal file

Binary file not shown.

BIN
third_party/ffmpeg/include/libavcodec/vdpau.h LFS vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
third_party/ffmpeg/include/libavcodec/xvmc.h LFS vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
third_party/ffmpeg/include/libavformat/avio.h LFS vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
third_party/ffmpeg/include/libavutil/adler32.h LFS vendored Normal file

Binary file not shown.

BIN
third_party/ffmpeg/include/libavutil/aes.h LFS vendored Normal file

Binary file not shown.

BIN
third_party/ffmpeg/include/libavutil/aes_ctr.h LFS vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
third_party/ffmpeg/include/libavutil/avutil.h LFS vendored Normal file

Binary file not shown.

BIN
third_party/ffmpeg/include/libavutil/base64.h LFS vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
third_party/ffmpeg/include/libavutil/bprint.h LFS vendored Normal file

Binary file not shown.

BIN
third_party/ffmpeg/include/libavutil/bswap.h LFS vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f16742d574216434580573a2b09f56fc5b66b7dda1960d4f02ba59e3269ba548
size 11998

Binary file not shown.

BIN
third_party/ffmpeg/include/libavutil/cast5.h LFS vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
third_party/ffmpeg/include/libavutil/common.h LFS vendored Normal file

Binary file not shown.

BIN
third_party/ffmpeg/include/libavutil/cpu.h LFS vendored Normal file

Binary file not shown.

BIN
third_party/ffmpeg/include/libavutil/crc.h LFS vendored Normal file

Binary file not shown.

BIN
third_party/ffmpeg/include/libavutil/csp.h LFS vendored Normal file

Binary file not shown.

BIN
third_party/ffmpeg/include/libavutil/des.h LFS vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
third_party/ffmpeg/include/libavutil/dict.h LFS vendored Normal file

Binary file not shown.

BIN
third_party/ffmpeg/include/libavutil/display.h LFS vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
third_party/ffmpeg/include/libavutil/error.h LFS vendored Normal file

Binary file not shown.

BIN
third_party/ffmpeg/include/libavutil/eval.h LFS vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
third_party/ffmpeg/include/libavutil/fifo.h LFS vendored Normal file

Binary file not shown.

BIN
third_party/ffmpeg/include/libavutil/file.h LFS vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
third_party/ffmpeg/include/libavutil/frame.h LFS vendored Normal file

Binary file not shown.

BIN
third_party/ffmpeg/include/libavutil/hash.h LFS vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:457274c2eda1fe91e83ae76b9d1ab8682e6144adfacbd2c86f5fb4a03ede421f
size 14385

Binary file not shown.

BIN
third_party/ffmpeg/include/libavutil/hmac.h LFS vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b598f37f40cf1342f923c0b97784a6f2830b543868eccee046375e096fbd5f24
size 4673

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:74067b6224e8a9d60969f192fdc17f97a12ff073274f5047c380543647026760
size 11412

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
third_party/ffmpeg/include/libavutil/lfg.h LFS vendored Normal file

Binary file not shown.

BIN
third_party/ffmpeg/include/libavutil/log.h LFS vendored Normal file

Binary file not shown.

BIN
third_party/ffmpeg/include/libavutil/lzo.h LFS vendored Normal file

Binary file not shown.

BIN
third_party/ffmpeg/include/libavutil/macros.h LFS vendored Normal file

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More