I fixed FFmpeg's subtitle conversion (the bug from 2014)
FFmpeg converts everything except subtitles across format boundaries. SRT to Blu-ray PGS? "Subtitle encoding currently only possible from text to text or bitmap to bitmap." Ticket #3819, filed 2014. I built this with Claude Code over a few weeks. Claude wrote most of the encoder, found an integer overflow in the decoder buffer tracking, and ran review from five angles. I read the Panasonic and Sony patents, made the architectural calls, and told it when it was wrong about the spec. We argued about whether DTS computation belongs in the muxer. (It does, and also in fftools. We did both.) Animation is an interesting problem. Advanced SubStation Alpha fades have to survive conversion to Blu-ray's PGS format. The encoder watches pixel changes between frames and classifies them: palette shift or full redraw. Fades become palette-only updates, no bitmap retransmission. Overlapping subtitles with different end times took four rewrites and an event lookahead window. I'd like to maintain this properly and get the patches upstream eventually. If you hit a bug or have a subtitle workflow that doesn't work, open an issue. I'm dead curious what people do with this, but i have some plans for translation related plugins building on the OCR work. Six iterations. 23 patches. libass and Tesseract were already in FFmpeg's filter library. I wired them into the main pipeline the same way sub2video works. Text to bitmap, bitmap to text, 114 OCR languages, RGBA-to-GIF. The development page has the history. Pre-built for 6 platforms, no dependencies: https://connollydavid.github.io/pgs-release/
- AI Agent
- Code Generation
- Integrations
✨ AI Summary
This project addresses a long-standing FFmpeg bug (Ticket #3819, filed 2014) that prevented subtitle conversion between different formats, such as SRT to Blu-ray PGS. It introduces enhanced subtitle encoding capabilities, including support for complex animations and overlapping subtitles, with pre-built binaries available for multiple platforms.
Best For
Video editors, Media archivists, Blu-ray disc creators
Why It Matters
Enables reliable conversion of various subtitle formats within FFmpeg, overcoming a decade-old limitation.
Key Features
- Converts SRT subtitles to Blu-ray PGS format.
- Handles Advanced SubStation Alpha fade effects by detecting palette shifts.
- Optimizes subtitle bitmap updates by tracking pixel changes between frames.
- Manages overlapping subtitles with different end times using an event lookahead window.
Use Cases
- A video editor working on a Blu-ray authoring project needs to convert SRT subtitles to the PGS format for compatibility. This tool allows them to seamlessly integrate their text-based subtitles into the high-definition disc format, preserving visual fidelity.
- A media archivist is digitizing old film collections and needs to convert legacy subtitle files (like Advanced SubStation Alpha) into a modern, widely supported format for inclusion in digital archives. The tool's ability to handle complex animations and fades ensures the subtitles remain accurate and visually appealing.
- A content creator producing multilingual videos wants to add subtitles in various bitmap formats (like PGS) for different regional releases. This solution enables them to convert their original SRT files into these formats, supporting a wide range of OCR languages for potential future translation workflows.