GNU / Linux

Convert, Join, re encode AVCHD .MTS files in Ubuntu Linux

convert, encode and join avchd files in linux

One of our audio and video archive customers has a large collection of AVCHD video files that are stored in 1.9GB ‘chunks’ as xxxxx.MTS files. All these files are of 60 minute and longer duration and must be joined, deinterlaced, re encoded to a suitable size and bitrate then uploaded for online access.

This is quite a task in computer time and file handling. These small domestic cameras produce good HD movies for a low cost but the compression to achieve this is very high and does not give you a file that is easily edited. The .MTS files are MPEG transport stream containers for H264 encoded video.

There are some proprietary solutions for MacOS X and Windows that will repackage the .MTS files into .MOV Quicktime containers that can be accessed by MacOS X or re-encoded to a less compressed format for editing with Final Cut Pro or Premiere. We didn’t need this though, just a reliable and  quick open source workflow.

  1. The first and most important issue is to rejoin the camera split files.
    These cameras use FAT32 file systems which cannot handle individual files larger than 2GB so they split the .MTS video file into chunks. As each chunk in a continuous sequence references the other chunks these must be joined in the correct order. This is easily achieved with the cat command.
  2. The rejoined .MTS files can now be reencoded to a more manageable size using open source software such as Handbrake. We also needed to deinterlace our footage as it was shot interlaced and it would be accessed on progressive displays. This will increase the encoding time but without it any movement will look odd with visible artifacts.
  3. Finding the ‘sweet spot’ for encoding can be time consuming but in this case was important as projected text needed to be legible but the file sizes kept manageable for reasonable upload times!


Posted by greatbear in digitisation expertise, video tape, 0 comments

Powerful tape conversion tools using SoX, LAME and Bash Scripting

SoX running in the MacOS X Leopard

One of our recent and ongoing jobs is a very large, over 2000, NAB 10.5 inch reel to reel archive of quarter inch professional tape recordings.

To fit into the budget but maintain quality we needed to find a way to streamline our workflow in converting the high resolution 24 bit 96 Khz master .wav  files to CD quality (16 bit / 44 Khz) and MP3 (320 kbps) audio files.

Typically this would be done manually with 2 track audio software such as Audacity, Peak Audio Tools, Wavelab, etc with a Graphic User Interface (GUI). For such a large amount of individual files this is time consuming, expensive and unnecessary. While many audio editors have batch processing tools, Amadeus Pro being one of our favourites, they are still not as flexible as combining command line tools with a Bash script.

SoX is a powerful command line audio tool that can be used to edit, convert, process, record and play a wide range of digital audio files. It also has a very high quality resampling algorithm which we are using here.

Once the tape reels have been digitised they are split into individual .wav files which are then renamed with artist and track details using a php script that accesses a .csv file. These 24/96 resolution files are then converted to lower, CD resolution using SoX and to 320 kb/s MP3’s using LAME. The script also uses sed, the stream editor, to add the text _16_44.wav or _mp3.mp3 to the filename for ease of identification. The script finds all files with the suffix _24_96.wav in all the subdirectories of it’s working directory and processes these.

At the moment this script is running under Mac OS X 10.5.8 using the MacPorts project but will, in time, be moved to one of our Apple G4 servers running the PowerPC version of Debian GNU/Linux 5.05 ‘Lenny’.

Posted by greatbear in audio tape, 1 comment