ffmpeg_bridge: new shared library isolating all FFmpeg access behind a pure C API

The library lives outside of app/ and is the only component that includes
FFmpeg headers or links FFmpeg libraries. All objects (frames, packets,
decoder/encoder instances, scalers, resamplers, audio filter graphs) are
identified by opaque handles and never leave the library.

Public surface (include/ffmpeg_bridge/ffmpeg_bridge.h):
- FBFrame/FBPacket: AVFrame/AVPacket wrappers with field accessors
- FBDecoder: demux+decode instance with hwaccel fallback logic
- FBProbe: file probing, per-stream details, subtitle reading
- FBScaler/FBResampler/FBAudioGraph: swscale/swresample/avfilter wrappers
- FBEncoder: full export encoder (video filter graph, audio resampling,
  subtitles) ported from FFmpegEncoder
- FB_* constants mirror AV_* values, verified by static_asserts against
  the real FFmpeg headers inside the library

Two small bugs in the ported encoder were fixed: the resampler is now
properly freed with swr_free() (was re-initialized with swr_init() and
leaked), and codec option dictionaries are freed after avcodec_open2().
This commit is contained in:
2026-07-15 22:07:57 +08:00
parent 0f41620a0b
commit ddb2b30cf4
13 changed files with 3749 additions and 0 deletions
+4
View File
@@ -223,6 +223,10 @@ list(APPEND OLIVE_LIBRARIES
FFMPEG::swresample
)
# FFmpeg isolation: all FFmpeg access is being moved behind this shared
# library's pure C API. Built early so the app can link it.
add_subdirectory(ffmpeg_bridge)
# Detect FFmpeg pixel formats that may not exist in all versions
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_INCLUDES ${FFMPEG_INCLUDE_DIRS})