By Lucas, founder of FixMyVideos · Updated

Recover a Corrupted Sony XAVC S File

Sony cameras recording XAVC S, S-I or HS (Alpha bodies, the ZV and RX compacts, and FX3/FX30-class Cinema Line cameras) write an MP4 that the camera names in the C####.MP4 pattern and files away in a clip folder on the card. When one of those refuses to open, the first suspect is the index at the end of the file, and on a Sony that index can carry more than the timing of each picture. Losing it can hurt more on a Sony than on most cameras, and the rest of this page is about why.

Three names come up. XAVC S is H.264 in Long-GOP, usually with B-frames. XAVC S-I is H.264 All-Intra, every picture a keyframe. XAVC HS is H.265/HEVC, built the same way; the HEVC page covers that codec's own problems.

What a healthy XAVC S file looks like inside

A clip that closed normally is laid out as a small ftyp header, a Sony uuid box, one large mdat holding the media, and the moov index written last, at the tail. Inside mdat the camera interleaves three kinds of data, one group at a time. In a 1080p50 clip we took apart, each half-second group of pictures came after 24 metadata samples of 1,024 bytes and before 92,160 bytes of audio.

The audio is uncompressed PCM. Every Sony file we have measured carried 16-bit big-endian samples, 48 kHz, stereo.

The metadata is a timed track Sony calls rtmd: one sample per video frame, made of SMPTE KLV packets plus some proprietary bytes and padding, including a per-frame timecode. An a1 II shooting 1080p100 writes 19,456 bytes of it per frame, so this "metadata" track outweighs the audio by roughly ten to one.

The XML file the camera writes next to each clip (its name follows the clip's) holds clip metadata. It is not the index, and the MP4 does not need it to play.

Why losing the moov can be worse on a Sony

On most cameras a missing moov means the player has lost its map (frame sizes, timing, where the audio is), and rebuilding it from the frames is the classic repair. Some Sony files lose more than that. The H.264 decoder setup lives in the SPS and PPS parameter sets, and in a 4K Long-GOP file we measured they existed only inside the moov: 4,270 pictures, not one parameter set in the stream itself. Other Sony files do repeat them in-band (an a1 II XAVC S clip and an XAVC Intra stream we examined both did). When they are missing, though, the coded pictures are unreadable even with every byte of video still on the card.

Those parameter sets are not one fixed table either. Sony's Long-GOP encoder writes four PPS variants, numbered 0 to 3, each with stronger scaling matrices, and picks a rung per picture. In HD the tables are byte-identical across the a7 III, ZV-1 and A7S III. Recent 4K bodies (A6700, A7 V) use a different ladder. Guess the ladder wrong and the file still decodes without a single error message, while the picture comes out subtly or badly off.

Symptoms and what they point to

Horizontal tinted bands. You get one band per slice, which meant eight on the Sony 4K Long-GOP files we measured. Intra prediction restarts at every slice boundary, so the error from a wrong dequantisation table builds up separately inside each slice and each band ends up with its own colour cast. A 4.77 GB 4K 59.94p file showed it clearly. Swapping guessed tables for Sony's 4K ladder, harvested from donor clips shot in the same mode, took the chroma step at the band edges from 3.77 to 0.40 in 10-bit levels, where a healthy file from the same camera class measures 1.08.

The image plays back and forth, a small judder every GOP. Many XAVC S modes store pictures out of display order, and a rebuilt file must then carry the composition offsets (a ctts table) that tell the player how to reorder them. Without it, QuickTime shows the pictures in storage order, while ffmpeg-based tools reorder internally and report the file as clean. The reverse also exists. One older XAVC S file announced reordering in its header that its pictures never used, and forcing a reorder on it scrambled the timeline (31 backward steps in 792 frames).

The audio is loud noise. Any tool that reads the gaps between video groups as audio gets PCM, rtmd packets and padding mixed together, often played in the wrong sample format. The fix is to find the KLV packets by their structure, strip every metadata sample, and only then detect the format on what remains. We checked that against an a1 II clip with its index stripped, and the extracted PCM came out byte-exact.

The file is the right size and still won't open. The 4K 29.97p 10-bit 4:2:2 file we rebuilt had a pre-reserved mdat: the camera stopped writing 534.8 MB into a 939.5 MB region and the rest was zeros. When that happens, the size you see in Finder is the reservation, not the recording.

What you can try yourself first

Work on a copy, and keep the original card untouched until you have a file you are happy with. If the clip plays in VLC but not in the Windows or Mac player, it may not be damaged at all: Sony's 10-bit 4:2:2 modes are a format those players cannot decode (10-bit 4:2:2 video won't play).

  1. Copy the whole clip folder, not just the MP4, and try a different card reader if the copy errors out or stalls. A bad read is a different problem from a bad file (see the unrecoverable cases below).
  2. Run ffprobe on the copy. "moov atom not found" confirms the missing-index case. If ffprobe lists a video stream with a duration, the index survived, and you are looking at damage inside the media instead.
  3. Open it in DaVinci Resolve or Premiere as well as QuickTime. If one of them opens it, the index is at least partly there.
  4. Try untrunc with a healthy clip from the same camera, recorded at the same resolution, frame rate, codec and bit depth. Because of the PPS ladder, a clip from the same camera in a different mode is not a valid reference. Even when untrunc fails, keep that healthy clip; it is the most useful thing you can give anyone who repairs the file.

How our engine rebuilds an XAVC S file

The analyzer walks the payload and separates the three streams: H.264 access units by their length prefixes, rtmd by its KLV chains, and PCM by what remains. Near-silent PCM is a trap here, because 16-bit samples of value 0 and 1 spell out an H.264 start code. Before we fixed the scanner, a test copy of an a1 II 1080p100 clip produced 1,356 phantom frames. Afterwards the same file gave 1,152 of 1,152 frames, each byte-exact, with every keyframe at its true position.

When the file has no parameter sets of its own, they come from a store of ladders harvested from real Sony clips recorded in the same mode. A clean decode proves nothing here, since a wrong ladder decodes silently too, which is why the mode has to match. If yours is a mode we hold no ladder for, the diagnosis says so and asks for a healthy clip from the same camera and mode, which then serves as the reference.

The frame rate is read from the file itself. A 4K 29.97p clip taught us that: a rate learned from an earlier, similar file overrode the one this file declared, and its preview ran at 60 fps. Now the declared rate wins over anything learned elsewhere.

The video is not re-encoded. We built a test copy from a customer's own healthy clip, stripped its index and cut off the start; all 504 delivered pictures matched the original frame for frame, with audio and video in sync to 0.0 ms. The repaired file carries AAC audio, encoded from the recovered PCM, rather than the camera's original PCM track.

Two recoveries, described by their measured result:

  • 4K 29.97p, 10-bit 4:2:2, missing index, zero-filled tail. 855 of 855 pictures decoded with no errors, picture and sound both 28.528 s long, audio matching the original timing at zero lag. The last picture had 5 of its 8 slices complete and the sixth cut off by the zero fill; it is dropped rather than shown half-drawn.
  • 1080p50 XAVC S whose start had been overwritten by an 833 KB JPEG from another camera, written there by a card-recovery tool, plus duplicated junk at the end. 792 pictures delivered, uniformly timed, with 15.78 s of real sound. The pictures between the destroyed keyframe and the next one cannot be rebuilt by any decoder.

We also got one wrong at first. A 100 MB fragment of an XAVC HS 4K card was diagnosed as holding no video while 78.6% of its bytes were HEVC. Three faults had stacked up. The scan took a 627-byte rtmd sidecar index for the file's own, the carve insisted on an mdat box the fragment no longer had, and the search for HEVC parameter sets never looked 2.74 MB in, where they sat. All three are fixed, and an index with no video track no longer counts. The upload itself turned out to be six overlapping copies of one stretch of about 15 to 18.6 MB, leaving about 2.7 seconds of distinct picture.

When there is nothing to recover

Some files are beyond any repair, ours included, and the diagnosis says so instead of selling you a preview. Only the first case below came off a Sony card. The other two came from other cameras, but a bad copy fails the same way whatever recorded it.

  • All zeros. A 390 MB .MP4 from a Sony card was 0x00 from first byte to last. This copy carried none of the recording, so if you still have the card, copy the clip from it again.
  • Header only. A 24-byte file that a card-recovery tool had carved out: a single ftyp box with nothing behind it.
  • One block repeated. A 20 MB dashcam file held 12,288 bytes of distinct data, because the reader kept returning the same sector. Copying again through different hardware is the only move that can help, and the diagnosis tells you that.

Trying it on your file

Upload the XAVC S file, up to 150 GB. The diagnosis and a free 5-second preview of the rebuilt clip come back within a few minutes, so you can check the picture and sound before deciding anything. If you keep it, the full file costs €6 under 2 GB, €18 from 2 to 20 GB, €35 from 20 to 50 GB and €59 above that, VAT included. Uploads are deleted automatically after 48 hours.

FAQ

Do I need a healthy reference clip? Often not, when your file still holds its parameter sets or your recording mode is covered by the ladders we already hold. When it is not, the diagnosis asks for one, and it has to come from the same camera at the same resolution, frame rate and codec setting.

Will my S-Log3 footage come back flat, ready to grade? The coded pictures are copied, not re-encoded, so they decode to what the camera recorded once the right parameter sets are in place. With the wrong ones you would see tinted bands, so look closely at the preview before you pay.

Why does my recovered file have AAC audio instead of PCM? The rebuild encodes the recovered PCM to AAC 48 kHz. The sound is the camera's, measured in sync with the picture, but it is a lossy encode of it, not a copy of the original track.

The file is 4 GB but nothing opens. Is the video really in there? Possibly less than the size suggests. If the camera reserved the space up front, as the one we measured did, a recording that stopped early leaves a long run of zeros behind it. The diagnosis reports how much real video it found.

Is my footage safe? It is processed on our servers, deleted automatically after 48 hours and never used for training or shared. Details in the privacy policy.

Related

Upload your XAVC S file

Free preview · No commitment

Ready to recover your video?

Upload your file and get a free 5-second preview in about a minute. Pay only if the preview looks right.

Upload your file →