In an age where smart cameras are everywhere, storing CCTV footage usually means monthly cloud subscriptions or pricey DVR systems. I wanted a more affordable, private solution — so I repurposed an old Ubuntu laptop into a dedicated CCTV feed recorder. Here's how I did it.
An old laptop (running Ubuntu Server — no GUI required)
A TP-Link Tapo cam (or any IP camera that supports RTSP)
FFmpeg installed
Basic terminal/command line knowledge
Most modern IP cameras support RTSP (Real-Time Streaming Protocol), which allows you to stream directly into tools like FFmpeg.
Here’s the RTSP URL format I used for my Tapo C200:
bashrtsp://username:[email protected]:554/stream1
You can test the stream with:
bashffmpeg -i rtsp://username:password@camera_ip/stream1
To capture and store the feed in hour-long chunks, I used the following command:
bashffmpeg -rtsp_transport tcp -i rtsp://your_user:your_pass@camera_ip/stream1 \
-vf scale=1280:720 -r 12 -c:v libx264 -preset slow -crf 30 -an \
-f segment -segment_time 3600 -reset_timestamps 1 -strftime 1 \ /home/your_username/recordings/recording-%Y-%m-%d_%H-%M-%S.mp4
🔍 What This Does:
Downscales to 720p resolution
Reduces frame rate to 12fps (enough for security footage)
Uses CRF 30 for smaller file size without losing too much quality
Ignores audio (-an) to save space
Splits files into hourly segments
To avoid running out of disk space, I set up a cron job that deletes footage older than 2 days:
bashcrontab -e
Then add:
arduino59 23 * * * find /home/your_username/recordings/ -type f -name "recording-*.mp4" -mmin +2880 -delete
This runs daily at 11:59 PM and removes videos older than 48 hours (2880 minutes).
While PM2 is designed for Node.js, it also works great for managing long-running CLI processes:
bashpm2 start "ffmpeg -rtsp_transport tcp -i rtsp://... -c:v libx264 ..." --name cctv-recorder --interpreter bash
pm2 startup
pm2 save
This ensures the FFmpeg command restarts on boot and keeps running reliably in the background.
Using the above settings, here’s my actual usage:
24 seconds = ~786 KB
1 hour = ~120 MB
1 day (24h) = ~2.8 GB
80 GB drive = ~28 days of retention
Perfect for short-term logging without manual intervention.
FFmpeg is a beast. Lightweight, customizable, and insanely powerful.
You don’t need expensive hardware to build a robust security setup.
Cron + PM2 = Set it and forget it.
Privacy first. No more relying on cloud services to store sensitive footage.
This little weekend project turned my dusty old laptop into a self-sufficient CCTV storage box. It’s private, cheap, and highly customizable — ideal for privacy-conscious homeowners or DIY tinkerers.
Got a camera lying around? Give it a go!