Command to convert folder(s) of .MTS to .mp4 for editing

For this command to run correctly every .MTS file that has been split in multiple .MTS files by the camera (for example where the recording size has exceeded 2.0GB and the camera has automatically split it into mulitple files) these files need to be concatenated back into a single file.

This can be done manually by:

cat secondFile >> firstFile
cat thirdFile >> firstFile

and so on..

If you want a GUI way of doing this you can use this nautilus script I edited from the one found here:

cfn=$1
shift;
for arg
do
cat “$arg” >> “$cfn”
mv “$arg” ~/.local/share/Trash/files/
done

Open your favourite text editor and copy and paste the above code in and save it in the following location

~/.gnome2/nautilus-scripts/Concatenate

You should now be able to right click several .MTS files and select Scripts > Concatenate. The machine will then concatenate the files and move the unessential  .MTS files to your Trash / Waste Basket. You’ll know the concatenation is complete when the last file in the series appears in your waste basket/disappears from it’s original folder.

Before transcoding the .MTS files we need to install some programs to help with the transcoding:

sudo apt-get install ubuntu-restricted-extras x264

With the concatenation complete (if necessary) and everything we need installed, you can now run the following command to transcode the .MTS files into .MP4 files that can be used and editied without sync issues on Ubuntu.

find /location/of/MTS/files -name “*.MTS” -type f -exec ffmpeg -i {} -vcodec libx264 -vpre hq -crf 19 -threads 0 -deinterlace -acodec copy {}.mp4 \;

Leave a Reply

Your email address will not be published. Required fields are marked *


*