Archived
server: /v1/videos writes WebM (VP9 and AV1) as well as MP4
A `format` field chooses the container a generated video is written in:
mp4 (the default, H.264 + AAC, unchanged) or webm (VP9 + Opus) or webm-av1
(AV1 + Opus). Old-hardware users -- this box's CPU is Zen 3, AVX2 only --
get the browser-friendly WebM the DaSiWa workflow ships without a fragile
client-side re-encode, and both webm codecs so either a VP9-friendly or an
AV1-parity file is available.
core/mm/mp4.{h,cpp} become core/mm/video_out.{h,cpp}: Mp4Writer generalises
to VideoWriter with a VideoFormat enum, branching the muxer, the video
encoder (libx264/libopenh264 for H.264, libvpx-vp9, libaom-av1/libsvtav1),
the rate-control options and the audio codec. Opus encodes only at 48 kHz,
so a WebM soundtrack is resampled to 48 kHz with libswresample (the model's
is 32 kHz); the encoder is fed packed FLT at its fixed frame size, AAC keeps
the planar FLTP path at its own rate. faststart and the shift_data reader are
MP4-only; WebM writes forward. Each codec/muxer is runtime-discovered and a
missing one fails open() with a message naming it, so the mp4 default always
works.
videos.cpp parses `format` (mp4|webm|webm-av1, mp4 default, refusing any
other name), threads it to the job and the writer, serves the file under the
matching content-type and a .webm/.mp4 Content-Disposition, echoes `format`
in the object, and advertises video_formats in the capability block.
The Docker FFmpeg build gains libvpx/libaom/libopus and the webm/matroska
muxers (all BSD, so the LGPL posture holds) and their runtime libraries.
Verified host-side: the videos_test webm case writes a real VP9+Opus file
(completed on libvpx-vp9, EBML magic + content-type + disposition checked);
a standalone writer harness produced mp4/webm/webm-av1 at 512x512 with stereo
32 kHz audio -- ffprobe reports h264+aac@32k, vp9+opus@48k and av1+opus@48k
respectively, and all three decode in software on this AVX2-only box.
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
0fe7771210
commit
ad7e0f8b89
6 files changed
+331
-128
No files matched your search
+13
-9
@@ -51,17 +51,18 @@ ARG JOBS=
|
||||
RUN apt-get update \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
||||
build-essential nasm pkg-config ca-certificates curl xz-utils zlib1g-dev libdav1d-dev \
|
||||
libwebp-dev libopenh264-dev \
|
||||
libwebp-dev libopenh264-dev libvpx-dev libaom-dev libopus-dev \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
WORKDIR /tmp
|
||||
# Demuxers: media.cpp's kFormats whitelist. Decoders: what those containers carry -- still
|
||||
# images, H.264 and HEVC (MP4, MOV, HEIF), VP8 and VP9 (WebM, WebP), AV1 through dav1d (WebM, MP4,
|
||||
# AVIF), MPEG-1/2/4, Theora and the FLV/H.263 family. JPEG XL is recognised and refused by name
|
||||
# (its only decoder is libjxl's). Encoders: the image output formats of media.cpp encode_image
|
||||
# (png, jpeg as mjpeg, webp through libwebp), and a generated video's MP4 (core/mm/mp4.cpp): H.264
|
||||
# through libopenh264 (BSD-licensed, so the build stays LGPL) and FFmpeg's own AAC, in the mp4
|
||||
# muxer. No protocols: media.cpp and mp4.cpp read and write memory through their own I/O
|
||||
# contexts.
|
||||
# (png, jpeg as mjpeg, webp through libwebp), and a generated video (core/mm/video_out.cpp): H.264
|
||||
# through libopenh264 and FFmpeg's own AAC in the mp4 muxer, and for WebM VP9 through libvpx and
|
||||
# AV1 through libaom with Opus through libopus in the webm muxer -- libvpx, libaom and libopus are
|
||||
# BSD, so, like libopenh264, the build stays LGPL. No protocols: media.cpp and video_out.cpp read
|
||||
# and write memory through their own I/O contexts.
|
||||
RUN echo 1000 > /proc/self/oom_score_adj 2>/dev/null || true; \
|
||||
curl -fsSL "https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.xz" -o ffmpeg.tar.xz \
|
||||
&& echo "${FFMPEG_SHA256} ffmpeg.tar.xz" | sha256sum -c - \
|
||||
@@ -69,10 +70,11 @@ RUN echo 1000 > /proc/self/oom_score_adj 2>/dev/null || true; \
|
||||
&& ./configure --prefix=/opt/ffmpeg --enable-shared --disable-static --disable-debug \
|
||||
--disable-programs --disable-doc --disable-network --disable-autodetect --disable-everything \
|
||||
--disable-avdevice --disable-avfilter --enable-swresample \
|
||||
--enable-zlib --enable-libdav1d --enable-libwebp \
|
||||
--enable-zlib --enable-libdav1d --enable-libwebp --enable-libvpx --enable-libaom --enable-libopus \
|
||||
--enable-demuxer=mov,matroska,avi,mpegts,flv,ogg,gif,apng,image2pipe,image_png_pipe,image_jpeg_pipe,image_jpegls_pipe,image_jpegxl_pipe,image_webp_pipe,image_bmp_pipe,image_tiff_pipe,image_qoi_pipe,image_pgm_pipe,image_ppm_pipe,image_pbm_pipe,image_pam_pipe,image_gif_pipe,wav,w64,mp3,flac,aac,aiff \
|
||||
--enable-decoder=h264,hevc,vp8,vp9,libdav1d,mpeg4,mpeg1video,mpeg2video,mjpeg,jpegls,png,apng,gif,webp,bmp,tiff,qoi,pgm,ppm,pbm,pam,pgmyuv,theora,vp3,flv,h263,pcm_u8,pcm_s16le,pcm_s16be,pcm_s24le,pcm_s24be,pcm_s32le,pcm_s32be,pcm_f32le,pcm_f32be,pcm_f64le,pcm_alaw,pcm_mulaw,mp3float,mp2float,flac,vorbis,opus,aac \
|
||||
--enable-encoder=png,mjpeg,libwebp,libopenh264,aac --enable-muxer=mp4 --enable-libopenh264 \
|
||||
--enable-encoder=png,mjpeg,libwebp,libopenh264,aac,libvpx-vp9,libaom-av1,libopus \
|
||||
--enable-muxer=mp4,webm,matroska --enable-libopenh264 \
|
||||
--enable-parser=h264,hevc,vp8,vp9,av1,mpeg4video,mpegvideo,mjpeg,png,gif,bmp,webp,vp3,qoi,pnm,h263,jpegxl,mpegaudio,flac,aac,vorbis,opus \
|
||||
&& make -j"${JOBS:-$(nproc)}" \
|
||||
&& make install \
|
||||
@@ -139,10 +141,12 @@ ARG JOBS=
|
||||
# g++-14 rather than the default 13: hipcc compiles device-side translation units against its
|
||||
# libstdc++, which is also the runtime image's. gawk: tools/ops_doc_check.sh uses gensub, which
|
||||
# mawk lacks. libdav1d7, libwebp7 and libopenh264-7 are the runtime libraries of the ffmpeg stage's
|
||||
# AV1 decoder, WebP encoder and H.264 encoder; busybox-static goes into the runtime image.
|
||||
# AV1 decoder, WebP encoder and H.264 encoder; libvpx9, libaom3 and libopus0 of its VP9, AV1 and
|
||||
# Opus encoders (core/mm/video_out.cpp's WebM output); busybox-static goes into the runtime image.
|
||||
RUN apt-get update \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
||||
cmake ninja-build pkg-config g++-14 gawk libdav1d7 libwebp7 libopenh264-7 busybox-static \
|
||||
cmake ninja-build pkg-config g++-14 gawk libdav1d7 libwebp7 libopenh264-7 \
|
||||
libvpx9 libaom3 libopus0 busybox-static \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY --from=ffmpeg /opt/ffmpeg /opt/ffmpeg
|
||||
|
||||
Reference in new issue
Block a user