cca92f9dc493bce6e43850ab74df04fcc2dcb641
RTMP Push Tool
A TypeScript library for pushing media streams to RTMP servers using FFmpeg.
Features
- Push media streams to RTMP servers
- Support for various media formats (H.264, AAC, etc.)
- Configurable capabilities and stream keys
- Process management and monitoring
- TypeScript support
Installation
bun install
Usage
import {RtmpPush} from '@techniker-me/rtmp-push';
const rtmpPush = new RtmpPush('https://example.com/video.ts', 'rtmp://ingest.example.com:80/ingest');
// Start streaming
rtmpPush.start('stream-key', ['h264', 'aac']);
// Check if running
if (rtmpPush.isRunning()) {
console.log('Stream is active');
}
// Stop streaming
rtmpPush.stop();
Testing
This package includes comprehensive tests for all features:
Run all tests
bun test
Run tests in watch mode
bun test --watch
Run tests with coverage
bun test --coverage
Test Structure
- Unit Tests (
RtmpPush.test.ts): Test individual methods and edge cases with mocked dependencies - Integration Tests (
RtmpPush.integration.test.ts): Test real functionality and error handling
Test Coverage
The test suite covers:
- ✅ Constructor and property initialization
- ✅ Getter methods
- ✅ Start method with various parameters
- ✅ Stop method and process cleanup
- ✅ Process lifecycle management
- ✅ Error handling and edge cases
- ✅ URI construction and validation
- ✅ FFmpeg command generation
- ✅ Process event handling
Requirements
- Bun runtime
- FFmpeg installed on the system (for actual streaming)
- TypeScript 5+
License
MIT
Languages
TypeScript
100%