diff options
-rw-r--r-- | tools/audio_extract | 26 | ||||
-rwxr-xr-x | tools/audio_split | 2 | ||||
-rwxr-xr-x | tools/audio_stats | 2 | ||||
-rwxr-xr-x | tools/convert2mp3 | 32 | ||||
-rw-r--r-- | tools/convert2vorbis | 12 | ||||
-rwxr-xr-x | tools/image_extract | 32 | ||||
-rw-r--r-- | tools/process-video | 9 |
7 files changed, 91 insertions, 24 deletions
diff --git a/tools/audio_extract b/tools/audio_extract index 2c040ea..a37bcdf 100644 --- a/tools/audio_extract +++ b/tools/audio_extract @@ -15,20 +15,26 @@ if [ -z "$1" ]; then exit 1 fi -./require ffmpeg +./require ffmpeg || { exit 1; } + #if [ "$FORMAT" == "pcm_s16le" ]; then # FORMAT="wav" #fi -echo -n " * Extracting audio ($FORMAT)..." +if [ ! -f $BASENAME.wav ]; then + echo " * File $BASENAME.wav does not exists:" + echo -n " * Extracting audio ($FORMAT)..." + + if [ "$3" ]; then + #DURATION="30" #`./duration$1` + DURATION="$3" + #echo "start: $2 - Dur: $DURATION" + ffmpeg -i $1 -ss $2 -t $DURATION -vn -acodec copy $NAME.$FORMAT 2> /dev/null + else + ffmpeg -i $1 -vn -acodec copy $NAME.$FORMAT 2> /dev/null + fi -if [ "$3" ]; then - #DURATION="30" #`./duration$1` - DURATION="$3" - #echo "start: $2 - Dur: $DURATION" - ffmpeg -i $1 -ss $2 -t $DURATION -vn -acodec copy $NAME.$FORMAT 2> /dev/null + echo -e "OK!" else - ffmpeg -i $1 -vn -acodec copy $NAME.$FORMAT 2> /dev/null + echo " * File $BASENAME.wav already exists." fi - -echo -e "OK!" diff --git a/tools/audio_split b/tools/audio_split index 8ccd089..3fff16e 100755 --- a/tools/audio_split +++ b/tools/audio_split @@ -14,7 +14,7 @@ if [ -z "$1" ]; then exit 1 fi -./require sox +./require sox || { exit 1; } # sox FAIL formats: can't open output file `1-left.mp2': SoX was compiled without MP3 encoding support # kan ikke encode til mp{2,3}... diff --git a/tools/audio_stats b/tools/audio_stats index f6e9ccc..596a317 100755 --- a/tools/audio_stats +++ b/tools/audio_stats @@ -11,7 +11,7 @@ if [ -z "$1" ]; then exit 1 fi -./require sox +./require sox || { exit 1; } echo -n " * Generating audio statistics for $1..." sox $1 -n stat diff --git a/tools/convert2mp3 b/tools/convert2mp3 new file mode 100755 index 0000000..6ef59f1 --- /dev/null +++ b/tools/convert2mp3 @@ -0,0 +1,32 @@ +#!/bin/bash +# +# Date: 2010-01-15 +# Author: Ole Kristian Lien +# License: GNU General Public License +# +# Convert the sound from the video to mp3. + + +EXT=`echo "$1"|awk -F . '{print $NF}'` +BASENAME=`basename $1 .$EXT` + +BITRATE="64" + +if [ -z "$1" ]; then + echo "Usage: $0 <video-file> [<audio-quality>]" + exit 1 +fi + +./require lame || { exit 1; } +./audio_extract $1 + +echo -n " * Generating $BASENAME.mp3 ($BITRATE kbps)..." + +if [ "$2" ]; then + $BITRATE=$2 +fi + +lame -b $BITRATE -a "$BASENAME.wav" "$BASENAME.mp3" > \ +"$BASENAME.mp3-compresslog" 2>&1 + +echo -e "OK!" diff --git a/tools/convert2vorbis b/tools/convert2vorbis index 2a7b2d2..61621c5 100644 --- a/tools/convert2vorbis +++ b/tools/convert2vorbis @@ -17,14 +17,10 @@ if [ -z "$1" ]; then exit 1 fi -./require oggenc # vorbis-tools +./require oggenc || { exit 1; } # vorbis-tools +./audio_extract $1 -if [ ! -f $BASENAME.wav ]; then - echo "File $BASENAME.wav does not exists" - ./audio_extract $1 -fi - -echo "Generating $BASENAME.ogg ($BITRATE kbps)..." +echo -n " * Generating $BASENAME.ogg ($BITRATE kbps)..." # --downmix #Downmix stereo to mono. Only allowed on stereo input. @@ -36,3 +32,5 @@ fi oggenc "$BASENAME.wav" --downmix -b $BITRATE \ 2>&1 + +echo -e "OK!" diff --git a/tools/image_extract b/tools/image_extract new file mode 100755 index 0000000..c1bf633 --- /dev/null +++ b/tools/image_extract @@ -0,0 +1,32 @@ +#!/bin/bash +# +# Date: 2010-01-15 +# Author: Ole Kristian Lien +# License: GNU General Public License +# +# Extract thumbnail from video + +EXT=`echo "$1"|awk -F . '{print $NF}'` +BASENAME=`basename $1 .$EXT` +DURATION=`./duration $1` +OLD_IFS="$IFS" +IFS=":" +TIME=( $DURATION ) +IFS="$OLD_IFS" +TOTAL=`echo "(${TIME[0]} * 3600) + (${TIME[1]} * 60) + ${TIME[2]}" | bc` +let SECOND=$RANDOM%$TOTAL+1 + +if [ -z "$1" ]; then + echo "Usage: $0 <video-file>" + exit 1 +fi + +if [ -f $BASENAME.jpg ] ; then + echo " * Image thumbnail already exist." + exit 1 +fi + +echo -n " * Extracting image thumbnail from video (frame $SECOND s)..." +ffmpeg -itsoffset -$SECOND -i $1 -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 $BASENAME.jpg \ +> "$BASENAME.jpg-compresslog" 2>&1 +echo -e "OK!" diff --git a/tools/process-video b/tools/process-video index 1c7e5cf..0e6a8f2 100644 --- a/tools/process-video +++ b/tools/process-video @@ -24,7 +24,6 @@ fi ./audio_channels_diff $1 if [ "${?}" == "3" ] ; then -# echo "should run ./merge_audio_stereo_track $1...neh.." ./merge_audio_stereo_track $1 fi @@ -37,8 +36,8 @@ fi ./audio_check_volume $NAME.wav VOLUME=`cat $NAME.wav.vol` ./audio_gain_volume $NAME.wav $VOLUME -./audio_check_noise $NAME.wav -./audio_remove_noise $NAME.wav +#./audio_check_noise $NAME.wav +#./audio_remove_noise $NAME.wav ##./audio_spectrogram $NAME.wav ./merge_av $NAME.wav $1 @@ -47,7 +46,7 @@ rm $NAME.wav $NAME-old.wav $NAME.wav.vol $NAME.noise-profile echo -e "OK!" #### Denn maa inn igjen #### -rm $NAME-old.dv +#rm $NAME-old.dv #### ## mv fade video/image_fade @@ -70,4 +69,4 @@ rm $NAME-intro.$EXT $NAME-outro.$EXT $NAME-temp.dv ##./convert2vorbis $1 ##./metadata $NAME.ogg $2 -scp $1 oklien@nerdhaven.nuug.no:/data/video/raw/ +#scp $1 oklien@nerdhaven.nuug.no:/data/video/raw/ |