A toolkit for building video streaming applications in Rust. The VDK provides a collection of modules for handling various video formats, codecs, and streaming protocols. It aims to provide a high-performance, flexible, and extensible framework for video processing and streaming, with a primary focus on RTSP to HLS conversion for web-based video streaming applications.
📦 crates.io 📖 Documentation 🔧 Examples 📝 Changelog
-
Video codec support:
- H.264/AVC parsing and frame extraction
- H.265/HEVC parsing and frame extraction
- AAC audio parsing and frame extraction
-
Streaming protocols:
- RTSP client implementation with SDP parsing
- RTP packet handling and media transport
- RTCP feedback and statistics
- TS (Transport Stream) format support
- HLS output with segmentation
These features have been thoroughly tested with live streams and are production-ready:
-
Streaming Protocols:
- RTSP: Fully implemented and tested with live RTSP streams, including core operations, authentication, and SDP parsing.
- RTP: Fully tested with live streams, implementing packet handling, sequence number management, and jitter buffer.
- RTCP: Thoroughly tested with reception reports and error handling.
-
Codec Support (via RTSP streams):
- H.264: Fully implemented and tested with live RTSP streams, including detailed handling of NALUs, SPS, and PPS.
- H.265: Basic functionality tested with live RTSP streams. Complete parameter set handling and more extensive testing are in progress.
- AAC: AAC codec parsing has been tested only as part of live RTSP streams for audio extraction, confirming basic functionality for RTSP audio. Standalone AAC format support and comprehensive testing remain in development.
The project's primary focus is enabling robust RTSP to HLS conversion for web-based video streaming applications. This feature is critical for building HTTP servers that can transcode RTSP streams to HLS without external dependencies. Current status:
- Basic RTSP to HLS conversion pipeline ✅
- TS segment generation and management ✅
- PCR timing and discontinuity handling ✅
- Multi-bitrate adaptation support ✅
- Error recovery with reconnection
⚠️ (Basic implementation) - Performance optimization 🚧 (In progress)
The following features are implemented and are undergoing further testing and refinement to ensure stability and production readiness:
-
Transport Stream (TS) Format:
- Core packet structure implementation ✅
- Program Specific Information (PSI) tables ✅
- PAT/PMT parsing and generation ✅
- Stream type identification (H.264, H.265, AAC) ✅
- Adaptation field support ✅
- PCR handling ✅
- PES packet handling ✅
- Advanced PCR timing mechanisms ✅
- PCR discontinuity handling ✅
-
HLS Support:
- Basic RTSP to HLS Conversion: Implemented and basic integration testing completed ✅. Provides a functional RTSP to HLS conversion pipeline.
- Segment generation and management ✅
- Basic playlist generation and management ✅
- Segment duration control ✅
- Multi-bitrate streaming support ✅
- RTSP to HLS conversion with transcoding ✅
- Testing Status:
- Basic RTSP to HLS conversion tested ✅
- Multi-bitrate adaptation tested ✅
- Playlist generation and segment management tested ✅
- Basic integration test now passing ✅
- PCR timing accuracy tested ✅
- Needs:
- Comprehensive Testing: More comprehensive testing with varied RTSP streams and codec combinations is needed to ensure robustness and identify potential issues.
- Enhanced error recovery and handling mechanisms
- Further refinement and optimization for performance and stability
- More comprehensive live testing for production readiness
While live testing URLs are essential for full validation and production readiness, we provide preliminary implementations with basic unit tests for formats that currently lack live testing capabilities. This approach ensures:
- Basic Functionality: Core features are implemented and unit tested
- Format Compatibility: Basic compatibility with the format specifications
- Integration Readiness: Groundwork for future live testing and validation
- Development Continuity: Progress continues while awaiting live testing resources
Note: These implementations should be considered experimental until validated with live streams. They provide a foundation for testing and development but are not recommended for production use without comprehensive live testing.
- Format Support:
- AAC Format: Basic implementation of AAC file format support (muxer/demuxer) with unit tests only. Needs live stream testing and more comprehensive tests.
- TS Format: Core TS format implementation is complete and used in RTSP to HLS conversion. Further testing needed with different codec combinations and transport stream variations.
-
RTSP to HLS Conversion Enhancement:
- Implement robust error recovery for stream interruptions and network issues
- Optimize TS segment generation and management for improved performance
- Add comprehensive testing with varied RTSP streams and codec combinations
- Enhance PCR timing accuracy and discontinuity handling
- Implement advanced buffer management for smoother playback
-
Performance Optimization:
- Profile and optimize TS muxing operations
- Improve memory usage in segment management
- Enhance concurrent stream handling efficiency
- Optimize PCR timing calculations
- Implement efficient segment cleanup strategies
-
Comprehensive Testing Infrastructure:
- Develop automated testing framework for RTSP to HLS conversion
- Create test suites for various network conditions
- Implement stress testing for long-running streams
- Add performance benchmarking tools
-
Acquire Live Testing URLs:
- Obtain live testing URLs for the following formats to enable full feature validation, comprehensive testing, and ensure feature parity with the reference vdk implementation:
- DVRIP
- FLV
- FMP4
- MKV
- MP4 variants
- RTMP
- WebRTC
- Obtain live testing URLs for the following formats to enable full feature validation, comprehensive testing, and ensure feature parity with the reference vdk implementation:
The following formats from vdk
are planned for implementation. Live testing URLs will be essential to properly validate these implementations and ensure production readiness:
- DVRIP - Preliminary implementation planned
- FLV - Preliminary implementation planned
- FMP4 - Preliminary implementation planned
- MKV - Preliminary implementation planned
- MP4 - Preliminary implementation planned
- MP4F - Preliminary implementation planned
- MP4M - Preliminary implementation planned
- MSE - Preliminary implementation planned
- NVR - Preliminary implementation planned
- RAW - Preliminary implementation planned
- RTMP - Preliminary implementation planned
- WebRTC - Preliminary implementation planned
Feature | vdkio Status | vdk Status | Live Testing Status |
---|---|---|---|
RTSP | ✅ Full | ✅ Full | ✅ Tested with live streams |
RTP | ✅ Full | ✅ Full | ✅ Tested with live streams |
RTCP | ✅ Full | ✅ Full | ✅ Tested with live streams |
H.264 | ✅ Full | ✅ Full | ✅ Tested with live streams |
H.265 | ✅ Full | ✅ Tested with live streams | |
AAC Codec | ✅ Full | ||
AAC Format | ✅ Full | ❌ Unit tests only | |
TS Format | ✅ Full | ✅ Full | ✅ Tested with RTSP conversion |
HLS | ✅ Full | ||
Other Formats | 🚧 Planned | ✅ Full | ❌ Awaiting test streams |
Legend:
- ✅ Full: Complete implementation
⚠️ Basic: Preliminary implementation- 🚧 In Progress/Planned: Implementation in progress or planned
- ❌ Missing: Not yet implemented or no test streams available
For thorough testing and feature parity validation, the following are needed:
-
Live testing URLs for format support validation: Essential for validating format implementations and achieving feature parity.
- DVRIP
- FLV
- FMP4
- MKV
- MP4 variants
- RTMP
- WebRTC
-
Additional testing requirements:
- Sample files for different codecs and formats to expand test coverage.
- Test streams with various codec combinations to ensure compatibility and robustness.
- Infrastructure for automated testing to streamline testing and ensure consistent validation.
- vdk for being the original, reference implementation in Go that was used.
- Exponential-Golomb coding for the theory behind H.264/H.265 transcoding.
- exp-golomb for providing a working, reference implementation for Exponential Golomb coding.
Built with the help of
- 🤖 Gemini 2.0
- 🤖 Claude 3.5 Sonnet
- 🤖 OpenAI GPT-4o-mini
- 🚀 Roo Code
- 🚀 Cline
Add this to your Cargo.toml
:
[dependencies]
vdkio = "0.1.0"
See the examples/
directory:
rtsp_player.rs
: Working with RTSP streamsts_format.rs
: Working with Transport Stream formataac_format.rs
: Working with AAC files (basic implementation)rtsp_to_hls.rs
: Converting RTSP streams to HLS formatstress_test.rs
: Performance and stability testing with:- Multi-bitrate transcoding
- Long-running stream validation
- Performance metrics collection
- Error recovery scenarios
The project includes comprehensive test suites:
-
Unit and Integration Tests:
- RTSP client functionality (
integration_test.rs
) - RTSP to HLS pipeline validation (
integration_test.rs
)
- RTSP client functionality (
-
Advanced Protocol Tests (
rtsp_hls_test.rs
):- RTSP error handling and recovery
- TS packet validation
- HLS playlist verification
- Network interruption handling
-
Performance Testing:
- Long-running stability tests (
stress_test.rs
) - Multi-bitrate transcoding validation
- Resource usage monitoring
- Error recovery verification
- Long-running stability tests (
-
RTSP Streams:
- Use RTSPClient for connecting to and consuming RTSP streams
- Supports authentication and connection management
- Includes setup options for video/audio selection
-
HLS Streaming:
- Supports conversion from RTSP to HLS
- Provides segmentation and playlist management
- Configurable segment duration and retention
- Features:
- Multi-bitrate adaptation support
- Automatic segment cleanup
- PCR timing accuracy
- Error recovery with reconnection
This project is licensed under the MIT License - see the LICENSE file for details.