Go Back

POSTS

How to Fix Corrupted Video Files

Did your PC crash mid recording? Don't delete that corrupted file. This guide explains exactly how to restore broken recordings and fix audio sync issues using free tools like Untrunc and FFmpeg.

Author:

Llewellyn Paintsil

Date:

Read:

5 mins

Tutorial

How to Fix Corrupted Video Files thumbnail

If you were recording gameplay specifically with the NVIDIA App and your PC crashed mid-game, you are likely staring at a large file, but it refuses to play.

This happens because the recording was never "closed" properly. The data is there, but the file structure is incomplete. This guide covers exactly how to restore that corrupted MP4 on Windows using two free tools: Untrunc and FFmpeg.

Prerequisites: Get the Tools

You need two specific pieces of software to perform this surgery.

1. Untrunc (The Repair Tool) Download the latest version of Untrunc from GitHub. This is the primary tool that pieces the file back together.

2. FFmpeg (The Sync Tool) You need this to fix audio/video desync issues that usually occur after a repair.

  • Option A (Fastest): If you use Chocolatey, open PowerShell and run:
choco install ffmpeg-full

Untrunc & ffmpeg site

Step 1: Create a "Reference File"

Untrunc works by comparing your broken file to a working one created by the exact same software and settings. It essentially copies the "header" from a working file and applies it to the broken one.

  1. Open the NVIDIA App (or whatever software you were using when the crash happened).
  2. Record a new 5-second clip of your desktop or a game.
  3. Save it. This is now your Reference File.

Nvidia App overlay

Step 2: The Repair Process

  1. Open the untrunc-gui application.
  2. Click the button to select your Reference File (the clean 5-second clip you just made).
  3. Click the button to select your Corrupted File (the crash recording).
  4. Click Repair.

The tool will process the data and instantly generate a new file in the same folder, usually ending in _fixed.mp4.

untrunc-gui

Step 3: Check for Sync Issues

Open the new _fixed file.

  • Scenario A: The video plays smoothly, and the audio matches the gameplay perfectly. If this is you, congratulations, you are done.
  • Scenario B: The video plays, but the audio drifts or the video speed looks wrong (too fast or too slow).

Why this happens: Because the crash occurred during active recording, the video stream and audio stream often end up with mismatched frame rates. The video player tries to play them, but they drift apart. You need to force a realignment using FFmpeg.

Step 4: Syncing with FFmpeg

To fix the drift, we will manually adjust the timestamps of the video to match the audio.

  1. Open your file explorer to the folder where your _fixed.mp4 is located.
  2. Right-click on an empty space and choose Open in Terminal (or Command Prompt).
  3. Run the following command:
ffmpeg -i "YOUR_FIXED_FILE.mp4" -filter:v "setpts=2.0*PTS" -r 30 "output_synced.mp4"

Replace YOUR_FIXED_FILE.mp4 with the actual name of your file.

ffmpeg in action

How to Tweak This Command

If the output video looks unnatural (too slow or too fast), you need to adjust the variables in the command:

  • -r 30 (Frame Rate): This forces the output to 30 frames per second. If you were recording at 60 FPS, change this to -r 60.
  • setpts=2.0*PTS (Speed): This stretches the time between frames.
  • If the video is too fast, increase the number (e.g., 2.5*PTS).
  • If the video is too slow, decrease the number (e.g., 1.5*PTS or 1.0*PTS).

Keep adjusting these two numbers until the movement looks natural and matches the audio.

Technical Deep Dive: Why Did This Happen?

For those who want to understand the mechanics behind the crash and the fix, here is the technical breakdown.

1. The "Moov Atom" Problem

When your computer records an MP4 file, it is essentially writing a book. It writes the pages (video and audio data) sequentially to your hard drive. However, it does not write the Table of Contents (technically called the Moov Atom) until the exact moment you hit "Stop Recording."

When your PC crashed, the recording process was killed instantly. The "pages" (data) were written to the disk, but the "Table of Contents" was never created. Without that index, video players see a chaotic mess of data and refuse to play it because they don't know where the video starts or ends.

2. How Untrunc Performs the Transplant

Untrunc acts like a surgeon. When you provide a Reference File, you are giving Untrunc a valid Table of Contents from a healthy file.

  • It reads the structure of the healthy file.
  • It scans your corrupted file to identify the raw video and audio data.
  • It "transplants" the healthy structure onto the raw data, allowing video players to recognise the file as a valid MP4 again.

3. How FFmpeg Fixes the Drift

Even after the file is readable, the internal timing is often damaged. The video stream might think it has 100 frames that should play in 1 minute, while the audio stream thinks it has 2 minutes of sound.

The FFmpeg command we used manually overrides this:

  • setpts=2.0*PTS: This stands for Set Presentation Time Stamps. It mathematically alters the time gap between every single video frame. By multiplying by 2.0, we are effectively slowing the video down (stretching the time) to help it align with the audio.
  • -r 30: This creates a constant frame rate, forcing the player to process exactly 30 frames every second, eliminating variable frame rate jitters caused by the crash.

By combining these, you manually synchronize the visual speed with the audio speed.

Author

Llewellyn Paintsil profile pic, a member of L.A.P

Llewellyn Paintsil

Driven by a transformative moment that sparked a deep fascination with technology, I've been captivated by all its facets, particularly the visual aspects of software and video.

Latest Posts

Tutorial

Read Every Manga (For Free) with Komikku thumbnail

Read Every Manga (For Free) with Komikku

Tired of reading manga on websites that drain your battery and spam you with ads? There’s a better way. Meet Komikku: the clean, ad-free, and open-source alternative that every manga fan needs. Here is exactly how to set it up and start reading in minutes.

Author

Llewellyn Paintsil

Duration

6 mins

Tutorial

Turn Your Phone Into a Magic Wand thumbnail

Turn Your Phone Into a Magic Wand

Too lazy to reach for the mouse? Discover how to use your phone's gyroscope to control your computer from a distance in this quick, beginner-friendly guide.

Author

Llewellyn Paintsil

Duration

5 min

Scripts

how-to-watch-movies-and-series-in-terminal-lobster-thumbnail

Watch Movies and Series in Terminal

Ever wanted to watch a movie without leaving the comfort of your command line? Meet Lobster, the surprising tool that makes it possible. Learn how to turn your terminal into a media player in our latest guide.

Author

Llewellyn Paintsil

Duration

5 mins