Skip to content

nathanpbutler/libopx

Repository files navigation

libopx

NuGet GitHub Release Build Status License: MIT .NET

A .NET 9 C# library for parsing and extracting data from MXF (Material Exchange Format) files and extracted data streams, VBI (Vertical Blanking Interval), T42 (Teletext packet stream), and MPEG-TS (Transport Stream) files, with SMPTE timecode and Teletext caption support.

Features

  • Multi-format support: MXF, extracted data streams, VBI, T42, and MPEG-TS file parsing
  • Format conversion: Automatic VBI ↔ T42 conversion, plus RCWT and EBU STL output
  • MPEG-TS teletext extraction: Automatic PAT/PMT parsing with DVB teletext support
  • Teletext filtering: Magazine and row-based filtering with Unicode mapping
  • SMPTE timecode: Full timecode calculations with various frame rates
  • MXF processing: Stream extraction and demuxing capabilities
  • CLI tool: Unified opx command-line interface
  • Subtitle formats: RCWT (Raw Captions With Time) and EBU STL (EBU-Tech 3264) export

Format conversions: Convert between HD and SD T42 and VBI formats or vice versa. You can even pipe that data to other applications like ffmpeg or mpv.

Piping Example

ANSI Escaped Teletext: Supports parsing and filtering of teletext data with ANSI escape sequences:

VHS Teletext Comparison

Quick Start

Installation

Add the package reference to your project file from NuGet.org.

dotnet add package libopx

Or download the latest release from GitHub Releases.

Using the CLI Tool

# Filter teletext data by magazine and rows
opx filter -m 8 -r 20,22 input.vbi

# Filter MPEG-TS teletext (auto-detects PIDs)
opx filter input.ts

# Filter MPEG-TS with specific PID
opx filter --pid 70 input.ts

# Convert between formats (auto-detected from extension)
opx convert input.vbi output.t42

# Convert MPEG-TS to T42
opx convert --pid 70 input.ts output.t42

# Convert to EBU STL subtitle format
opx convert -c input.mxf output.stl

# Extract streams from MXF files
opx extract -k d,v input.mxf

Using the Library

using nathanbutlerDEV.libopx.Formats;

// Parse and filter teletext data from VBI
using var vbi = new VBI("input.vbi");
foreach (var line in vbi.Parse(magazine: 8, rows: new[] { 20, 22 }))
{
    Console.WriteLine(line);
}

// Parse and filter teletext from MPEG-TS (auto-detects PIDs)
using var ts = new TS("input.ts");
foreach (var line in ts.Parse(magazine: 8))
{
    Console.WriteLine(line);
}

// Parse MPEG-TS with specific PID
using var ts2 = new TS("input.ts") { PIDs = new[] { 70 } };
foreach (var line in ts2.Parse())
{
    Console.WriteLine(line);
}

Documentation

Project Structure

libopx/
├── apps/opx/         # CLI tool
├── lib/              # Main library
│   ├── Formats/      # Format parsers (MXF, MXF data stream, VBI, T42, TS)
│   ├── SMPTE/        # SMPTE metadata system
│   └── Enums/        # Enumeration definitions
├── samples/          # (Deprecated in repo) Obtain sample media from Release
│                       assets (e.g. v1.0.0) and place here if needed
├── scripts/          # Development scripts
└── tests/            # xUnit test suite

Development

# Clone and build
git clone https://github.com/nathanpbutler/libopx
cd libopx
dotnet build

# Run tests
dotnet test

Requirements

  • .NET 9 or later
  • Supported platforms: Windows, Linux, macOS

Dependencies

  • System.CommandLine (v2.0.0-rc.2.25502.107)
  • xUnit (testing)
  • coverlet (code coverage)

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Ensure all tests pass
  6. Submit a pull request

License

MIT - see the LICENSE file for details.

Acknowledgments

  • vhs-teletext - Software to recover teletext data from VHS recordings (inspiration for filter command)
  • MXFInspect - Tool for displaying the internal structure of MXF files (was super helpful for understanding MXF parsing and the intricacies of SMPTE timecodes)
  • bmxtranswrap - BBC's MXF processing library and utilities (inspiration for extract command)
  • SubtitleEdit - An incredibly useful C# library and software for subtitle editing and processing
  • CCExtractor - Closed caption and subtitle extraction and processing
  • ffmpeg - The swiss army knife of multimedia processing

Support

For questions and support, please open an issue.

About

MXF and Teletext caption processing library

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors 3

  •  
  •  
  •  

Languages