$ show bramp/ffmpeg-cli-wrapper
This is a Java library that wraps the FFmpeg and FFprobe command-line tools, providing a fluent builder API to programmatically construct and execute media transcoding, probing, and processing commands. It is not a standalone application but a reusable Maven artifact. The core architecture consists of builder classes (FFmpegBuilder, FFmpegOutputBuilder, etc.) that generate ffmpeg command-line arguments, an executor (FFmpegExecutor) that creates runnable jobs (single-pass, two-pass), and progress parsers (TCP, UDP, stream) for real-time encoding feedback. Probing is handled via FFprobe, with JSON output deserialized into typed model classes (FFmpegProbeResult, FFmpegStream, etc.) using custom Gson adapters. The library also includes a partial NUT container demuxer. Its primary data flows involve constructing command arguments, launching external processes, parsing text/JSON output, and delivering typed results and progress events to the caller. External dependencies include a local ffmpeg/ffprobe installation and Java libraries (Guava, Commons IO, Gson, ModelMapper). The codebase is well-tested, actively maintained, and supports features like HLS multi-variant output, stream and metadata specifiers, complex filters, and encoding progress monitoring.
The LLM identified 3 files worth highlighting for reuse:
A self-contained InputStream wrapper that computes a CRC32 checksum as data is read. It implements the standard InputStream interface and exposes a getCRC32() method. This is a well-crafted, isolated utility that can be reused in any Java project requiring stream-level CRC validation without external dependencies (only java.io and java.util.zip). The code is clean, tested, and demonstrates non-obvious stream wrapping patterns.
A utility class with static methods, most notably toTimecode() which converts a duration in seconds (double) to a formatted timecode string (HH:mm:ss.SSS). This method is standalone, deterministic, and reusable across projects that need timecode formatting. The class also contains timestamp parsing and other media-related format helpers, all fully self-contained and independent of the rest of the library.
A custom Gson TypeAdapter for serializing/deserializing Apache Commons Lang3 Fraction objects. It handles both decimal and fraction string representations (e.g., "30000/1001") with proper null safety. The implementation is isolated (only depends on Gson and commons-lang3 Fraction) and demonstrates the correct pattern for bidirectional Gson adapters. It can be extracted and reused in any Gson-based project requiring Fraction serialization.