Treasured's Movie Repair Guide -- AVCHD

AVCHD is a modern high-definition video format developed by Sony and Panasonic.

It is targeted to consumer camcorders recording in DVD disks, SD and SDHC memory cards and hard disk drives.


297px-AVCHD.svg.png


http://en.wikipedia.org/wiki/AVCHD


AVCHD is stored in .mts files. In the typical file structure, they are found in the BDMV folder:


Root directory of recording medium

|

|--[PRIVATE]

|     |

|     |--[AVCHD]

|     |     |

|     |     |--[BDMV]

|     |     |     |

|     |     |     |--[STREAM]

|     |     |     |     |

|     |     |     |     |-- XXXX.MTS  ... video clip


Detection

Treasured is capable of detecting and previewing AVCHD media in damaged files or disks.

Such corrupt AVCHD files can also be repaired through the Movie Repair Service.


Repairability

AVCHD files use an MPEG Transport Stream structure that contain a H264 video stream and an audio stream that can be AC-3 or PCM.

Unlike other containers, transport streams do not need indexes, instead they use fixed-length blocks to organize the data. Blocks start with 0x47 byte and are easily found. This contributes to make transport streams more robust to corruption.


In case of recording failure, for example when the camera battery dies, the file is incomplete but can still be playable.

In other words, it is very rare that an AVCHD file requires to be repaired.


How to repair a damaged AVCHD clip?

The easiest way is certainly to ask our Movie Repair Service to do it for you.

But for those who can program, here you have a few tips:

The file is probably unplayable due to "alien data" that contaminates the transport stream, or due to mixed streams. For example, large amount of garbage or padding can be inside the file, in particular after a storage failure or DeepMediaScan.

Therefore, the file data should be filtered to get rid of alien data. This can be done superficially, verifying that we have a regular TS blocks structure with token 0x47 every 192 bytes.

If it's not enough, the transport stream should be decoded, and the H264 + Audio media inside can then be inspected and repaired.


How to re-wrap an AVCHD file for use in Mac computers?

The .mts file can be used with very few applications. Usually you must go through re-encoding to Intermediate format before you can use them.


Fortunately, there is a method to make them directly available to most video applications (that use QuickTime .mov or .mp4 file formats)

You can re-wrap your AVCHD file in .mp4 containers with ffmpeg command-line utility.

ffmpeg -i sampleAVCHD.mts -vcodec copy -an -f mp4 myfile.mp4


This command creates a valid QuickTime file with a H264 track. Re-wrapping is ultra-fast and lossless, as it does not re-encode the media. Re-wrapped files can be edited natively with SimpleMovieX.


Note that you need a version of ffmpeg at least as recent as below, 

  libavutil     50. 3. 0 / 50. 3. 0

  libavcodec    52.37. 1 / 52.37. 1

  libavformat   52.39. 2 / 52.39. 2

  libavdevice   52. 2. 0 / 52. 2. 0

  libswscale     0. 7. 1 /  0. 7. 1