A lightning-fast Rust command-line tool that converts any video to Apple TV-compatible format using FFmpeg with hardware acceleration.
Command: tvcode
Run tvcode in any folder and it will:
- 🔍 Find all video files in the current directory
- 📊 Check their codec information
- ⚡ Convert them to H.264 video + AAC audio in MP4 format
- 🚀 Use hardware acceleration for maximum speed
- ✅ Skip files that are already compatible
Output Format (Apple TV Compatible):
- Video: H.264 (High Profile, Level 4.1)
- Audio: AAC (192 kbps stereo)
- Container: MP4 with fast-start flag
- Quality: Resolution-appropriate bitrates (3M-20M)
Install FFmpeg:
# macOS
brew install ffmpeg
# Linux (Ubuntu/Debian)
sudo apt install ffmpeg
# Windows
choco install ffmpeg- Build the binary:
cd /Volumes/Phobos/projects/home_video_loader
cargo build --release- Install to your PATH:
# Copy to /usr/local/bin (macOS/Linux)
sudo cp target/release/tvcode /usr/local/bin/
# Or add to your PATH in ~/.zshrc or ~/.bashrc
export PATH="/Volumes/Phobos/projects/home_video_loader/target/release:$PATH"- Verify installation:
tvcodeJust navigate to any folder with videos and run:
tvcodeThat's it! The command will:
- Scan for video files (.mp4, .mkv, .avi, .mov, etc.)
- Show what it found
- Convert incompatible files to H.264/AAC/MP4
- Create new files with
_appletv.mp4suffix
📺 tvcode - Apple TV Video Transcoder
======================================
📁 Scanning directory: /Users/you/Videos
Found 2 video file(s)
🎥 Processing: movie.mkv
Video: hevc (3840x2160)
Audio: ac3
Container: matroska,webm
⚙️ Transcoding to H.264/AAC...
📤 Output: movie_appletv.mp4
🚀 Using hardware acceleration: videotoolbox (H.264)
🔊 Converting audio to AAC
🔄 Starting transcode...
✅ Transcode completed: H.264/AAC/MP4
🎥 Processing: video.mp4
Video: h264 (1920x1080)
Audio: aac
Container: mov,mp4,m4a,3gp,3g2,mj2
✅ Already H.264/AAC Apple TV compatible, skipping
✅ All done!
tvcode automatically detects and uses the fastest available encoder:
| Platform | First Choice | Second Choice | Fallback |
|---|---|---|---|
| macOS | VideoToolbox | — | libx264 |
| Windows | NVIDIA NVENC | Intel QuickSync | libx264 |
| Linux | NVIDIA NVENC | VAAPI | libx264 |
Hardware encoding is typically 5-10x faster than software encoding.
- MP4, MKV, AVI, MOV, WMV
- FLV, WebM, M4V, MPG, MPEG
- 3GP, TS, M2TS
Bitrates are automatically chosen based on resolution:
| Resolution | Bitrate | Max Bitrate |
|---|---|---|
| 4K (2160p) | 20 Mbps | 30 Mbps |
| 1080p | 8 Mbps | 12 Mbps |
| 720p | 5 Mbps | 7 Mbps |
| SD | 3 Mbps | 4 Mbps |
All outputs use:
- H.264 High Profile (Level 4.1)
- AAC audio at 192 kbps
- CRF 20 for software encoding (excellent quality)
While Apple TV supports H.265/HEVC, H.264 offers:
- ✅ Universal compatibility across all Apple TV models
- ✅ Better hardware decoder support
- ✅ Faster encoding with hardware acceleration
- ✅ Excellent quality-to-size ratio
- ✅ No compatibility issues with older devices
Convert a specific folder:
cd ~/Downloads/vacation-videos
tvcodeProcess videos and delete originals:
# Review the output files first, then:
rm *_original_filename.mkvCheck what will be converted (dry run):
Just run tvcode - it will show what needs converting before doing anything.
"ffmpeg and ffprobe must be installed"
- Install FFmpeg:
brew install ffmpeg(macOS) - Verify:
ffmpeg -versionandffprobe -version
Slow encoding:
- Check if hardware acceleration is detected in the output
- macOS should always use VideoToolbox automatically
- Update GPU drivers on Windows/Linux
Command not found:
- Make sure the binary is in your PATH
- Try:
which tvcodeto see if it's installed - Re-run the installation steps
- Original files are never modified
- Output files:
{original_name}_appletv.mp4 - Outputs appear in the same directory as source files
MIT License - use freely!