A high-performance RTSP to HLS conversion library written in Zig 0.13, focusing on memory efficiency and minimal external dependencies.
- RTSP client for connecting to RTSP servers (supports RTSP 1.0)
- Media parsing for H.264, H.265, and AAC
- Transport Stream (TS) segment creation
- HLS playlist generation and serving
- Customizable segment duration and retention
- Support for both live and dummy RTSP URLs for testing
- Zero external dependencies - pure Zig implementation
- Memory-efficient design for embedded and high-performance applications
- Zig 0.13.0 or later
- No additional dependencies required
# Clone the repository
git clone https://github.com/yourusername/zvdk.git
cd zvdk
# Build the library and executable
zig build
# Run tests
zig build test
# Basic usage
./zig-out/bin/zvdk <rtsp_url> [output_dir] [port]
# Example
./zig-out/bin/zvdk rtsp://example.com/stream segments 8080
You can include zvdk in your Zig project in several ways:
const std = @import("std");
const zvdk = @import("zvdk");
pub fn main() !void {
var client = try RtspClient.init(allocator);
defer client.deinit();
try client.connect("rtsp://example.com/stream");
try client.setup();
try client.play();
// Process frames
while (client.isPlaying()) {
// Process RTSP stream
// See full example in examples directory
}
// Clean up
client.teardown();
}
Add zvdk to your build.zig.zon
file:
.{
.name = "your-app",
.version = "0.1.0",
.dependencies = .{
.zvdk = .{
.url = "https://github.com/bkataru/zvdk/archive/refs/tags/v0.1.0.tar.gz",
.hash = "12200...", // Replace with the actual hash after adding the dependency
},
},
}
Then, in your build.zig
:
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{
.name = "your-app",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
// Add zvdk as a dependency
const zvdk_dep = b.dependency("zvdk", .{
.target = target,
.optimize = optimize,
});
exe.addModule("zvdk", zvdk_dep.module("zvdk"));
b.installArtifact(exe);
}
In your code, you can then import and use zvdk:
const std = @import("std");
const zvdk = @import("zvdk");
pub fn main() !void {
// Your code using zvdk
}
See the API Documentation for detailed information about using the library.
The library includes comprehensive tests:
# Run all tests
zig build test
# Run specific test
zig build test -- --filter="hls"
For more advanced testing, the library includes a mock RTSP server that can be used for testing without a real RTSP source.
See ARCHITECTURE.md for detailed information about the project structure and component interactions.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Please ensure your code passes all tests and follows the Zig coding style.
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by various media processing libraries and RTSP clients
- Thanks to the Zig community for the great language and tools
- Special thanks to the following open source projects that provided valuable references:
- media-server - A comprehensive C/C++ implementation of various media protocols
- cpp_hls - A C++ implementation of HLS streaming
- vdk - Go Video Development Kit with RTSP, RTMP, and HLS support