The Problem
My neighbor's car got scratched. They had CCTV footage — 3 days of recordings on a microSD card.
When we checked the files, every single one had a .media extension. No video player could open them. Most converter apps either choked on bulk files or wanted a subscription.
I suspected these were just regular video containers with a renamed extension — common with budget CCTV brands.
Step 1: Test with FFmpeg
ffmpeg -i "/path/to/0000.media" -c copy test_output.mp4
It worked. H.264 video wrapped in a .media container. FFmpeg read it without issues.
Step 2: Understand the File Structure
The microSD had a nested folder structure — thousands of 10-second .media chunks across subfolders.
Step 3: The Script
#!/bin/bash
INPUT_DIR="/path/to/cctv"
OUTPUT_DIR="/path/to/cctv_generated/output"
MERGED_DIR="/path/to/cctv_generated/merged"
CONCAT_LIST="/path/to/cctv_generated/concat_list.txt"
MERGED_OUTPUT="$MERGED_DIR/merged_final.mp4"
mkdir -p "$OUTPUT_DIR"
mkdir -p "$MERGED_DIR"
> "$CONCAT_LIST"
find "$INPUT_DIR" -name "*.media" | sort | while read -r f; do
rel=$(echo "$f" | sed "s|$INPUT_DIR/||" | sed 's|/|_|g' | sed 's|\.media||')
out="$OUTPUT_DIR/${rel}.mp4"
ffmpeg -i "$f" -c copy "$out" -y 2>/dev/null
if [ -f "$out" ] && [ -s "$out" ]; then
echo "file '$out'" >> "$CONCAT_LIST"
else
echo "⚠️ Skipping (failed): $f"
fi
done
ffmpeg -f concat -safe 0 -i "$CONCAT_LIST" -c copy "$MERGED_OUTPUT" -y
echo "✅ Done! Merged output: $MERGED_OUTPUT"
Why -c copy?
Instead of re-encoding (which takes hours), -c copy copies the raw stream directly into the new container.
For 1,000 files this means:
- Minutes instead of hours
- Zero quality loss
- Negligible CPU usage
Result
~1,000 files converted and merged into a single 34-hour MP4. The whole process finished in under 15 minutes on a Mac Mini M-series.
A few files had moov atom not found errors — these were corrupt/incomplete recordings from the CCTV, safely skipped.
The Bigger Takeaway
Most "bulk video converter" websites? They're just wrappers around FFmpeg on a backend server. You're paying for a UI around a free, 20-year-old open-source CLI tool.
Next time you hit a file format problem — check if FFmpeg handles it first. It probably does.
FFmpeg docs: https://www.ffmpeg.org/

Top comments (0)