You run FFmpeg on a file and it stops at once with Invalid data found when processing input. Nothing is converted. It is a general error: FFmpeg could not process the input data. It can come from detecting the format, parsing the header or decoding. The causes are few, and you can work through them in order. First confirm what the file really is, then try the least destructive repair, and re-encode only if nothing else works.

The error is about the input, so start there. In most cases the file is incomplete, damaged or not a media file at all. Find out which one you have first; only some of these can be recovered.

Common Causes

The message alone does not prove the file is damaged. Read the lines just before it to see which step failed. The usual causes are:

  • Truncated or partial download — a download or copy was interrupted, so the end of the file is missing. The moov atom (in an MP4) or the index never arrived.
  • Not actually a media file — for example an HTML error page, a partial download or other non-media data saved as video.mp4. For formats FFmpeg can recognise from their contents, such as MP4 and WebM, a valid file with the wrong extension (a real .webm named .mp4) usually still opens. Some formats are detected by extension, though, and need the right one or an explicit -f.
  • Actual corruption — bytes were flipped or lost on a bad disk, in a faulty transfer or in a failed recording.
  • Unsupported or exotic container — a rare format that your FFmpeg build was not compiled to demux (read).

Whatever the cause, the order is the same: identify the file, then try the cheapest repair first.

Step 1: Check What the File Really Is

Before any repair, run ffprobe. It shows the container and streams FFmpeg detects, so you see at once whether the file is the format you think it is.

ffprobe input.mp4

Check the first lines of the output:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
  Duration: 00:01:23.45, start: 0.000000, bitrate: 1536 kb/s
  Stream #0:0: Video: h264 (High), yuv420p, 1280x720, 30 fps
  Stream #0:1: Audio: aac, 44100 Hz, stereo

If ffprobe also reports Invalid data found, the bytes are usually damaged, incomplete, unsupported or not media data at all. For formats detected by extension, a wrong extension can cause it too, so if you know the real format, rename the file or name the format with -f before the input and try again. If ffprobe detects a valid format that only differs from the extension (for example Input #0, matroska,webm on a file named .mp4), FFmpeg can already read it. Renaming it to the format ffprobe reports (for example input.webm) helps people and media players, not FFmpeg.

If ffprobe shows a sensible duration and streams but FFmpeg still fails partway through a conversion, the file is probably slightly damaged or truncated. Go to Step 2.

Step 2: Re-mux into a New File

If the streams are mostly valid but the file contains some garbage, you can often copy the packets into a new container. -c copy skips re-encoding (fast and lossless). Try it without -err_detect first. That option changes error handling both when the input is read and when it is decoded, but whether it helps depends on the format and the damage.

ffmpeg -i input.mp4 -c copy output.mp4
  • -c copy — copy the output streams without re-encoding
  • output to a fresh file — a clean container with a rebuilt index

This writes a new container from the packets that can be saved. If the only damage was a broken index or some junk at the end, the new output.mp4 often plays normally. Because it is a copy, it loses no quality and is usually much faster than a re-encode; the time depends on the file size and on disk or network speed.

Step 3: Generate Missing Timestamps

Some files, such as AVI files with B-frames, have packets with a decoding timestamp (DTS) but no presentation timestamp (PTS). Copying them to MP4 then prints pts has no value. -fflags +genpts tells FFmpeg to generate the missing PTS from the DTS.

ffmpeg -fflags +genpts -i input.mp4 -c copy output.mp4
  • -fflags +genpts — generate missing presentation timestamps
  • -c copy — still no re-encoding

It does not repair a cut-off file. An MP4 keeps its timing in the moov atom, which +genpts cannot rebuild. A Non-monotonic DTS message is a warning: FFmpeg adjusts the timestamp and carries on, and +genpts does not change that.

Step 4: Re-encode as a Last Resort

When the file opens and its packets can be read, but the copy still does not play because the packets themselves are damaged (not only the container), the last option is to decode and re-encode. FFmpeg decodes the video and audio streams it selects automatically, drops what it cannot decode and writes a new file. To keep other audio tracks or subtitles too, list every stream you want with -map. For subtitles in MP4, convert text subtitles with -c:s mov_text.

ffmpeg -i input.mp4 -c:v libx264 -crf 23 -c:a aac output.mp4
  • -c:v libx264 -crf 23 — re-encode the video at a sensible quality
  • -c:a aac — re-encode the audio to AAC
  • the decode step reconstructs as much as possible and discards the unrecoverable

Re-encoding is slower and lossy: how much quality it costs depends on the source and the settings, so check the output. It can still rescue files that copying cannot. It cannot help a file that does not open at all (when ffprobe fails too).

Summary: Fixes in Order

Step Command Cost Use when
1. Identify ffprobe input.mp4 None Always first — find the real format
2. Re-mux ffmpeg -i input.mp4 -c copy output.mp4 Fast, lossless Streams valid, container junk
3. Fix PTS ffmpeg -fflags +genpts -i input.mp4 -c copy output.mp4 Fast, lossless Packets without PTS (pts has no value)
4. Re-encode ffmpeg -i input.mp4 -c:v libx264 -crf 23 -c:a aac output.mp4 Slow, lossy It opens, but copying does not fix it

Work from top to bottom. The early steps cost nothing and often solve the problem. Re-encode only when copying fails.

FAQ

ffprobe says the format doesn’t match the extension — what do I do?

For formats FFmpeg recognises from their contents, such as MP4 and WebM, it usually opens the file whatever the extension. The wrong extension mainly confuses media players and people. Renaming the file to the format ffprobe reports (a .webm saved as .mp4 becomes input.webm) is for clarity and player compatibility; FFmpeg does not need it. If ffprobe itself reports invalid data, the usual causes are a damaged file, a file that is not media, or a format this build does not support. For formats detected by extension, a wrong extension can cause it too, so if you know the real format, rename the file or name the format with -f before the input and try again.

My download was interrupted — can FFmpeg still save it?

It depends on the format. With TS, MKV or an MP4 whose moov is at the start (faststart), you can often recover the part that arrived. Try the re-mux in Step 2. You get a shorter clip that covers what was downloaded. A regular MP4 keeps its moov at the end. If the end is missing, that is the “moov atom not found” case below, and FFmpeg alone can almost never recover it.

Re-muxing produced a file but it cuts off early. Why?

Reading or writing may have ended at that point. Some formats, such as MKV, can skip a damaged section and keep reading, so check the log just before the end and the size of the original file. Re-encoding (Step 4) sometimes recovers a few more frames, but it cannot recreate missing bytes.

Is this the same as a “moov atom not found” error?

They are related but not the same. “moov atom not found” is a specific MP4 case: the index (the moov atom) is missing, usually because a download was cut short. If the moov atom is really missing, FFmpeg usually cannot demux any packets at all. -err_detect ignore_err, -fflags +genpts and re-encoding then generally cannot recover the file; they only help when FFmpeg can still demux usable streams. A missing moov atom usually needs the original or a reference recording, or a specialized repair tool such as untrunc. See the moov atom guide for details.

Could it just be an outdated FFmpeg build?

Rarely, but check it for unusual containers. If your build has no demuxer for the format, ffprobe cannot name it and reports the same Invalid data found error. Updating to the latest FFmpeg may add the demuxer. For common formats such as MP4, MKV and WebM, an outdated build is almost never the cause. Suspect a damaged file, or one that is not media at all, first.