Support Filtergraph output format #31
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new image-based subtitle writer for FFmpeg filtergraphs, improves the handling of image-based subtitle rendering, and refactors palette and color management for better clarity and extensibility. It also adds comprehensive tests for the new filtergraph writer. The most significant changes are grouped below.
New FFmpeg Filtergraph Writer:
FiltergraphWriterclass inpycaption/filtergraph.pythat generates PNG subtitle images and an FFmpeg filtergraph for overlaying subtitles as transparent video. This writer outputs a ZIP file containing the images and the filtergraph script, supporting custom output directories and video resolutions.pycaption/__init__.pyto exposeFiltergraphWriterin the public API. [1] [2]Image-based Subtitle Rendering Refactor:
SubtitleImageBasedWriterinpycaption/subtitler_image_based.pyto use RGBA images with transparent backgrounds by default, and moved palette/color management to subclasses. Now, each subclass is responsible for converting RGBA images to their required palette and format. [1] [2]fontColorandborderColorattributes for RGBA rendering, replacing the previous palette-based approach.Palette and Format Handling for Subclasses:
ScenaristDVDWriterandTTMLBackgroundWriterto define their own palettes and conversion logic, ensuring correct color quantization and transparency handling for their respective formats. [1] [2] [3]Testing:
tests/test_filtergraph.pywith extensive tests for theFiltergraphWriter, covering ZIP output, filtergraph structure, custom directories, overlay chaining, duration calculation, and resolution handling.Other Minor Updates:
PIL.Imageinpycaption/scenarist.pyand minor test import tweaks. [1] [2]