summaryrefslogtreecommitdiffstats
path: root/tools/audio_extract
blob: ee3c96f52849f7d6d2181f68b2da5b96fa2f1d04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
#
# Date:    2009-12-16
# 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> [<start-pos> <duration>]"
	exit 1
fi

#if [ "$FORMAT" == "pcm_s16le" ]; then
#	FORMAT="wav"
#fi

echo "Extracting $NAME.$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