To rebuild an AVI index with FFmpeg, use this command: ffmpeg -i input.avi -c copy output.avi. It remuxes the file and writes a fresh idx1 index, fixing playback issues caused by a broken or missing index. The video and audio streams are copied into a new AVI container without re-encoding. Quality stays the same. The flags are simple. The limits are real.
What Remuxing Does to the Index
How the Command Works
Run ffmpeg -i input.avi -c copy output.avi. FFmpeg reads the original file, extracts the video and audio streams, and writes them into a new AVI container. During this process it generates a new idx1 index at the end of the file. The old index, if corrupt or missing, is replaced. This is the standard repair for an AVI that refuses to seek or shows a wrong duration. Because -c copy is used, no re-encoding happens. The output file stays roughly the same size as the input, but with a correct index.
Generating Missing Timestamps with Genpts
When Timestamps Are Missing
Some AVI files lack proper presentation timestamps in their video or audio streams. Without them, FFmpeg may produce a file that still plays incorrectly. Add the option -fflags +genpts before the -i flag:
ffmpeg -fflags +genpts -i input.avi -c copy output.avi
The +genpts flag tells FFmpeg to generate missing presentation timestamps from the available data. This matters when a file claims a constant frame rate but has no timestamps in the index. The generated timestamps are written into the new AVI container along with the rebuilt index.
Checking for Errors Before Remuxing
Spot Hidden Corruption First
Before rebuilding the index, check whether the file has serious decoding errors. Run:
ffmpeg -v error -i input.avi -f null -
This reads the file, decodes nothing (the -f null - discards output), and prints only error messages. If you see many errors about corrupt frames or broken data, the video data itself is damaged. Remuxing with -c copy will copy that damaged data into the new file. The index will be rebuilt. The glitches will remain.
When Re-Encoding Becomes Necessary
The Nuclear Option
If the video data is damaged, a remux will not repair it. The damaged frames copy over as-is. To attempt a fix, re-encode the video stream, for example to H.264. Re-encoding can smooth over small data errors because FFmpeg decodes the stream as much as possible and then encodes a clean version. Quality drops. Processing takes longer. The command looks like this:
ffmpeg -i input.avi -c:v libx264 -c:a copy output.avi
This re-encodes the video while keeping the audio untouched. It is a full re-encode, not a remux. Use it only when the remux approach fails to produce a playable file.
Step by Step Remuxing with Index Rebuild
The Full Procedure
- Open a terminal (Command Prompt on Windows, Terminal on macOS or Linux).
- Navigate to the folder containing your AVI file with
cd. - Run the error check:
ffmpeg -v error -i yourfile.avi -f null -. Review the output for corruption messages. - If errors are minimal or absent, run the remux command with timestamp generation:
ffmpeg -fflags +genpts -i yourfile.avi -c copy fixed.avi - Wait for FFmpeg to finish. The new file
fixed.avicontains a fresh index. - Test the output file in your media player. If it still fails, consider re-encoding the video.
This copies the content while fixing index and timestamp issues.
Limitations of This Method
What Remuxing Cannot Fix
- Damaged video data: If the video stream contains corrupted frames, remuxing copies those damaged bytes. The index will be correct, but playback may still show artifacts or freeze at the damaged points.
- No error concealment: FFmpeg does not attempt to repair or conceal errors when using
-c copy. It passes the data through. - Audio sync issues: If the original file had sync problems due to missing timestamps,
+genptscan help. It will not fix all sync errors if the underlying data is inconsistent. - Unreadable files: Some AVI files are so badly structured that FFmpeg cannot read them at all. No command line method will work on these.
For files that cannot be repaired with these commands, a different tool or a re-encode is the only option. The site avi.repair offers an online alternative for those who prefer not to use the command line.
Running FFmpeg on Different Operating Systems
FFmpeg is free and runs on Windows, macOS, and Linux. The commands are identical on all three platforms. On Windows, download the FFmpeg executable and either add it to your PATH or run it from the folder where you placed it. On macOS, install it via Homebrew with brew install ffmpeg. On Linux, use your package manager (sudo apt install ffmpeg on Debian/Ubuntu). Once installed, the ffmpeg command works the same way everywhere.