fix: gitignore and stuff
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,5 +1,7 @@
|
||||
node_modules
|
||||
|
||||
timelapse
|
||||
|
||||
# Output
|
||||
.output
|
||||
.vercel
|
||||
|
||||
223
QUICK_START.md
223
QUICK_START.md
@@ -1,223 +0,0 @@
|
||||
# RTSP to HLS Streaming - Quick Start Guide
|
||||
|
||||
## Installation (5 minutes)
|
||||
|
||||
### 1. Install FFmpeg
|
||||
```bash
|
||||
# macOS
|
||||
brew install ffmpeg
|
||||
|
||||
# Ubuntu/Debian
|
||||
sudo apt-get install ffmpeg
|
||||
|
||||
# Windows (Chocolatey)
|
||||
choco install ffmpeg
|
||||
```
|
||||
|
||||
### 2. Install Dependencies
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
### 3. Start Development Server
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
|
||||
Visit `http://localhost:5173`
|
||||
|
||||
## Usage
|
||||
|
||||
1. Enter a **Stream ID** (e.g., "camera-1")
|
||||
2. Enter an **RTSP URL** (e.g., "rtsp://192.168.1.100:554/stream")
|
||||
3. Click **Start Stream**
|
||||
4. Watch video play in the browser
|
||||
5. Click **Stop Stream** to terminate
|
||||
|
||||
## What Was Set Up
|
||||
|
||||
### Backend Components
|
||||
- **`src/lib/server/streaming.ts`** - FFmpeg process manager
|
||||
- Spawns FFmpeg to convert RTSP → HLS
|
||||
- Manages stream lifecycle
|
||||
- Handles errors and cleanup
|
||||
|
||||
- **`src/routes/api/stream/+server.ts`** - REST API
|
||||
- `/api/stream` POST endpoint
|
||||
- Actions: start, stop, status, list
|
||||
|
||||
### Frontend Components
|
||||
- **`src/lib/components/RTSPVideoPlayer.svelte`** - Video player
|
||||
- HLS.js library for playback
|
||||
- Input forms for Stream ID and RTSP URL
|
||||
- Stream controls and status display
|
||||
|
||||
### Static Files
|
||||
- **`static/hls/`** - HLS segments (auto-created)
|
||||
- Stores `.m3u8` playlists
|
||||
- Stores `.ts` segment files
|
||||
- Automatically cleaned up by FFmpeg
|
||||
|
||||
## How It Works
|
||||
|
||||
```
|
||||
RTSP Stream (Camera)
|
||||
↓
|
||||
FFmpeg (spawned process on server)
|
||||
Converts to HLS segments
|
||||
↓
|
||||
HLS.js (browser)
|
||||
Parses playlist and segments
|
||||
↓
|
||||
HTML5 Video Player
|
||||
Displays video in browser
|
||||
```
|
||||
|
||||
## API Examples
|
||||
|
||||
### Start Stream
|
||||
```bash
|
||||
curl -X POST http://localhost:5173/api/stream \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"action": "start",
|
||||
"streamId": "camera-1",
|
||||
"rtspUrl": "rtsp://192.168.1.100:554/stream"
|
||||
}'
|
||||
```
|
||||
|
||||
### Stop Stream
|
||||
```bash
|
||||
curl -X POST http://localhost:5173/api/stream \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"action": "stop",
|
||||
"streamId": "camera-1"
|
||||
}'
|
||||
```
|
||||
|
||||
### Get Status
|
||||
```bash
|
||||
curl -X POST http://localhost:5173/api/stream \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"action": "status", "streamId": "camera-1"}'
|
||||
```
|
||||
|
||||
### List All Streams
|
||||
```bash
|
||||
curl -X POST http://localhost:5173/api/stream \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"action": "list"}'
|
||||
```
|
||||
|
||||
## Common RTSP URLs
|
||||
|
||||
| Camera Brand | URL Pattern |
|
||||
|---|---|
|
||||
| Hikvision | `rtsp://admin:password@IP:554/stream` |
|
||||
| Dahua | `rtsp://admin:password@IP:554/live` |
|
||||
| Generic | `rtsp://user:password@IP:554/stream` |
|
||||
| Reolink | `rtsp://user:password@IP:554/h264Preview_01_main` |
|
||||
| Ubiquiti | `rtsp://user:password@IP:554/live1` |
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
| Problem | Solution |
|
||||
|---|---|
|
||||
| FFmpeg not found | Install FFmpeg and add to PATH |
|
||||
| Stream won't connect | Verify RTSP URL with VLC first |
|
||||
| No video playback | Check browser console for HLS.js errors |
|
||||
| High CPU usage | Use `-preset ultrafast` in streaming.ts |
|
||||
| High latency | Reduce `-hls_time` from 10 to 2-5 seconds |
|
||||
|
||||
## File Structure
|
||||
|
||||
```
|
||||
grown/
|
||||
├── src/
|
||||
│ ├── lib/
|
||||
│ │ ├── server/
|
||||
│ │ │ └── streaming.ts ← FFmpeg manager
|
||||
│ │ └── components/
|
||||
│ │ └── RTSPVideoPlayer.svelte ← Video player UI
|
||||
│ └── routes/
|
||||
│ ├── +page.svelte ← Home page
|
||||
│ └── api/stream/
|
||||
│ └── +server.ts ← Stream API
|
||||
├── static/
|
||||
│ └── hls/ ← HLS segments (auto-created)
|
||||
├── package.json
|
||||
├── svelte.config.js
|
||||
└── vite.config.ts
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
Edit `src/lib/server/streaming.ts` to adjust FFmpeg parameters:
|
||||
|
||||
### Lower Latency (for real-time apps)
|
||||
```typescript
|
||||
'-hls_time', '2', // 2-second segments
|
||||
'-hls_list_size', '5', // Keep 5 segments
|
||||
'-preset', 'ultrafast', // Fastest encoding
|
||||
```
|
||||
|
||||
### Higher Quality
|
||||
```typescript
|
||||
'-crf', '23', // Better quality
|
||||
'-b:v', '2500k', // Higher video bitrate
|
||||
'-b:a', '192k', // Higher audio bitrate
|
||||
```
|
||||
|
||||
### GPU Acceleration (NVIDIA)
|
||||
```typescript
|
||||
'-c:v', 'h264_nvenc', // GPU encoder
|
||||
'-preset', 'fast', // fast, medium, slow
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
### Test with a Public RTSP Stream
|
||||
```
|
||||
rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov
|
||||
```
|
||||
|
||||
### Test with VLC Player
|
||||
```bash
|
||||
# Verify RTSP URL works before using in the app
|
||||
vlc rtsp://192.168.1.100:554/stream
|
||||
```
|
||||
|
||||
## Next Steps
|
||||
|
||||
1. **Deploy**: Use Docker or your preferred hosting
|
||||
2. **Secure**: Add authentication to `/api/stream` endpoints
|
||||
3. **Monitor**: Log stream statistics and errors
|
||||
4. **Scale**: Implement load balancing for multiple cameras
|
||||
5. **Optimize**: Adjust FFmpeg parameters for your use case
|
||||
|
||||
## Documentation
|
||||
|
||||
- Full setup guide: `RTSP_STREAMING_SETUP.md`
|
||||
- FFmpeg docs: https://ffmpeg.org/documentation.html
|
||||
- HLS.js docs: https://github.com/video-dev/hls.js/wiki
|
||||
- SvelteKit docs: https://kit.svelte.dev
|
||||
|
||||
## Browser Support
|
||||
|
||||
✓ Chrome/Edge (HLS.js)
|
||||
✓ Firefox (HLS.js)
|
||||
✓ Safari (Native HLS)
|
||||
✓ Mobile browsers (Full support)
|
||||
|
||||
## Need Help?
|
||||
|
||||
1. Check the browser console for errors
|
||||
2. Check terminal output for FFmpeg logs
|
||||
3. Verify RTSP URL is correct
|
||||
4. Ensure FFmpeg is installed and in PATH
|
||||
5. Check network connectivity to camera
|
||||
|
||||
---
|
||||
|
||||
**You're all set!** Start the dev server and visit `http://localhost:5173`
|
||||
@@ -1,546 +0,0 @@
|
||||
# RTSP to HLS Streaming in SvelteKit
|
||||
|
||||
This guide walks you through setting up real-time RTSP stream conversion to HLS format in your SvelteKit application.
|
||||
|
||||
## What's Included
|
||||
|
||||
- **Backend**: FFmpeg-based RTSP to HLS converter running on Node.js
|
||||
- **Frontend**: SvelteKit component with HLS.js video player
|
||||
- **API**: RESTful endpoints to control streams
|
||||
|
||||
## Prerequisites
|
||||
|
||||
### System Requirements
|
||||
- **Node.js**: 18 or higher
|
||||
- **FFmpeg**: Must be installed and in your PATH
|
||||
- **Package Manager**: npm or bun
|
||||
|
||||
### Install FFmpeg
|
||||
|
||||
#### macOS
|
||||
```bash
|
||||
brew install ffmpeg
|
||||
```
|
||||
|
||||
#### Ubuntu/Debian
|
||||
```bash
|
||||
sudo apt-get update
|
||||
sudo apt-get install ffmpeg
|
||||
```
|
||||
|
||||
#### Windows (Chocolatey)
|
||||
```bash
|
||||
choco install ffmpeg
|
||||
```
|
||||
|
||||
#### Windows (Scoop)
|
||||
```bash
|
||||
scoop install ffmpeg
|
||||
```
|
||||
|
||||
#### Verify Installation
|
||||
```bash
|
||||
ffmpeg -version
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
### 1. Install Dependencies
|
||||
```bash
|
||||
npm install
|
||||
# or with bun
|
||||
bun install
|
||||
```
|
||||
|
||||
This installs `hls.js` for browser-based HLS playback.
|
||||
|
||||
### 2. Project Structure
|
||||
|
||||
The setup creates the following files:
|
||||
|
||||
```
|
||||
src/
|
||||
├── lib/
|
||||
│ ├── server/
|
||||
│ │ └── streaming.ts # FFmpeg stream manager
|
||||
│ └── components/
|
||||
│ └── RTSPVideoPlayer.svelte # Video player component
|
||||
├── routes/
|
||||
│ ├── +page.svelte # Home page
|
||||
│ └── api/
|
||||
│ └── stream/
|
||||
│ └── +server.ts # Stream API endpoints
|
||||
└── ...
|
||||
|
||||
static/
|
||||
└── hls/ # HLS playlists & segments (auto-created)
|
||||
```
|
||||
|
||||
### 3. Run Development Server
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
|
||||
Open `http://localhost:5173` in your browser.
|
||||
|
||||
## Usage
|
||||
|
||||
### Web Interface
|
||||
|
||||
1. **Stream ID**: Enter a unique identifier (e.g., "camera-1")
|
||||
2. **RTSP URL**: Enter your camera's RTSP stream URL
|
||||
3. **Start Stream**: Click to begin conversion and playback
|
||||
4. **Stop Stream**: Click to terminate the stream
|
||||
|
||||
### Common RTSP URLs
|
||||
|
||||
**Hikvision Cameras**
|
||||
```
|
||||
rtsp://admin:password@192.168.1.100:554/stream
|
||||
rtsp://admin:password@192.168.1.100:554/Streaming/Channels/101
|
||||
```
|
||||
|
||||
**Dahua Cameras**
|
||||
```
|
||||
rtsp://admin:password@192.168.1.100:554/live
|
||||
```
|
||||
|
||||
**Generic IP Cameras**
|
||||
```
|
||||
rtsp://user:password@camera-ip:554/stream
|
||||
rtsp://camera-ip:554/stream1
|
||||
```
|
||||
|
||||
## API Reference
|
||||
|
||||
### Start Stream
|
||||
|
||||
**Request:**
|
||||
```bash
|
||||
curl -X POST http://localhost:5173/api/stream \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"action": "start",
|
||||
"streamId": "camera-1",
|
||||
"rtspUrl": "rtsp://192.168.1.100:554/stream"
|
||||
}'
|
||||
```
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"playlistUrl": "/hls/camera-1.m3u8"
|
||||
}
|
||||
```
|
||||
|
||||
### Stop Stream
|
||||
|
||||
**Request:**
|
||||
```bash
|
||||
curl -X POST http://localhost:5173/api/stream \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"action": "stop",
|
||||
"streamId": "camera-1"
|
||||
}'
|
||||
```
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"success": true
|
||||
}
|
||||
```
|
||||
|
||||
### Get Stream Status
|
||||
|
||||
**Request:**
|
||||
```bash
|
||||
curl -X POST http://localhost:5173/api/stream \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"action": "status",
|
||||
"streamId": "camera-1"
|
||||
}'
|
||||
```
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"streamId": "camera-1",
|
||||
"rtspUrl": "rtsp://192.168.1.100:554/stream",
|
||||
"startedAt": "2024-01-15T10:30:45.123Z",
|
||||
"isRunning": true,
|
||||
"playlistUrl": "/hls/camera-1.m3u8"
|
||||
}
|
||||
```
|
||||
|
||||
### List All Streams
|
||||
|
||||
**Request:**
|
||||
```bash
|
||||
curl -X POST http://localhost:5173/api/stream \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"action": "list"}'
|
||||
```
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"streams": [
|
||||
{
|
||||
"streamId": "camera-1",
|
||||
"rtspUrl": "rtsp://192.168.1.100:554/stream",
|
||||
"startedAt": "2024-01-15T10:30:45.123Z",
|
||||
"isRunning": true,
|
||||
"playlistUrl": "/hls/camera-1.m3u8"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
### FFmpeg Parameters
|
||||
|
||||
Edit `src/lib/server/streaming.ts` to adjust encoding parameters:
|
||||
|
||||
```typescript
|
||||
// Current defaults
|
||||
'-hls_time', '10', // Segment duration (seconds)
|
||||
'-hls_list_size', '3', // Number of segments to keep
|
||||
'-preset', 'fast', // Encoding speed
|
||||
'-b:a', '128k', // Audio bitrate
|
||||
```
|
||||
|
||||
### Low Latency Setup
|
||||
|
||||
For real-time applications, modify the FFmpeg arguments:
|
||||
|
||||
```typescript
|
||||
'-hls_time', '2', // 2-second segments
|
||||
'-hls_list_size', '5', // Keep more segments
|
||||
'-preset', 'ultrafast', // Fastest encoding
|
||||
'-flags', '+low_delay', // Low-delay mode
|
||||
```
|
||||
|
||||
### High Quality Setup
|
||||
|
||||
```typescript
|
||||
'-crf', '23', // Quality (0-51, lower=better)
|
||||
'-b:v', '2500k', // Video bitrate
|
||||
'-c:a', 'aac',
|
||||
'-b:a', '192k', // Higher audio quality
|
||||
```
|
||||
|
||||
### GPU Acceleration (NVIDIA)
|
||||
|
||||
```typescript
|
||||
'-c:v', 'h264_nvenc', // NVIDIA encoder
|
||||
'-preset', 'fast', // fast, medium, slow
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### "ffmpeg: command not found"
|
||||
|
||||
FFmpeg is not installed or not in your system PATH.
|
||||
|
||||
**Solution:** Reinstall FFmpeg and ensure it's in your PATH, then restart your terminal.
|
||||
|
||||
```bash
|
||||
# Verify FFmpeg is accessible
|
||||
which ffmpeg
|
||||
ffmpeg -version
|
||||
```
|
||||
|
||||
### Stream won't connect
|
||||
|
||||
Check the following:
|
||||
|
||||
1. **RTSP URL is correct**: Test with VLC player first
|
||||
2. **Network connectivity**: Ping the camera IP
|
||||
3. **Firewall rules**: Ensure port 554 (default RTSP) is open
|
||||
4. **Camera credentials**: Verify username/password in URL
|
||||
5. **FFmpeg logs**: Check browser console and terminal output
|
||||
|
||||
### "Playlist not found" Error
|
||||
|
||||
This usually means FFmpeg hasn't created the HLS segments yet.
|
||||
|
||||
**Solution:** Increase the wait time in the component:
|
||||
|
||||
```typescript
|
||||
// In RTSPVideoPlayer.svelte, startStream function
|
||||
await new Promise((resolve) => setTimeout(resolve, 3000)); // Increase from 1000 to 3000
|
||||
```
|
||||
|
||||
### Video won't play in Safari
|
||||
|
||||
HLS.js may have issues with some configurations.
|
||||
|
||||
**Solution:** Check that the HLS.js library is loaded:
|
||||
|
||||
```typescript
|
||||
// Verify HLS.js is available
|
||||
if (typeof window !== 'undefined' && !(window as any).HLS) {
|
||||
console.error('HLS.js not loaded');
|
||||
}
|
||||
```
|
||||
|
||||
### High CPU Usage
|
||||
|
||||
The FFmpeg process is using too many resources.
|
||||
|
||||
**Solution:** Use a faster preset or reduce resolution:
|
||||
|
||||
```typescript
|
||||
// Use ultrafast preset
|
||||
'-preset', 'ultrafast',
|
||||
|
||||
// Or reduce resolution
|
||||
'-vf', 'scale=1280:720',
|
||||
```
|
||||
|
||||
### High Latency / Buffering
|
||||
|
||||
Segments are taking too long to generate or playback is laggy.
|
||||
|
||||
**Solutions:**
|
||||
1. Reduce segment duration to 2-5 seconds
|
||||
2. Enable low-latency mode
|
||||
3. Check network bandwidth
|
||||
4. Reduce video resolution
|
||||
5. Close other CPU-intensive applications
|
||||
|
||||
## Browser Support
|
||||
|
||||
| Browser | HLS Support | Notes |
|
||||
|---------|-------------|-------|
|
||||
| Chrome | ✓ HLS.js | Full support via HLS.js library |
|
||||
| Firefox | ✓ HLS.js | Full support via HLS.js library |
|
||||
| Safari | ✓ Native | Native HLS support |
|
||||
| Edge | ✓ HLS.js | Chromium-based, full support |
|
||||
| Mobile Chrome | ✓ HLS.js | Full support |
|
||||
| Mobile Safari | ✓ Native | Native HLS support |
|
||||
| Opera | ✓ HLS.js | Full support |
|
||||
|
||||
## Security Best Practices
|
||||
|
||||
### 1. Environment Variables for Credentials
|
||||
|
||||
Never hardcode camera credentials in your code.
|
||||
|
||||
```typescript
|
||||
// Load from environment
|
||||
const rtspUrl = `rtsp://${process.env.CAMERA_USER}:${process.env.CAMERA_PASS}@${process.env.CAMERA_IP}:554/stream`;
|
||||
```
|
||||
|
||||
Create a `.env.local` file:
|
||||
```
|
||||
CAMERA_USER=admin
|
||||
CAMERA_PASS=password
|
||||
CAMERA_IP=192.168.1.100
|
||||
```
|
||||
|
||||
### 2. Restrict API Access
|
||||
|
||||
Implement authentication on the `/api/stream` endpoint:
|
||||
|
||||
```typescript
|
||||
// src/routes/api/stream/+server.ts
|
||||
export async function POST({ request, locals }) {
|
||||
// Check authentication
|
||||
if (!locals.user) {
|
||||
return json({ error: 'Unauthorized' }, { status: 401 });
|
||||
}
|
||||
|
||||
// Continue with stream logic
|
||||
}
|
||||
```
|
||||
|
||||
### 3. Network Security
|
||||
|
||||
- Use HTTPS in production
|
||||
- Restrict camera access to internal network only
|
||||
- Use VPN for remote access
|
||||
- Implement IP whitelisting
|
||||
|
||||
### 4. Process Management
|
||||
|
||||
FFmpeg runs with server privileges. Ensure:
|
||||
|
||||
- Minimal file system access
|
||||
- Process limits to prevent DoS
|
||||
- Regular monitoring and logging
|
||||
|
||||
## Performance Optimization
|
||||
|
||||
### 1. Adaptive Bitrate
|
||||
|
||||
Implement multiple quality levels:
|
||||
|
||||
```typescript
|
||||
// Start multiple streams at different resolutions
|
||||
const streams = [
|
||||
{ id: 'high', resolution: '1920:1080', bitrate: '5000k' },
|
||||
{ id: 'medium', resolution: '1280:720', bitrate: '2500k' },
|
||||
{ id: 'low', resolution: '640:360', bitrate: '1000k' }
|
||||
];
|
||||
```
|
||||
|
||||
### 2. Connection Pooling
|
||||
|
||||
For multiple concurrent streams, optimize memory usage:
|
||||
|
||||
```typescript
|
||||
// Limit concurrent streams
|
||||
const MAX_STREAMS = 5;
|
||||
if (activeStreams.size >= MAX_STREAMS) {
|
||||
return { error: 'Too many concurrent streams' };
|
||||
}
|
||||
```
|
||||
|
||||
### 3. Caching
|
||||
|
||||
Cache HLS segments on a CDN for better performance.
|
||||
|
||||
### 4. Hardware Acceleration
|
||||
|
||||
Use GPU encoding when available:
|
||||
|
||||
- NVIDIA: `h264_nvenc`
|
||||
- Intel: `h264_qsv`
|
||||
- AMD: `h264_amf`
|
||||
|
||||
## Production Deployment
|
||||
|
||||
### Docker
|
||||
|
||||
Create `Dockerfile`:
|
||||
|
||||
```dockerfile
|
||||
FROM node:18-slim
|
||||
|
||||
RUN apt-get update && apt-get install -y ffmpeg && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci --only=production
|
||||
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["node", "build/index.js"]
|
||||
```
|
||||
|
||||
Build and run:
|
||||
|
||||
```bash
|
||||
docker build -t rtsp-hls-app .
|
||||
docker run -p 3000:3000 \
|
||||
-e CAMERA_USER=admin \
|
||||
-e CAMERA_PASS=password \
|
||||
-e CAMERA_IP=192.168.1.100 \
|
||||
rtsp-hls-app
|
||||
```
|
||||
|
||||
### Docker Compose
|
||||
|
||||
```yaml
|
||||
version: '3.8'
|
||||
services:
|
||||
app:
|
||||
build: .
|
||||
ports:
|
||||
- "3000:3000"
|
||||
environment:
|
||||
CAMERA_USER: admin
|
||||
CAMERA_PASS: password
|
||||
CAMERA_IP: 192.168.1.100
|
||||
volumes:
|
||||
- ./static/hls:/app/static/hls
|
||||
restart: unless-stopped
|
||||
```
|
||||
|
||||
### Nginx Reverse Proxy
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name stream.example.com;
|
||||
|
||||
ssl_certificate /etc/ssl/certs/cert.pem;
|
||||
ssl_certificate_key /etc/ssl/private/key.pem;
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:3000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
}
|
||||
|
||||
location /hls/ {
|
||||
alias /app/static/hls/;
|
||||
expires 1h;
|
||||
add_header Cache-Control "public, max-age=3600";
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Advanced Topics
|
||||
|
||||
### Custom Video Filters
|
||||
|
||||
Add effects or transformations:
|
||||
|
||||
```typescript
|
||||
'-vf', 'scale=1280:720,fps=30,format=yuv420p'
|
||||
```
|
||||
|
||||
### Audio Processing
|
||||
|
||||
```typescript
|
||||
'-af', 'aresample=44100' // Resample to 44.1kHz
|
||||
```
|
||||
|
||||
### Statistics and Monitoring
|
||||
|
||||
Log stream statistics:
|
||||
|
||||
```typescript
|
||||
ffmpegProcess.stdout.on('data', (data) => {
|
||||
console.log(`Stream stats: ${data}`);
|
||||
});
|
||||
```
|
||||
|
||||
### Multiple Bitrate HLS (Adaptive)
|
||||
|
||||
Generate multiple quality versions:
|
||||
|
||||
```typescript
|
||||
// Create master playlist pointing to multiple variants
|
||||
const masterPlaylist = `#EXTM3U
|
||||
#EXT-X-STREAM-INF:BANDWIDTH=5000000
|
||||
high.m3u8
|
||||
#EXT-X-STREAM-INF:BANDWIDTH=2500000
|
||||
medium.m3u8
|
||||
#EXT-X-STREAM-INF:BANDWIDTH=1000000
|
||||
low.m3u8`;
|
||||
```
|
||||
|
||||
## Support & Resources
|
||||
|
||||
- [FFmpeg Documentation](https://ffmpeg.org/documentation.html)
|
||||
- [HLS.js Documentation](https://github.com/video-dev/hls.js/wiki)
|
||||
- [SvelteKit Documentation](https://kit.svelte.dev)
|
||||
- [ONVIF Protocol](https://www.onvif.org/) - For camera device discovery
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
@@ -1,7 +0,0 @@
|
||||
#EXTM3U
|
||||
#EXT-X-VERSION:3
|
||||
#EXT-X-TARGETDURATION:3
|
||||
#EXT-X-MEDIA-SEQUENCE:0
|
||||
#EXTINF:3.150000,
|
||||
camera-10.ts
|
||||
#EXT-X-ENDLIST
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,269 +0,0 @@
|
||||
#EXTM3U
|
||||
#EXT-X-VERSION:3
|
||||
#EXT-X-TARGETDURATION:12
|
||||
#EXT-X-MEDIA-SEQUENCE:1773178276
|
||||
#EXTINF:12.500000,
|
||||
camera-10.ts
|
||||
#EXTINF:12.500000,
|
||||
camera-11.ts
|
||||
#EXTINF:12.500000,
|
||||
camera-12.ts
|
||||
#EXTINF:12.500000,
|
||||
camera-13.ts
|
||||
#EXTINF:12.500000,
|
||||
camera-14.ts
|
||||
#EXTINF:12.500000,
|
||||
camera-15.ts
|
||||
#EXTINF:12.500000,
|
||||
camera-16.ts
|
||||
#EXTINF:12.500000,
|
||||
camera-17.ts
|
||||
#EXTINF:12.500000,
|
||||
camera-18.ts
|
||||
#EXTINF:12.500000,
|
||||
camera-19.ts
|
||||
#EXTINF:12.500000,
|
||||
camera-110.ts
|
||||
#EXTINF:4.600000,
|
||||
camera-111.ts
|
||||
#EXT-X-DISCONTINUITY
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178288.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178289.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178290.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178291.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178292.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178293.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178294.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178295.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178296.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178297.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178298.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178299.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178300.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178301.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178302.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178303.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178304.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178305.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178306.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178307.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178308.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178309.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178310.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178311.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178312.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178313.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178314.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178315.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178316.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178317.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178318.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178319.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178320.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178321.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178322.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178323.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178324.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178325.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178326.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178327.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178328.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178329.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178330.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178331.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178332.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178333.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178334.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178335.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178336.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178337.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178338.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178339.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178340.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178341.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178342.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178343.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178344.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178345.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178346.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178347.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178348.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178349.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178350.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178351.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178352.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178353.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178354.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178355.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178356.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178357.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178358.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178359.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178360.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178361.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178362.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178363.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178364.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178365.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178366.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178367.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178368.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178369.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178370.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178371.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178372.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178373.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178374.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178375.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178376.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178377.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178378.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178379.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178380.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178381.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178382.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178383.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178384.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178385.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178386.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178387.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178388.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178389.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178390.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178391.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178392.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178393.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178394.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178395.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178396.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178397.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178398.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178399.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178400.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178401.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178402.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178403.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178404.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178405.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178406.ts
|
||||
#EXTINF:3.000000,
|
||||
camera-11773178407.ts
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user