Added some new scripts
authorAlan J. Pippin <alan@pippins.net>
Wed, 7 Jan 2015 05:42:38 +0000 (22:42 -0700)
committerAlan J. Pippin <ajp@pippins.net>
Wed, 7 Jan 2015 05:42:38 +0000 (22:42 -0700)
mkv2avi [new file with mode: 0755]
mkv2mp4small [new file with mode: 0755]
mp4tomp3 [new file with mode: 0755]

diff --git a/mkv2avi b/mkv2avi
new file mode 100755 (executable)
index 0000000..996a376
--- /dev/null
+++ b/mkv2avi
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+INPUT=$1
+OUTPUT_DIR=$2
+
+if [ -z "$OUTPUT_DIR" ]; then
+    OUTPUT_DIR="."
+fi
+
+FILENAME=`basename ${INPUT%%.*}`
+OUTPUT="$OUTPUT_DIR/$FILENAME.avi"
+
+echo "-> Converting $INPUT to 480p downscaled $OUTPUT file"
+
+if [[ -e "$OUTPUT" ]]; then
+  echo "-E- Output file $OUTPUT already exists. Aborting..."
+  exit 1
+fi
+
+# scale=720:-2 
+# profile=asp5
+
+mencoder \
+  -mc 0 \
+  -noskip \
+  -vf expand=:::::16/9,hqdn3d,harddup,scale=720:-2 \
+  -ovc xvid -oac mp3lame \
+  -xvidencopts fixed_quant=3.8:me_quality=6:noqpel:nogmc:trellis:chroma_me:chroma_opt:hq_ac:vhq=4:lumi_mask:max_key_interval=300:quant_type=mpeg:max_bframes=2:closed_gop:nopacked:autoaspect:bvhq=1:threads=4 \
+  -lameopts vbr=2:q=1:aq=2 \
+  -o $OUTPUT $INPUT
+
+echo "-> DONE!!!"
+
diff --git a/mkv2mp4small b/mkv2mp4small
new file mode 100755 (executable)
index 0000000..463c3d3
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+# step 1: convert the mkv to mpg ; many mkv files do not directly get converted to mp4
+mencoder "$1" -ovc lavc -lavcopts vcodec=mpeg1video -aid 0 -oac pcm -o delete_me.mpg
+
+# step 2: convert the mpg file to mp4
+mencoder -of lavf -lavfopts format=mp4 -oac lavc -ovc lavc -lavcopts \
+aglobal=1:vglobal=1:acodec=libfaac:vcodec=mpeg4:abitrate=128:vbitrate=640:keyint=250:mbd=1:vqmax=10:lmax=10:turbo  -af lavcresample=44100 \
+-vf harddup,scale=640:-3 "delete_me.mpg" -o "$1.mp4"
+
+# step 3: delete the temporary huge sized mpg file 
+rm "delete_me.mpg"
diff --git a/mp4tomp3 b/mp4tomp3
new file mode 100755 (executable)
index 0000000..ca69306
--- /dev/null
+++ b/mp4tomp3
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+INPUT=$1
+START=$2
+STOP=$3
+
+if [[ -n $START ]]; then
+  START="-ss $START"
+fi
+
+if [[ -n $STOP ]]; then
+  STOP="-t $STOP"
+fi
+
+if [[ -z INPUT ]]; then
+  echo "usage: $0 <input> [<start> <stop>]"
+fi
+
+ffmpeg $START $STOP -i $INPUT -acodec libmp3lame -ab 128k $INPUT.mp3