1#! /bin/bash
2
3# AVCHD to MP4 converter
4# ffmpeg arguments taken from http://pvdm.xs4all.nl/wiki/index.php/Convert_an_AVCHD_/_MTS_file_to_MP4_using_ffmpeg
5
6OPTIND=1
7
8src=""
9dest=""
10verbose=0
11
12if (( $# < 2 ))
13 then
14 printf "\n\x1b[31mWrong number of arguments\x1b[0m\n\n"
15 printf "Usage: avchdtomp4 -s SOURCE -d DESTINATION [-v]\n where SOURCE is the source file, or a directory scanned for *.MTS files\n DESTINATION is the output directory relative to working directory\n [-v] enables verbose mode in ffmpeg"
16 exit 1
17fi
18
19
20while getopts s:d:v option; do
21 case "$opt" in
22 s)
23 src=$OPTARG
24 ;;
25 d)
26 dest=$OPTARG
27 ;;
28 v)
29 verbose=1
30 ;;
31 esac
32done
33
34
35
36IFS=$(echo -en "\n\b"); for i in $(find $src -name '*.MTS'); do ffmpeg -i "$i" -vcodec mpeg4 -b:v 15M -acodec libmp3lame -b:a 192k "${$i%.MTS}.mp4"; done
37
38