Skip to content

Instantly share code, notes, and snippets.

@sit
Created April 21, 2010 04: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 sit/373401 to your computer and use it in GitHub Desktop.
Save sit/373401 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# Convert from a MTS to a mp4 file using HandbrakeCLI
# Handbrake available from, for example, http://handbrake.fr/downloads2.php
#
# Renames files as prefixYYYYMMDD_basename.mp4 in the current directory.
# If you have an AVCHD directory, for example, you could run
# mts2mp4 /Volumes/SDCARD/PRIVATE/BDMV/STREAM/*.MTS
# to convert from your SDCARD into your current directory (on OS X).
#
prefix=${USER}_
# Exit the entire script on signal.
trap 'exit' 1 2 15
# Abort on any conversion error (or if file is missing!)
set -e
for f in "$@"
do
# Name the output file based on the file modification time.
# (The ctime may have been affected by the time the file was copied, chmod, etc)
eval $(stat -s $f)
of=$prefix$(date -j -f %s $st_mtime +%Y%m%d)_$(basename $f .MTS).mp4
time nice HandbrakeCLI --preset="Normal" -i $f -o $of
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment