Automated Archiving Service
Go to file
RTSDA 2c3c86e07d Add LICENSE, improve README, and update project documentation
- Add MIT LICENSE file
- Make README more generic and comprehensive
- Add installation and troubleshooting sections
- Include systemd service integration docs
- Update with build and deployment instructions
2025-08-16 18:57:27 -04:00
package Add LICENSE, improve README, and update project documentation 2025-08-16 18:57:27 -04:00
src Add LICENSE, improve README, and update project documentation 2025-08-16 18:57:27 -04:00
.DS_Store Add LICENSE, improve README, and update project documentation 2025-08-16 18:57:27 -04:00
.gitignore Remove .mp4 files and update .gitignore 2025-02-06 22:14:51 -05:00
Cargo.lock Initial commit 2025-02-06 22:14:18 -05:00
Cargo.toml Initial commit 2025-02-06 22:14:18 -05:00
DEPLOY.md Add LICENSE, improve README, and update project documentation 2025-08-16 18:57:27 -04:00
deploy.sh Add LICENSE, improve README, and update project documentation 2025-08-16 18:57:27 -04:00
LICENSE Add LICENSE, improve README, and update project documentation 2025-08-16 18:57:27 -04:00
livestream-archiver-clean.tar.gz Add LICENSE, improve README, and update project documentation 2025-08-16 18:57:27 -04:00
livestream-archiver.service Add LICENSE, improve README, and update project documentation 2025-08-16 18:57:27 -04:00
package.sh Add LICENSE, improve README, and update project documentation 2025-08-16 18:57:27 -04:00
README.md Add LICENSE, improve README, and update project documentation 2025-08-16 18:57:27 -04:00

Livestream Archiver

A Rust application that monitors a directory for livestream recordings, processes them, and syncs them to a remote server. Designed for automated livestream archiving with hardware-accelerated transcoding.

Features

  • File Detection: Monitors a configured directory for new MP4 files
  • Readiness Check: Waits for files to be completely written before processing
  • Remote Sync: Uses rsync to send files to a remote server immediately after detection
  • Caching & Retry: Caches failed syncs and retries them on subsequent runs
  • Processing: Converts files to AV1 using QSV hardware acceleration
  • Organization: Creates date-based directory structure in Jellyfin format
  • Cleanup: Deletes original files after successful processing and sync
  • Systemd Integration: Runs as a system service with automatic restart

Installation

Prerequisites

  • Rust toolchain (1.70 or later)
  • rsync for file synchronization
  • ffmpeg compiled with Intel QSV support
  • SSH key authentication configured for passwordless rsync

Building from Source

# Clone the repository
git clone <repository-url>
cd livestream-archiver

# Build release binary
cargo build --release

# Binary will be at target/release/livestream-archiver

Quick Deploy

# Use the included deploy script
./deploy.sh

Configuration

Set the PC_SYNC_TARGET environment variable to configure where files are synced:

export PC_SYNC_TARGET="user@192.168.1.100:/path/to/destination/"

If not set, defaults to: user@192.168.1.100:/path/to/destination/

Usage

Running Manually

# Run directly
cargo run

# Or run the compiled binary
./target/release/livestream-archiver

Running as a Service

# Copy the service file
sudo cp livestream-archiver.service /etc/systemd/system/

# Reload systemd and enable the service
sudo systemctl daemon-reload
sudo systemctl enable livestream-archiver
sudo systemctl start livestream-archiver

# Check service status
sudo systemctl status livestream-archiver

The application will:

  1. Check for existing unprocessed files
  2. Start monitoring for new files
  3. For each detected file:
    • Wait for it to be ready (stable size/modification time)
    • Sync to PC using rsync
    • Convert to AV1 format
    • Create NFO metadata file
    • Delete original file

Directory Structure

Output files are organized as:

<output-directory>/
├── 2024/
│   ├── 01-January/
│   │   ├── Livestream - January 01 2024.mp4
│   │   ├── Livestream - January 01 2024.nfo
│   │   └── ...
│   └── ...
└── ...

Environment Variables

  • PC_SYNC_TARGET: Remote sync destination (e.g., user@server:/path/to/destination/)
  • INPUT_DIR: Directory to monitor for new files (default: /home/user/Sync/Livestreams)
  • OUTPUT_DIR: Local output directory for processed files (default: /media/archive/jellyfin/livestreams)

Troubleshooting

Service not starting

  • Check logs: journalctl -u livestream-archiver -f
  • Verify paths exist and have proper permissions
  • Ensure ffmpeg has QSV support: ffmpeg -hwaccels | grep qsv

Sync failures

  • Verify SSH key authentication to remote server
  • Check network connectivity
  • Review cached sync files in ~/.cache/livestream-archiver/

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.