--- /dev/null
+#!/bin/bash
+#
+# Calin-Andrei Burloiu, 2010, calin.burloiu@gmail.com
+#
+# This script cuts .mts video file starting from a seek point
+# with a desired duration. Seek point and duration are expressed in
+# seconds or in the hh:mm:ss[.xx] format.
+#
+
+if test $# -ne 4; then
+ echo "Usage: $0 mts-input-file mts-output-file seek-point duration"
+ exit 1
+fi
+
+MTS_IN="$1"
+MTS_OUT="$2"
+SEEK_POINT="$3"
+DURATION="$4"
+FFMPEG=/usr/bin/ffmpeg
+
+if test ! -f "$MTS_IN"; then
+ echo "Error: No such file $MTS_IN"
+ exit 1
+fi
+
+"$FFMPEG" -ss "$SEEK_POINT" -t "$DURATION" -i "$MTS_IN" -f mpegts -acodec copy -vcodec copy "$MTS_OUT"
--- /dev/null
+#!/bin/bash
+#
+# Calin-Andrei Burloiu, 2010, calin.burloiu@gmail.com
+#
+# This script extracts a thumbnail from a random frame of a video file.
+#
+#
+
+if test $# -ne 3; then
+ echo "Usage: $0 input-video output-image resolution"
+ exit 1
+fi
+
+IN="$1"
+OUT="$2"
+RESOLUTION="$3"
+FFMPEG=/usr/bin/ffmpeg
+
+if test ! -f "$IN"; then
+ echo "Error: No such file $IN"
+ exit 1
+fi
+
+# Choose a random frame
+DURATION=$(mediainfo --Inform="General;%Duration%" "$IN" | cut -d"." -f1)
+SEEK_POINT=$(($DURATION * $RANDOM / 32767 / 1000))
+
+"$FFMPEG" -i "$IN" -ss "$SEEK_POINT" -vframes 1 -s "$RESOLUTION" -f image2 "$OUT"
--- /dev/null
+#!/bin/bash
+#
+# 2010, Calin-Andrei Burloiu, calin.burloiu@gmail.com
+#
+# This scripts creates thumbnails for all videos with a specified suffix.
+#
+#
+
+if [ $# -ne 2 ]; then
+ echo "usage: $0 root_path suffix"
+ exit 1
+fi
+
+root_path="$1"
+suffix="$2"
+
+(
+IFS=$'\n'
+for filename in $(find "$root_path" -name "*$suffix"); do
+ new_filename=$(dirname "$filename")/$(basename "$filename" "$suffix")_tmp.jpg
+ new_filename1=$(dirname "$filename")/$(basename "$filename" "$suffix")_small.jpg
+ new_filename2=$(dirname "$filename")/$(basename "$filename" "$suffix")_big.jpg
+ rm -f "$new_filename1"
+ rm -f "$new_filename2"
+ ./ffmpeg-extract-thumbnail "$filename" "$new_filename" 1280x720
+ ffmpeg -i "$new_filename" -s 122x69 -f image2 "$new_filename1"
+ ffmpeg -i "$new_filename" -s 149x84 -f image2 "$new_filename2"
+ rm -f "$new_filename"
+done
+)
--- /dev/null
+#!/bin/bash
+#
+# 2010, Calin-Andrei Burloiu, calin.burloiu@gmail.com
+#
+# This scripts converts all mts files to avi starting from a root directory
+# recursively. The avi files are placed in the same directory as the
+# original mts files.
+#
+
+if [ $# -ne 1 ]; then
+ echo "usage: $0 root_path"
+fi
+
+root_path="$1"
+
+for i in $(find "$root_path" -name "*.mts"); do
+ #echo $(dirname $i)/$(basename $i .mts).avi
+ ./ffmpeg-mts2avi "$i" "$(dirname $i)/$(basename $i .mts).avi"
+
+done
--- /dev/null
+#!/bin/bash
+#
+# 2010, Calin-Andrei Burloiu, calin.burloiu@gmail.com
+#
+# This scripts converts all mts files to avi starting from a root directory
+# recursively. The avi files are placed in the same directory as the
+# original mts files.
+#
+
+if [ $# -ne 1 ]; then
+ echo "usage: $0 root_path"
+fi
+
+root_path=$1
+
+(
+IFS=$'\n'
+for filename in $(find "$root_path" -name '*.mts'); do
+ new_filename=$(dirname "$filename")/$(basename "$filename" .mts).avi
+ rm "$new_filename"
+ ./ffmpeg-mts2avi-custom "$filename" "$new_filename" 800x600
+done
+)
--- /dev/null
+#!/bin/bash
+#
+# 2010, Calin-Andrei Burloiu, calin.burloiu@gmail.com
+#
+# This scripts converts all mts files to avi starting from a root directory
+# recursively. The avi files are placed in the same directory as the
+# original mts files.
+#
+
+if [ $# -ne 1 ]; then
+ echo "usage: $0 root_path"
+fi
+
+root_path="$1"
+
+#resolution=960x720 # HD
+resolution=800x600 # SD
+
+(
+IFS=$'\n'
+for filename in $(find "$root_path" -name '*.mts'); do
+ new_filename=$(dirname "$filename")/$(basename "$filename" .mts)_SD.mp4
+ rm "$new_filename"
+ ./ffmpeg-mts2mp4-custom "$filename" "$new_filename" $resolution 700k
+done
+)
--- /dev/null
+#!/bin/bash
+#
+# Calin-Andrei Burloiu, 2010, calin.burloiu@gmail.com
+#
+# This script converts an MTS file into an AVI file, which
+# contains an H.264 video stream and and an MP3 audio stream.
+#
+
+if test $# -ne 2; then
+ echo "Usage: $0 mts-file avi-file"
+ exit 1
+fi
+
+MTS_FILE="$1"
+AVI_FILE="$2"
+FFMPEG=/usr/bin/ffmpeg
+
+if test ! -f "$MTS_FILE"; then
+ echo "Error: No such: file $MTS_FILE"
+ exit 1
+fi
+
+$FFMPEG -i "$MTS_FILE" -f avi -acodec libmp3lame -ab 256k -ar 44100 -ac 2 -vcodec libx264 -vpre normal -b 1400k -r 25 -threads 0 "$AVI_FILE"
+
--- /dev/null
+#!/bin/bash
+#
+# Calin-Andrei Burloiu, 2010, calin.burloiu@gmail.com
+#
+# This script converts an MTS file into an AVI file, which
+# contains an H.264 video stream and and an MP3 audio stream.
+#
+
+if test $# -ne 4; then
+ echo "Usage: $0 mts-file avi-file resolution bitrate"
+ exit 1
+fi
+
+MTS_FILE="$1"
+AVI_FILE="$2"
+RESOLUTION="$3"
+BITRATE="$4"
+FFMPEG=/usr/bin/ffmpeg
+
+if test ! -f "$MTS_FILE"; then
+ echo "Error: No such: file $MTS_FILE"
+ exit 1
+fi
+
+$FFMPEG -i "$MTS_FILE" -f avi -acodec libmp3lame -ab 256k -ar 44100 -ac 2 -vcodec libx264 -vpre normal -b "$BITRATE" -r 25 -s $RESOLUTION -threads 0 "$AVI_FILE"
+
--- /dev/null
+#!/bin/bash
+#
+# Calin-Andrei Burloiu, 2010, calin.burloiu@gmail.com
+#
+# This script converts an MTS file into an AVI file, which
+# contains an H.264 video stream and and an MP3 audio stream.
+#
+
+if test $# -ne 3; then
+ echo "Usage: $0 mts-file avi-file resolution"
+ exit 1
+fi
+
+MTS_FILE="$1"
+AVI_FILE="$2"
+RESOLUTION="$3"
+FFMPEG=/usr/bin/ffmpeg
+
+if test ! -f "$MTS_FILE"; then
+ echo "Error: No such: file $MTS_FILE"
+ exit 1
+fi
+
+$FFMPEG -i "$MTS_FILE" -f flv -acodec libmp3lame -ab 256k -ar 44100 -ac 2 -vcodec libx264 -vpre normal -b 1400k -r 25 -s $RESOLUTION -threads 0 "$AVI_FILE"
+
--- /dev/null
+#!/bin/bash
+#
+# Calin-Andrei Burloiu, 2010, calin.burloiu@gmail.com
+#
+# This script converts an MTS file into an AVI file, which
+# contains an H.264 video stream and and an MP3 audio stream.
+#
+
+if test $# -ne 4; then
+ echo "Usage: $0 mts-file avi-file resolution bitrate"
+ exit 1
+fi
+
+MTS_FILE="$1"
+AVI_FILE="$2"
+RESOLUTION="$3"
+BITRATE="$4"
+FFMPEG=/usr/bin/ffmpeg
+
+if test ! -f "$MTS_FILE"; then
+ echo "Error: No such: file $MTS_FILE"
+ exit 1
+fi
+
+$FFMPEG -i "$MTS_FILE" -f mp4 -acodec libmp3lame -ab 192k -ar 44100 -ac 2 -vcodec libx264 -vpre normal -b "$BITRATE" -r 25 -s "$RESOLUTION" -threads 0 "$AVI_FILE"
+
--- /dev/null
+#!/bin/bash
+#
+# Calin-Andrei Burloiu, 2010, calin.burloiu@gmail.com
+#
+# This script converts an MTS file into an WebM file, which
+# contains a V8 video stream and and a Vorbis audio stream.
+#
+
+if test $# -ne 2; then
+ echo "Usage: $0 mts-file avi-file"
+ exit 1
+fi
+
+MTS_FILE="$1"
+AVI_FILE="$2"
+FFMPEG=/usr/bin/ffmpeg
+
+if test ! -f "$MTS_FILE"; then
+ echo "Error: No such file $MTS_FILE"
+ exit 1
+fi
+
+$FFMPEG -i "$MTS_FILE" -f ogg -acodec libvorbis -ab 256k -ar 44100 -ac 2 -vcodec libtheora -b 1400k -r 25 -threads 0 "$AVI_FILE"
+
--- /dev/null
+#!/bin/bash
+#
+# Calin-Andrei Burloiu, 2010, calin.burloiu@gmail.com
+#
+# This script converts an MTS file into an WebM file, which
+# contains a V8 video stream and and a Vorbis audio stream.
+#
+
+if test $# -ne 4; then
+ echo "Usage: $0 mts-file avi-file resolution bitrate"
+ exit 1
+fi
+
+MTS_FILE="$1"
+AVI_FILE="$2"
+RESOLUTION="$3"
+BITRATE="$4"
+FFMPEG=/usr/bin/ffmpeg
+
+if test ! -f "$MTS_FILE"; then
+ echo "Error: No such file $MTS_FILE"
+ exit 1
+fi
+
+$FFMPEG -i "$MTS_FILE" -f ogg -acodec libvorbis -ab 256k -ar 44100 -ac 2 -vcodec libtheora -b "$BITRATE" -r 25 -s $RESOLUTION -threads 0 "$AVI_FILE"
+
--- /dev/null
+#!/bin/bash
+#
+# Calin-Andrei Burloiu, 2010, calin.burloiu@gmail.com
+#
+# This script converts an MTS file into an AVI file, which
+# contains an H.264 video stream and and an MP3 audio stream.
+#
+
+if test $# -ne 4; then
+ echo "Usage: $0 mts-file ts-file bitrate resolution"
+ exit 1
+fi
+
+MTS_FILE="$1"
+TS_FILE="$2"
+BITRATE="$3"
+RESOLUTION="$4"
+FFMPEG=/usr/bin/ffmpeg
+
+if test ! -f "$MTS_FILE"; then
+ echo "Error: No such: file $MTS_FILE"
+ exit 1
+fi
+
+$FFMPEG -i "$MTS_FILE" -f mpegts -acodec libmp3lame -ab 128k -ar 44100 -ac 2 -vcodec libx264 -vpre normal -b "$BITRATE" -r 25 -s $RESOLUTION -threads 0 "$TS_FILE"
--- /dev/null
+#!/bin/bash
+#
+# Calin-Andrei Burloiu, 2010, calin.burloiu@gmail.com
+#
+# This script converts an MTS file into an WebM file, which
+# contains a V8 video stream and and a Vorbis audio stream.
+#
+
+if test $# -ne 2; then
+ echo "Usage: $0 mts-file avi-file"
+ exit 1
+fi
+
+MTS_FILE="$1"
+AVI_FILE="$2"
+FFMPEG=/usr/bin/ffmpeg
+
+if test ! -f "$MTS_FILE"; then
+ echo "Error: No such file $MTS_FILE"
+ exit 1
+fi
+
+$FFMPEG -i "$MTS_FILE" -f webm -acodec libvorbis -ab 256k -ar 44100 -ac 2 -vcodec libvpx -b 1400k -r 25 -threads 0 "$AVI_FILE"
+
--- /dev/null
+#!/bin/bash
+#
+# Calin-Andrei Burloiu, 2010, calin.burloiu@gmail.com
+#
+# This script transcodes all input videos with a specified extension to a new
+# format with a given resolutin and video bitrate. The audio bitrate is hard
+# coded to 192 kb/s. The output_path parameter is optional. If not given it
+# puts all output files in the same folder as the corresponding input.
+#
+
+if test $# -lt 4; then
+ echo "Usage: $0 input-path input-extension output-format resolution video-bitrate [output-suffix] [output_path]"
+ exit 1
+fi
+
+in_path="$1"
+in_ext="$2"
+out_format="$3"
+resolution="$4"
+bitrate="$5"
+if [ ! -z "$6" ]; then
+ out_suffix="$6"
+else
+ out_suffix=""
+fi
+if [ ! -z "$7" ]; then
+ out_path="$7"
+fi
+
+FFMPEG=/usr/bin/ffmpeg
+ABITRATE=192k
+
+(
+IFS=$'\n'
+for filename in $(find "$in_path" -name "*.$in_ext"); do
+ if [ ! -z "$out_path" ]; then
+ new_filename="${out_path}"$(basename "$filename" ."$in_ext")"$out_suffix"."$out_format"
+ else
+ new_filename=$(dirname "$filename")/$(basename "$filename" ."$in_ext")"$out_suffix"."$out_format"
+ fi
+
+ case "$out_format" in
+ "avi" )
+ $FFMPEG -i "$filename" -f avi -acodec libmp3lame -ab $ABITRATE -ar 44100 -ac 2 -vcodec libx264 -vpre normal -b "$bitrate" -r 25 -s $resolution -threads 0 "$new_filename"
+ ;;
+ "flv" )
+ $FFMPEG -i "$filename" -f flv -acodec libmp3lame -ab $ABITRATE -ar 44100 -ac 2 -vcodec libx264 -vpre normal -b "$bitrate" -r 25 -s $resolution -threads 0 "$new_filename"
+ ;;
+ "mp4" )
+ $FFMPEG -i "$filename" -f mp4 -acodec libmp3lame -ab $ABITRATE -ar 44100 -ac 2 -vcodec libx264 -vpre normal -b "$bitrate" -r 25 -s "$resolution" -threads 0 "$new_filename"
+ ;;
+ "ogg" )
+ $FFMPEG -i "$filename" -f ogg -acodec libvorbis -ab $ABITRATE -ar 44100 -ac 2 -vcodec libtheora -b "$bitrate" -r 25 -s $resolution -threads 0 "$new_filename"
+ ;;
+ "webm" )
+ $FFMPEG -i "$filename" -f webm -acodec libvorbis -ab $ABITRATE -ar 44100 -ac 2 -vcodec libvpx -b "$bitrate" -r 25 -s $resolution -threads 0 "$new_filename"
+ ;;
+ "ts" )
+ $FFMPEG -i "$filename" -f mpegts -acodec libmp3lame -ab $ABITRATE -ar 44100 -ac 2 -vcodec libx264 -vpre normal -b "$bitrate" -r 25 -s $resolution -threads 0 "$new_filename"
+ ;;
+
+ * )
+ echo "Format $out_format is not implemented!" 1>&2
+ exit 1
+ ;;
+ esac
+
+done
+)