audio_video_transcode () { local VIDEO_SRC="$1" local VIDEO_DST="$2" local VIDEO_FPS="$3" local VIDEO_GEOMETRY="$4" local TEMPORARY=`tempfile` # touch $TEMPORARY # # Get video MPEG-2. # ffmpeg -i $VIDEO_SRC -f mpeg2video \ -hq \ -sameq \ -r $VIDEO_FPS \ -s $VIDEO_GEOMETRY \ $TEMPORARY.m2v # # Get audio WAV if any audio exist. # ffmpeg -i $VIDEO_SRC -f wav $TEMPORARY.wav # if ! [ -s $TEMPORARY.wav ] then # # Create a silent audio track of 1/30 s. # dd if="/dev/zero" bs=4 count=1600 | \ sox -t .raw -s -w -c 2 -r 48000 - $TEMPORARY.wav fi # # Resample with Sox, fixing a stereo output. # if sox $TEMPORARY.wav -w \ -r 48000 \ -c 2 \ $TEMPORARY.48.wav \ resample then # # It worked with resample. # true # else sox $TEMPORARY.wav -w \ -r 48000 \ -c 2 \ $TEMPORARY.48.wav fi # # Make a new, uniform, MP2 audio file. # toolame -b 128 $TEMPORARY.48.wav $TEMPORARY.mp2 # # Remultiplex video and audio for DVD. # mplex -f 8 -V -o $VIDEO_DST \ $TEMPORARY.m2v \ $TEMPORARY.mp2 # # Remove temporary files. # rm -f $TEMPORARY* }