Tricks when using avconv (+ avprobe)

Tricks when using avconv (+ avprobe)

Show differences in sync:

(how much video is before audio)

avprobe -v quiet -show_streams $1 | grep start_time | awk -F= '{a[NR]=$2} END {printf "%f ",a[1]-a[2]}'

# use with xargs:
find *.mp4 -type f -print0 | xargs -0 -I {} ./process.sh {}

## process.sh

# extract audio, 1 channel
in=$1
root=${in%.*}
avconv -i $1 -c:a pcm_s16le -ac 1 ../bidrag4/$root.wav
# with resampling:
#avconv -i $1 -c:a pcm_s16le -ac 1 -ar 16000 ../bidrag3/$root.wav

# sync audio and video ( http://lzone.de/fix%20async%20video%20with%20ffmpeg )
# when audio is ahead of video
#avconv -async 1 -i $1 -s 1024x576 -c:v libx264 ../bidrag2/$1

# print difference; if negative, audio is ahead
#avprobe -v quiet -show_streams $1 | grep start_time | awk -F= '{a[NR]=$2} END {printf "%f ",a[1]-a[2]}'
#echo $1

# how to copy them ( paths are just examples )
#rsync --progress *.wav /mnt/SOL/MuMoP/Klippta\ sändningar/dest_dir