diff options
-rw-r--r-- | tools/audio_bitrate | 14 | ||||
-rw-r--r-- | tools/audio_format | 14 | ||||
-rw-r--r-- | tools/duration | 14 | ||||
-rw-r--r-- | tools/extract_audio | 18 | ||||
-rw-r--r-- | tools/merge_audio_stereo_track | 33 | ||||
-rw-r--r-- | tools/merge_av | 17 | ||||
-rw-r--r-- | tools/split_audio | 24 | ||||
-rw-r--r-- | tools/takk_til | 13 |
8 files changed, 147 insertions, 0 deletions
diff --git a/tools/audio_bitrate b/tools/audio_bitrate new file mode 100644 index 0000000..65ff6ee --- /dev/null +++ b/tools/audio_bitrate @@ -0,0 +1,14 @@ +#!/bin/bash +# +# Date: 2009-11-30 +# Author: Ole Kristian Lien +# License: GNU General Public License +# +# Grabs audio bitrate from audio/video-file + +if [ -z "$1" ]; then + echo "Usage: $0 <audio/video-file>" + exit 1 +fi + +ffmpeg -i $1 2>&1 | grep Audio | cut -d "," -f 5 | cut -d " " -f 2 diff --git a/tools/audio_format b/tools/audio_format new file mode 100644 index 0000000..a96348c --- /dev/null +++ b/tools/audio_format @@ -0,0 +1,14 @@ +#!/bin/bash +# +# Date: 2009-11-30 +# Author: Ole Kristian Lien +# License: GNU General Public License +# +# Grabs audio format from audio/video-file + +if [ -z "$1" ]; then + echo "Usage: $0 <audio/video-file>" + exit 1 +fi + +ffmpeg -i $1 2>&1 | grep Audio | cut -d " " -f 8 | sed 's/,//g' diff --git a/tools/duration b/tools/duration new file mode 100644 index 0000000..797eeb4 --- /dev/null +++ b/tools/duration @@ -0,0 +1,14 @@ +#!/bin/bash +# +# Date: 2009-11-30 +# Author: Ole Kristian Lien +# License: GNU General Public License +# +# Grabs duration from audio/video-file + +if [ -z "$1" ]; then + echo "Usage: $0 <audio/video-file>" + exit 1 +fi + +ffmpeg -i $1 2>&1 | grep "Duration" | cut -d ' ' -f 4 | sed s/,// | cut -d "." -f1 diff --git a/tools/extract_audio b/tools/extract_audio new file mode 100644 index 0000000..26a8588 --- /dev/null +++ b/tools/extract_audio @@ -0,0 +1,18 @@ +#!/bin/bash +# +# Date: 2009-11-30 +# Author: Ole Kristian Lien +# License: GNU General Public License +# +# Extract audio from video-file + +EXT=`echo "$1"|awk -F . '{print $NF}'` +NAME=`basename $1 .$EXT` +FORMAT=`./audio_format $1` + +if [ -z "$1" ]; then + echo "Usage: $0 <video-file>" + exit 1 +fi + +ffmpeg -i $1 -vn -acodec copy $NAME.$FORMAT 2> /dev/null diff --git a/tools/merge_audio_stereo_track b/tools/merge_audio_stereo_track new file mode 100644 index 0000000..2cf5f64 --- /dev/null +++ b/tools/merge_audio_stereo_track @@ -0,0 +1,33 @@ +#!/bin/bash +# +# Date: 2009-11-30 +# Author: Ole Kristian Lien +# License: GNU General Public License +# +# Merge audio stereo track from video + +EXT=`echo "$1"|awk -F . '{print $NF}'` +NAME=`basename $1 .$EXT` +AFORMAT=`./audio_format $1` + +if [ -z "$1" ]; then + echo "Usage: $0 <video-file>" + exit 1 +fi + +echo "Processing $1:" + +echo -n " * Extracting audio..." +./extract_audio $1 +echo -e "OK" + +echo -n " * Splitting up audio..." +./split_audio $NAME.$AFORMAT +echo -e "OK" + +echo -n " * Merging new audio with video..." +./merge_av $NAME-new.$AFORMAT $1 +echo -e "OK" + +rm $1 $NAME.$AFORMAT $NAME-new.$AFORMAT +mv $NAME-new.$EXT $1 diff --git a/tools/merge_av b/tools/merge_av new file mode 100644 index 0000000..6b5bdaa --- /dev/null +++ b/tools/merge_av @@ -0,0 +1,17 @@ +#!/bin/bash +# +# Date: 2009-11-30 +# Author: Ole Kristian Lien +# License: GNU General Public License +# +# Merge audio and video + +EXT=`echo "$2"|awk -F . '{print $NF}'` +NAME=`basename $2 .$EXT` + +if [ -z "$2" ]; then + echo "Usage: $0 <audio-file> <video-file>" + exit 1 +fi + +ffmpeg -i $1 -i $2 -map 1:0 -map 0:0 -acodec copy -vcodec copy $NAME-new.$EXT 2> /dev/null diff --git a/tools/split_audio b/tools/split_audio new file mode 100644 index 0000000..4e97221 --- /dev/null +++ b/tools/split_audio @@ -0,0 +1,24 @@ +#!/bin/bash +# +# Date: 2009-11-30 +# Author: Ole Kristian Lien +# License: GNU General Public License +# +# Splits stereo channel into left and right, then +# combines them back into an audio file (stereo) + +BITRATE=`./audio_bitrate $1` +EXT=`echo "$1"|awk -F . '{print $NF}'` +NAME=`basename $1 .$EXT` + +if [ -z "$1" ]; then + echo "Usage: $0 <audio-file>" + exit 1 +fi + +sox $1 -c 1 left.wav mixer -l 2> /dev/null +sox $1 -c 1 right.wav mixer -r 2> /dev/null +sox -m left.wav right.wav mono.wav 2> /dev/null +sox mono.wav -c 2 stereo.wav 2> /dev/null +ffmpeg -i stereo.wav -acodec $EXT -ab "$BITRATE"k $NAME-new.$EXT 2> /dev/null +rm left.wav right.wav mono.wav stereo.wav diff --git a/tools/takk_til b/tools/takk_til new file mode 100644 index 0000000..900e222 --- /dev/null +++ b/tools/takk_til @@ -0,0 +1,13 @@ +#!/bin/bash +FONT="/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-Bold.ttf" + +if [ $# -gt 2 ]; then + convert -font $FONT -size 1440x1080 xc:black \ + -fill white -gravity center -pointsize 60 -draw "text 0,0 '${1}'" \ + -fill white -gravity center -pointsize 40 -draw "text 0,60 '${2}'" \ + -append ${3}.png +else + convert -font $FONT -size 1440x1080 xc:black \ + -fill white -gravity center -pointsize 60 -draw "text 0,0 '${1}'" \ + -append ${2}.png +fi |