Skip to main content

Crate oximedia_subtitle

Crate oximedia_subtitle 

Source
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

FormatDescriptionFeatures
SRTSubRipBasic text, simple HTML tags
WebVTTWeb Video Text TracksPositioning, cue settings
SSA/ASSAdvanced SubStation AlphaFull styling, animations, karaoke
CEA-608/708Closed CaptionsReal-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.
WebVttParser
High-level WebVTT parser struct.