Results 1 to 10 of 22

Thread: How to convert AVCHD (MTS/M2TS) to MP4 losslessly.

Threaded View

  1. #1
    Join Date
    Jul 2005
    Beans
    17

    How to convert AVCHD (MTS/M2TS) to MP4 losslessly.

    I'll start with the end:

    Code:
    mencoder infile.mts -demuxer lavf -oac copy -ovc copy -of lavf=mp4 -o outfile.mp4
    ..and now to explain myself:

    AVCHD (MTS) is basically a container format for MPEG4-AVC video and AC-3 Audio. It's commonly found on modern camcorders. I have pulled files off a Sony Camcorder (I forget which model), which records in 1080i@50Hz. It seems there are timestamp problems, and both the even and odd fields are stamped with the same time, and not 1/50th of a second apart as you'd expect. This currently breaks ffmpeg (0.6~svn20100711), and the mencoder (SVN-r31722) internal demuxer doesn't like it either. The libavformat (lavf 0.6~svn20100711) demuxer/muxer seems to handle it, so that's what we'll use.

    If you run 'mediainfo' over an MTS file, you'll see something like this:

    Code:
    General
    ID                               : 0
    Complete name                    : infile.mts
    Format                           : BDAV
    Format/Info                      : Blu-ray Video
    File size                        : 62.6 MiB
    Duration                         : 56s 72ms
    Overall bit rate                 : 9 364 Kbps
    Maximum Overall bit rate         : 18.0 Mbps
    
    Video
    ID                               : 4113 (0x1011)
    Menu ID                          : 1 (0x1)
    Format                           : AVC
    Format/Info                      : Advanced Video Codec
    Format profile                   : High@L4.0
    Format settings, CABAC           : Yes
    Format settings, ReFrames        : 2 frames
    Duration                         : 56s 0ms
    Bit rate                         : 8 726 Kbps
    Width                            : 1 440 pixels
    Height                           : 1 080 pixels
    Display aspect ratio             : 16:9
    Frame rate                       : 25.000 fps
    Resolution                       : 8 bits
    Colorimetry                      : 4:2:0
    Scan type                        : Interlaced
    Scan order                       : Top Field First
    Bits/(Pixel*Frame)               : 0.224
    Stream size                      : 58.3 MiB (93%)
    
    Audio
    ID                               : 4352 (0x1100)
    Menu ID                          : 1 (0x1)
    Format                           : AC-3
    Format/Info                      : Audio Coding 3
    Duration                         : 56s 128ms
    Bit rate mode                    : Constant
    Bit rate                         : 256 Kbps
    Channel(s)                       : 2 channels
    Channel positions                : Front: L R
    Sampling rate                    : 48.0 KHz
    Video delay                      : -80ms
    Stream size                      : 1.71 MiB (3%)
    
    Text
    ID                               : 4608 (0x1200)
    Menu ID                          : 1 (0x1)
    Format                           : PGS
    Duration                         : 55s 575ms
    Video delay                      : -80ms

    Once you run it through the above command, the resultant container will look like this. The audio/video codec details will be the same because it's a straight (lossless) copy. Also note that the headers have been corrected from 25i to 50i.

    Code:
    General
    Complete name                    : outfile.mp4
    Format                           : MPEG-4
    Format profile                   : Base Media
    Codec ID                         : isom
    File size                        : 58.7 MiB
    Duration                         : 56s 160ms
    Overall bit rate                 : 8 761 Kbps
    Writing application              : Lavf52.73.0
    
    Video
    ID                               : 1
    Format                           : AVC
    Format/Info                      : Advanced Video Codec
    Format profile                   : High@L4.0
    Format settings, CABAC           : Yes
    Format settings, ReFrames        : 2 frames
    Format_Settings_FrameMode        : Frame tripling
    Codec ID                         : avc1
    Codec ID/Info                    : Advanced Video Coding
    Duration                         : 56s 140ms
    Bit rate mode                    : Variable
    Bit rate                         : 8 504 Kbps
    Width                            : 1 440 pixels
    Height                           : 1 080 pixels
    Display aspect ratio             : 4:3
    Original display aspect ratio    : 16:9
    Frame rate mode                  : Constant
    Frame rate                       : 50.000 fps
    Original frame rate              : 8.333 fps
    Resolution                       : 8 bits
    Colorimetry                      : 4:2:0
    Scan type                        : Interlaced
    Scan order                       : Top Field First
    Bits/(Pixel*Frame)               : 0.109
    Stream size                      : 56.9 MiB (97%)
    
    Audio
    ID                               : 2
    Format                           : AC-3
    Format/Info                      : Audio Coding 3
    Codec ID                         : ac-3
    Duration                         : 56s 160ms
    Bit rate mode                    : Constant
    Bit rate                         : 256 Kbps
    Channel(s)                       : 2 channels
    Channel positions                : Front: L R
    Sampling rate                    : 48.0 KHz
    Resolution                       : 16 bits
    Stream size                      : 1.71 MiB (3%)
    Note that the final video will still be interlaced. Removing the interlacing requires re-encoding.

    This was tested on 10.04 with the VDPAU team's cutting-edge-multimedia PPA installed.
    Last edited by pHr34kY; September 11th, 2010 at 11:55 AM.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •