Skip to content

Preventing Corrupted MP4 Files on Power Outage & System Crash

A critical vulnerability in standard CCTV and NVR software is unfinalized MP4 corruption. If a camera server experiences an abrupt power outage, kernel panic, or forced container restart, hours of recorded video can become permanently corrupted and unplayable.


🔍 The Anatomy of Broken MP4 Files

In the standard ISO Base Media File Format (MP4):

  • Video and audio payloads are written into the mdat atom.
  • The index, track definitions, frame offsets, and timestamps are written into the moov (movie) atom.

In conventional recorders:

  1. The recorder streams raw video into mdat during recording.
  2. The moov atom is calculated in memory and written to the file only when the recording is stopped normally.
  3. The Disaster: If power is cut or the server crashes while recording, the moov atom is never written to disk. Video players (VLC, Chrome, QuickTime) have no index and report corrupted file or unsupported format.

✅ The Solution: Fragmented MP4 (fMP4) Architecture

RUSEON Core records exclusively using Fragmented MP4 (fMP4):

text
[ ftyp ] [ moov (Initialization) ]
[ moof #1 ] [ mdat #1 ] -> 2-second fragment
[ moof #2 ] [ mdat #2 ] -> 2-second fragment
[ moof #3 ] [ mdat #3 ] -> 2-second fragment (Power cuts here!)

Why fMP4 is Crash-Resilient:

  1. Self-Describing Fragments: The file is broken into short, independent chunks. Each chunk contains a moof (movie fragment) header describing only its corresponding mdat data.
  2. Instant Playability: If power is physically pulled during recording, every completed fragment is already 100% indexed on disk.
  3. Zero Data Loss: The file can be opened immediately in any modern video player up to the exact millisecond before the power failure, with zero recovery software required.

🚀 Native Timeshift without Disk Duplication

In RUSEON Core, fMP4 files are also used directly for instant Web UI timeshift playback:

  • When a user seeks through historical recordings in the web dashboard, RUSEON reads fMP4 atoms and generates HLS .ts segments on-the-fly directly in RAM.
  • Eliminates the need to store duplicate HLS segments on disk, saving 50% of total storage hardware costs.

Released under the MIT License.