Expand description
Subtitle and closed caption rendering for OxiMedia.
This crate provides comprehensive subtitle rendering support including:
- Subtitle Formats: SubRip (SRT), WebVTT, SSA/ASS, CEA-608/708
- Text Rendering: Font loading, glyph caching, Unicode support, bidirectional text
- Styling: Font properties, colors, outlines, shadows, positioning
- Advanced Features: Burn-in, animations, collision detection, karaoke effects
§Supported Formats
| Format | Description | Features |
|---|---|---|
| SRT | SubRip | Basic text, simple HTML tags |
| WebVTT | Web Video Text Tracks | Positioning, cue settings |
| SSA/ASS | Advanced SubStation Alpha | Full styling, animations, karaoke |
| CEA-608/708 | Closed Captions | Real-time captions, pop-on, roll-up |
§Example
ⓘ
use oximedia_subtitle::{SubtitleRenderer, SubtitleStyle, Font};
use oximedia_codec::VideoFrame;
// Load font
let font_data = std::fs::read("font.ttf")?;
let font = Font::from_bytes(font_data)?;
// Create renderer with custom style
let style = SubtitleStyle::default()
.with_font_size(48.0)
.with_color(255, 255, 255, 255);
let renderer = SubtitleRenderer::new(font, style);
// Parse subtitles
let subtitle_data = std::fs::read("movie.srt")?;
let subtitles = parser::srt::parse(&subtitle_data)?;
// Render onto frame
let mut frame = VideoFrame::new(...);
renderer.render_subtitle(&subtitles[0], &mut frame, timestamp)?;Re-exports§
pub use cea708::CaptionWindow;pub use cea708::Dtvcc708Command;pub use cea708::Dtvcc708Decoder;pub use cea708::Dtvcc708Packet;pub use error::SubtitleError;pub use error::SubtitleResult;pub use font::Font;pub use font::GlyphCache;pub use overlay::overlay_subtitle;pub use renderer::DirtyRect;pub use renderer::IncrementalSubtitleRenderer;pub use renderer::SubtitleRenderer;pub use style::Alignment;pub use style::Animation;pub use style::Color;pub use style::OutlineStyle;pub use style::Position;pub use style::ShadowStyle;pub use style::SubtitleStyle;pub use text::BidiLevel;pub use text::TextLayout;pub use text::TextLayoutEngine;pub use ttml_v2::SubtitleEntry;pub use ttml_v2::TtmlParser;pub use ttml_v2::TtmlRegion;pub use ttml_v2::TtmlSpan;pub use ttml_v2::TtmlStyle;
Modules§
- accessibility
- Subtitle accessibility features.
- ass_
override - Full ASS/SSA override tag parser.
- burn_in
- Subtitle burn-in rendering configuration and job management.
- cea
- CEA-608 and CEA-708 closed caption encoding and embedding.
- cea708
- CEA-708 DTVCC (Digital Television Closed Caption) decoder.
- convert
- Subtitle format conversion to CEA-608/708.
- cue_
parser - Cue-based subtitle parser for WebVTT and SRT cue timestamp formats.
- cue_
point - Cue points for marking significant moments in a subtitle track.
- cue_
positioning - Advanced subtitle cue positioning and collision avoidance.
- cue_
timing - Cue timing calculations and adjustments for subtitles.
- eia608_
realtime - EIA-608 (CEA-608) realtime caption decoder for live streams.
- error
- Error types for subtitle processing.
- fallback_
fonts - Fallback font chain for missing glyphs.
- font
- Font loading and glyph management with fallback font chain support.
- forced_
subtitle - Forced subtitle detection and flagging.
- format_
convert - Subtitle format conversion utilities.
- format_
converter - Multi-format subtitle converter with rich styling and document model.
- glyph_
atlas - Glyph atlas caching for batch subtitle rendering.
- karaoke_
engine - Full ASS karaoke timing engine with syllable-level highlighting.
- line_
break - Automatic line-breaking for subtitle text.
- live_
caption - Real-time caption display with roll-up and paint-on modes.
- overlap_
detect - Subtitle overlap detection for OxiMedia.
- overlay
- Video frame overlay for subtitle rendering.
- parser
- Subtitle format parsers.
- position
- Subtitle position normalisation.
- position_
calc - Position calculation for subtitle placement on screen.
- reading_
speed - Reading-speed analysis for subtitle tracks.
- renderer
- Main subtitle renderer with incremental (dirty-region) redraw support.
- search
- Full-text search over subtitle cue collections.
- segmentation
- Subtitle line segmentation and block optimization.
- sign_
language - Sign language overlay region management and picture-in-picture positioning.
- soft_
shadow - Soft-shadow rendering for subtitle burn-in.
- spell_
check - Basic spell-checking framework for subtitle text.
- ssa_
style_ cache - Cached ASS/SSA style lookup to avoid re-parsing style definitions per dialogue line.
- style
- Subtitle styling definitions.
- style_
inherit - Subtitle style inheritance resolution.
- sub_
style - Subtitle styling types for the OxiMedia subtitle crate.
- subtitle_
alignment - Automatic subtitle timing alignment between two subtitle tracks.
- subtitle_
chapters - Chapter-based subtitle organisation for DVD/Blu-ray-style chapter navigation.
- subtitle_
diff - Subtitle comparison and diffing.
- subtitle_
export - Subtitle export to multiple text-based formats.
- subtitle_
index - Subtitle index for efficient timestamp-based lookup.
- subtitle_
merge - Multi-track subtitle merging utilities.
- subtitle_
ocr - OCR-like text extraction from bitmap-based subtitle formats.
- subtitle_
sanitize - Subtitle text sanitization and cleanup utilities.
- subtitle_
search - Full-text search across subtitle cues.
- subtitle_
stats - Statistics computation for subtitle tracks.
- subtitle_
style_ ext - Extended subtitle style management for OxiMedia.
- subtitle_
validator - Subtitle validation rules and reporting.
- teletext
- DVB Teletext subtitle extraction per ETS 300 706.
- teletext_
subtitle - Teletext subtitle format support (EBU Teletext / ETS 300 706).
- text
- Text layout and bidirectional text support.
- timing
- Subtitle timing adjustment and synchronization.
- timing_
adjust - Subtitle timing adjustment utilities.
- timing_
adjuster - Subtitle timing adjuster: offset, FPS scaling, and automatic sync detection.
- translation
- Subtitle translation support.
- ttml_v2
- IMSC1/TTML2 enhanced parser.
- wcag_
validator - WCAG 2.1 AA/AAA subtitle contrast checker.
Structs§
- AssParser
- High-level ASS/SSA parser struct.
- SrtParser
- High-level SRT parser struct.
- Subtitle
- A single subtitle cue with timing and content.
- WebVtt
Parser - High-level WebVTT parser struct.