Skip to content

Instantly share code, notes, and snippets.

@morgner
Created May 2, 2011 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morgner/952354 to your computer and use it in GitHub Desktop.
Save morgner/952354 to your computer and use it in GitHub Desktop.
Convert MTS files to MOV format
#! /usr/bin/env bash
for F in `ls -1 *.MTS`
do
echo Recoding $F
FILE=${F%%.*}
ffmpeg -y -i ${FILE}.MTS -vn -acodec pcm_s16le -ac 2 a${FILE}.wav
YUV="yuv420p"
ffmpeg -y -r 24 -i ${FILE}.MTS -an -pix_fmt ${YUV} -r 24 -f rawvideo v${FILE}.yuv
ffmpeg -y -i a${FILE}.wav -s 1440x1080 -i v${FILE}.yuv -acodec pcm_s16le -ac 2 -vcodec mpeg4 -sameq -aspect 16:9 -r 24 -copyts ${FILE}.mov
rm a${FILE}.wav
rm v${FILE}.yuv
done
@morgner
Copy link
Author

morgner commented May 2, 2011

This script converts all MTS files in the current directory to MOV files (the MTS originals are kept) trying to minimize any impact on quality and file size. The intermediate files WAV and YUV may become huge (!) but the resulting MOV will be acceptable. The most important parameters are:

-s ...
-sameq
-aspect ...

With these parameter, quality and aspect ratio are adapted from source to destination. You may need to change them for your camera type or recording resolution settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment