Blame view

tools/scripts/ExtractAudioFromTV.sh 1.03 KB
1fd315c89   Jean-François Rey   add Extract audio...
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
  #!/bin/bash
  
  # File : ExtractAudioFromTV.sh
  # Brief : extract audio file and subtitle from TV corpus
  # version 1.0
  #
  
  ### ExtractAudioFromCorpus.sh INA-TV2 MYTV
  
  if [ $(($#-($OPTIND-1))) -ne 2 ]
  then
      echo "BAD USAGE : $0 <INPUT_DIRECTORY> <OUTPUT_DIRECTORY>"
      exit 1
  fi
  
  if [ -e $1 ]
  then
      IN=$(readlink -e $1)
  else
      echo "ERROR : Can't read input $1"
      exit 1
  fi
  
  if [ -e $2 ]
  then
      OUT=$(readlink -e $2)
  else
      echo "ERROR : Can't read  OUTPUT $2"
      exit 1
  fi
  
  
  for f in `ls $IN`
  do
      channel=`echo $f | sed -re 's/NAS_//'`
      mkdir $OUT/$channel
      cd $f
      for d in `ls $f`
      do
          for file in `ls ${f}/${d} | grep MP4`
          do
              avconv -i ${IN}/${f}/${d}/${file} -threads 4 -vn -f wav -ac 1 -ar 16000 -ab 256000 ${OUT}/${channel}/${d}_$(basename ${file} .MP4).wav
              if [ -e ${IN}/${f}/${d}/$(basename ${file} .MP4).SRT ]
              then
                  cp ${IN}/${f}/${d}/$(basename ${file} .MP4).SRT ${OUT}/${channel}/${d}_$(basename ${file} .MP4).SRT
              fi
          done
      done
  done