[IMPROVEMENT] feat(mp4): add FFmpeg/libavformat backend for MP4 demuxing#2191
[IMPROVEMENT] feat(mp4): add FFmpeg/libavformat backend for MP4 demuxing#2191gaurav02081 wants to merge 3 commits intoCCExtractor:masterfrom
Conversation
6c31e1c to
c83ebd9
Compare
Add a new CI job (cmake_ffmpeg_mp4) that builds CCExtractor with the optional FFmpeg-based MP4 parser enabled via -DUSE_FFMPEG_MP4=ON. The workflow now verifies two builds: - Default build using GPAC - FFmpeg MP4 build using a separate build directory This ensures the FFmpeg backend compiles successfully alongside the default GPAC implementation.
Replace the custom GPAC-based MP4 parser with an FFmpeg/libavformat implementation for subtitle extraction. This provides broader codec support, better container compatibility, and leverages FFmpeg's mature demuxing infrastructure for handling MP4/MOV files. - Add mp4_ffmpeg.c with full libavformat-based demuxing pipeline - Update CMakeLists to detect and link FFmpeg libraries (libavformat, libavcodec, libavutil) with fallback to GPAC when unavailable - Integrate FFmpeg pathway into ccextractor main entry point - Preserve existing GPAC codepath as fallback
c83ebd9 to
1d96d2c
Compare
1. src/lib_ccx/CMakeLists.txt — Added pkg_check_modules(AVCODEC REQUIRED libavcodec) and appended its include dirs and libraries to EXTRA_INCLUDES/EXTRA_LIBS in the USE_FFMPEG_MP4 block. 2. src/lib_ccx/mp4_ffmpeg.c — Updated the header comment to accurately reflect the libavcodec dependency.
|
Update: Added a new CI job to build CCExtractor with the optional FFmpeg MP4 backend. The workflow now performs two builds: Default build using the GPAC implementation FFmpeg build using -DUSE_FFMPEG_MP4=ON Both builds run --version to verify the binaries execute correctly, and separate build directories are used to avoid CMake cache conflicts. |
CCExtractor CI platform finished running the test files on linux. Below is a summary of the test results, when compared to test for commit 90128d8...:
Your PR breaks these cases:
NOTE: The following tests have been failing on the master branch as well as the PR:
Congratulations: Merging this PR would fix the following tests:
It seems that not all tests were passed completely. This is an indication that the output of some files is not as expected (but might be according to you). Check the result page for more info. |
CCExtractor CI platform finished running the test files on windows. Below is a summary of the test results, when compared to test for commit e4bcade...:
NOTE: The following tests have been failing on the master branch as well as the PR:
Congratulations: Merging this PR would fix the following tests:
This PR does not introduce any new test failures. However, some tests are failing on both master and this PR (see above). Check the result page for more info. |
[IMPROVEMENT] feat(mp4): add FFmpeg/libavformat backend for MP4 demuxing
In raising this pull request, I confirm the following (please check boxes):
My familiarity with the project is as follows (check one):
Add optional FFmpeg-based MP4 parser as an alternative to GPAC
This PR introduces an alternative MP4 parsing backend using FFmpeg's libavformat, while keeping the existing GPAC-based implementation unchanged and as the default.
Motivation
In a previous discussion (Gsoc meeting 2 MARCH) we talked about updating the GPAC dependency used for MP4 processing in CCExtractor. One suggestion was to explore whether there is a Debian-friendly alternative rather than only focusing on upgrading GPAC.
FFmpeg is already used in other parts of the codebase (for example in the demuxing/decoding integration and in the HardsubX module), so extending its use for MP4 parsing seemed like a reasonable option to explore.
Implementation
A new implementation (
mp4_ffmpeg.c) was added which uses FFmpeg's libavformat to open and parse MP4 containers.The general workflow is:
avformat_open_input()avformat_find_stream_info()av_read_frame()Video packets (H.264 / HEVC) are passed to the existing
do_NAL()processing logic, while caption tracks (CEA-608 / CEA-708) and subtitle tracks (tx3g) continue to use the existing CCExtractor parsing functions.One difference from the GPAC implementation is that FFmpeg reads packets sequentially across all streams, whereas the GPAC implementation reads samples per track. The downstream caption extraction pipeline remains unchanged.
For H.264 / HEVC streams, codec configuration data is obtained from the stream extradata (
avcC/hvcC) in order to determine the NAL unit length prefix size and extract SPS/PPS before processing packets.Build configuration
This backend is optional and controlled through a compile-time flag:
mp4.c)mp4_ffmpeg.c)The runtime behavior of CCExtractor remains unchanged — the difference only affects how the MP4 container is parsed internally.
Summary
This PR:
This provides a potential alternative MP4 backend using a widely available multimedia framework while preserving the existing behavior.