- Major code rewrite,
- New command line interface, - Major args reorganisation, - New video quality presetings (vqual).
This commit is contained in:
parent
56bb6c5d46
commit
cdde792c6d
307
dvd2divx
307
dvd2divx
@ -2,12 +2,12 @@
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# DVD2DivX
|
||||
#
|
||||
# (C) 2004-2008 Arnaud G. Gibert
|
||||
# (C) 2004-2009 Arnaud G. Gibert
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# $RCSfile: dvd2divx,v $
|
||||
# $Revision: 1.5 $
|
||||
# $Revision: 1.6 $
|
||||
# $Name: $
|
||||
# $Date: 2008/10/07 10:11:04 $
|
||||
# $Date: 2009/01/06 00:16:22 $
|
||||
# $Author: agibert $
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -32,38 +32,37 @@
|
||||
# Usage exemple
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# #!/bin/bash
|
||||
# # dvd_device divx_root divx_title dvd_title chapter angle alang slang vcodec vbr abr xsize aspect stereo asrate deint buffer apass vpass threads
|
||||
# #-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
#
|
||||
# # Read only
|
||||
# dvd2divx /dev/cdrom1 cobra 1 10 1- 1 fr - - - - - - - - - o - - -
|
||||
#
|
||||
# # Don't read, compress only
|
||||
# dvd2divx - cobra 1 - - - - - xvid 1000 128 480 4/3 n - y s y 2 4
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# # divx_root divx_title input dvd_device dvd_title chapter angle alang slang audio abr asrate stereo video vcodec vqual vbr xsize aspect deint threads
|
||||
# #--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
# dvd2divx cobra 1 dbo /dev/dvd0 10 1- 1 fr - - - - - - - - - - - - -
|
||||
# dvd2divx cobra 1 b - - - - - - fvp 128 - n 2a xvid 3 1000 480 4/3 y 4
|
||||
|
||||
|
||||
dvd_device=$1 # -|/dev/dvd|...
|
||||
divx_root=$2
|
||||
divx_title=$3
|
||||
title=$4
|
||||
chapter=$5
|
||||
angle=$6
|
||||
alang=$7 # en|fr|...
|
||||
slang=$8 # -|en|fr|...
|
||||
vcodec=$9 # -|lavc|xvid
|
||||
vbr=${10}
|
||||
abr=${11}
|
||||
xsize=${12} # -|...
|
||||
aspect=${13} # -|4/3|16/9|...
|
||||
stereo=${14} # y|n
|
||||
asrate=${15} # -|xxx (resample audio)
|
||||
deint=${16} # y|n
|
||||
bufferize=${17} # o|y|n|s (only: bufferize and stop | yes: bufferize an continue | no: read directly from disk | skip: bufferize previously done)
|
||||
apass=${18} # o|y|n|s (only: compress and stop | yes: compress and continue | no: compress mp3 whith video | skip: mp3 previously compressed)
|
||||
vpass=${19} # 1|2
|
||||
threads=${20} # -|1..
|
||||
|
||||
divx_root=${1} #
|
||||
divx_title=${2} #
|
||||
#------------------------------------------------------------------------------
|
||||
input=${3} # d|db|dbo|b (d: read directly from disk | db: bufferize and continue | dbo: bufferize only | b: read from a preexisting buffer)
|
||||
dvd_device=${4} # -|/dev/dvd|...
|
||||
title=${5} #
|
||||
chapter=${6} #
|
||||
angle=${7} #
|
||||
alang=${8} # en|fr|...
|
||||
slang=${9} # -|en|fr|...
|
||||
#------------------------------------------------------------------------------
|
||||
audio=${10} # ap|avp|fvp|n (ap: compress audio during audio pass | avp: compress audio during all video pass | fvp: compress audio during final video pass|no: use input audio stream)
|
||||
abr=${11} #
|
||||
asrate=${12} # -|xxx (resample audio)
|
||||
stereo=${13} # y|n
|
||||
#------------------------------------------------------------------------------
|
||||
video=${14} # 1|2a|2s|n (1: compress video in 1 pass | 2a: compress video in 2 assymetric passes | 2s: compress video in 2 symetric passes | no: use input video stream)
|
||||
vcodec=${15} # -|lavc|xvid
|
||||
vquality=${16} # 0|1|2|... (0: realtime | 1: fast | 2: High quality | 3: very high quality)
|
||||
vbr=${17} #
|
||||
xsize=${18} # -|...
|
||||
aspect=${19} # -|4/3|16/9|...
|
||||
deint=${20} # y|n
|
||||
threads=${21} # -|1..
|
||||
|
||||
|
||||
|
||||
@ -74,11 +73,19 @@ divx_name=../$divx_root-$divx_title.avi
|
||||
tmp_name=../$divx_root-$divx_title.vob
|
||||
out_name=../$divx_root-$divx_title
|
||||
|
||||
echo "device: [$dvd_device] DivX: [$divx_name] title: ($title) chapter: ($chapter) angle: ($angle) alang: ($alang) slang: ($slang)"
|
||||
echo "vcodec: [$vcodec] vbr: ($vbr) abr: ($abr) xsize: ($xsize) aspect: ($aspect) stereo: ($stereo) asrate: ($asrate) deint: ($deint)"
|
||||
echo "bufferize: ($bufferize) apass: ($apass) vpass: ($vpass) threards: ($threads)"
|
||||
echo "DivX: [$divx_name] title: ($title)"
|
||||
echo "Input: [$input] device: [$dvd_device] title: ($title) chapter: ($chapter) angle: ($angle) alang: ($alang) slang: ($slang)"
|
||||
echo "Audio: [$audio] abr: ($abr) asrate: ($asrate) stereo: ($stereo)"
|
||||
echo "Video: [$video] vcodec: [$vcodec] vquality: [$vquality] vbr: ($vbr) xsize: ($xsize) aspect: ($aspect) deint: ($deint) threards: ($threads)"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# DVDRip Setup
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
if [ "$dvd_device" != "-" ]
|
||||
then
|
||||
device_opt="-dvd-device $dvd_device"
|
||||
@ -91,6 +98,44 @@ else
|
||||
slang_opt="-slang $slang -vobsubout $out_name -vobsuboutid $slang -vobsuboutindex 0"
|
||||
fi
|
||||
|
||||
read_dvd_opt="$device_opt dvd://$title -chapter $chapter -dvdangle $angle -alang $alang $slang_opt"
|
||||
read_buf_opt="$tmp_name"
|
||||
|
||||
case "$input"
|
||||
in
|
||||
d)
|
||||
read_opt2="${read_dvd_opt}"
|
||||
;;
|
||||
|
||||
db)
|
||||
read_opt1="${read_dvd_opt}"
|
||||
read_opt2="${read_buf_opt}"
|
||||
;;
|
||||
|
||||
dbo)
|
||||
read_opt1="${read_dvd_opt}"
|
||||
;;
|
||||
|
||||
b)
|
||||
read_opt2="${read_buf_opt}"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Audio Setup
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
if [ "$asrate" == "-" ]
|
||||
then
|
||||
aresample=""
|
||||
else
|
||||
aresample="-srate $asrate -af lavcresample=$asrate"
|
||||
fi
|
||||
|
||||
if [ "$stereo" == "y" ]
|
||||
then
|
||||
stereo_mode=0
|
||||
@ -98,11 +143,76 @@ else
|
||||
stereo_mode=3
|
||||
fi
|
||||
|
||||
if [ "$asrate" == "-" ]
|
||||
audio_comp_opt="-oac mp3lame -lameopts cbr:br=$abr:aq=0:mode=$stereo_mode $aresample"
|
||||
audio_copy_opt="-oac copy"
|
||||
|
||||
if [ "$audio" != "n" ]
|
||||
then
|
||||
aresample=""
|
||||
if [ "$video" == "1" ]
|
||||
then
|
||||
audio_opt1="$audio_comp_opt"
|
||||
else
|
||||
if [ "$audio" == "avp" ]
|
||||
then
|
||||
audio_opt1="$audio_comp_opt"
|
||||
audio_opt2="$audio_comp_opt"
|
||||
else
|
||||
if [ "$audio" == "fvp" ]
|
||||
then
|
||||
audio_opt1="$audio_copy_opt"
|
||||
audio_opt2="$audio_comp_opt"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
aresample="-srate $asrate -af lavcresample=$asrate"
|
||||
audio_opt1="$audio_copy_opt"
|
||||
audio_opt2="$audio_copy_opt"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Video Setup
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
video_lavc_header_11="-ovc lavc -lavcopts vcodec=mpeg4:vbitrate=$vbr"
|
||||
video_lavc_header_21="-ovc lavc -lavcopts vcodec=mpeg4:vpass=1:vbitrate=$vbr"
|
||||
video_lavc_header_22="-ovc lavc -lavcopts vcodec=mpeg4:vpass=2:vbitrate=$vbr"
|
||||
|
||||
video_lavc_body_0="mbd=2:turbo"
|
||||
video_lavc_body_1="mbd=2:trell:v4mv:turbo"
|
||||
video_lavc_body_2="mbd=2:trell:v4mv:last_pred=2:dia=-1:vmax_b_frames=2:vb_strategy=1:cmp=3:subcmp=3:precmp=0:vqcomp=0.6:turbo"
|
||||
video_lavc_body_3="mbd=2:mv0:trell:v4mv:cbp:last_pred=3:predia=2:dia=2:vmax_b_frames=2:vb_strategy=1:precmp=2:cmp=2:subcmp=2:preme=2:qns=2"
|
||||
|
||||
video_xvid_header_11="-ovc xvid -xvidencopts bitrate=$vbr"
|
||||
video_xvid_header_21="-ovc xvid -xvidencopts pass=1:bitrate=$vbr"
|
||||
video_xvid_header_22="-ovc xvid -xvidencopts pass=2:bitrate=$vbr"
|
||||
|
||||
video_xvid_body_0="turbo:nochroma_me:notrellis:max_bframes=0:vhq=0"
|
||||
video_xvid_body_1="turbo:vhq=0"
|
||||
video_xvid_body_2="vhq=2:bvhq=1:chroma_opt:quant_type=mpeg"
|
||||
video_xvid_body_3="chroma_opt:vhq=4:bvhq=1:quant_type=mpeg"
|
||||
|
||||
|
||||
|
||||
if [ "$video" != "n" ]
|
||||
then
|
||||
if [ "$video" == "1" ]
|
||||
then
|
||||
video_opt1=$(eval echo \${video_${vcodec}_header_11}:\${video_${vcodec}_${vquality}})
|
||||
else
|
||||
if [ "$video" == "2a" ]
|
||||
then
|
||||
video_opt1=$(eval echo \${video_${vcodec}_header_21}:\${video_${vcodec}_body_0})
|
||||
video_opt2=$(eval echo \${video_${vcodec}_header_22}:\${video_${vcodec}_body_${vquality}})
|
||||
else
|
||||
video_opt1=$(eval echo \${video_${vcodec}_header_21}:\${video_${vcodec}_body_${vquality}})
|
||||
fi
|
||||
|
||||
video_opt2=$(eval echo \${video_${vcodec}_header_22}:\${video_${vcodec}_body_${vquality}})
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$deint" == "y" ]
|
||||
@ -112,54 +222,26 @@ fi
|
||||
|
||||
if [ "$xsize" != "-" ]
|
||||
then
|
||||
vf_opt="$vf_opt -vf-add scale -zoom -xy $xsize"
|
||||
fi
|
||||
|
||||
read_opt="$device_opt dvd://$title -chapter $chapter -dvdangle $angle -alang $alang $slang_opt"
|
||||
audio_opt="-oac mp3lame -lameopts cbr:br=$abr:aq=0:mode=$stereo_mode $aresample"
|
||||
|
||||
if [ "$vcodec" == "lavc" ]
|
||||
then
|
||||
video_opt="-ovc lavc -lavcopts vcodec=mpeg4:vbitrate=$vbr:vhq:v4mv"
|
||||
video_opt1="-ovc lavc -lavcopts vcodec=mpeg4:vpass=1:vbitrate=$vbr:vhq:v4mv"
|
||||
video_opt2="-ovc lavc -lavcopts vcodec=mpeg4:vpass=2:vbitrate=$vbr:vhq:v4mv"
|
||||
else
|
||||
if [ "$vcodec" == "xvid" ]
|
||||
then
|
||||
video_opt="-ovc xvid -xvidencopts bitrate=$vbr:chroma_me:chroma_opt:hq_ac:vhq=4"
|
||||
video_opt1="-ovc xvid -xvidencopts pass=1:bitrate=$vbr:chroma_me:chroma_opt:hq_ac:vhq=4"
|
||||
video_opt2="-ovc xvid -xvidencopts pass=2:bitrate=$vbr:chroma_me:chroma_opt:hq_ac:vhq=4"
|
||||
else
|
||||
if [ "$vcodec" != "-" ]
|
||||
then
|
||||
echo "invalid video codec: [$vcodec]"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
vf_opt="$vf_opt -vf-add scale -zoom -xy $xsize"
|
||||
fi
|
||||
|
||||
if [ "$aspect" == "-" ]
|
||||
then
|
||||
video_opt=$video_opt":autoaspect"
|
||||
video_opt1=$video_opt1":autoaspect"
|
||||
video_opt2=$video_opt2":autoaspect"
|
||||
else
|
||||
video_opt=$video_opt":aspect=$aspect"
|
||||
video_opt1=$video_opt1":aspect=$aspect"
|
||||
video_opt2=$video_opt2":aspect=$aspect"
|
||||
fi
|
||||
|
||||
if [ "$threads" != "-" ]
|
||||
then
|
||||
video_opt=$video_opt":threads=$threads"
|
||||
video_opt1=$video_opt1":threads=$threads"
|
||||
video_opt2=$video_opt2":threads=$threads"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
mkdir $tmpdir_name
|
||||
@ -167,51 +249,6 @@ cd $tmpdir_name
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
if [ "$bufferize" != "n" ]
|
||||
then
|
||||
if [ "$bufferize" == "y" ] || [ "$bufferize" == "o" ]
|
||||
then
|
||||
echo "Bufferizing..."
|
||||
mencoder $read_opt -oac copy -ovc copy -o $tmp_name >$out_name.1.log 2>&1
|
||||
|
||||
if [ "$bufferize" == "o" ]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
read_opt="$tmp_name"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
if [ "$apass" != "n" ]
|
||||
then
|
||||
if [ "$apass" == "y" ] || [ "$apass" == "o" ]
|
||||
then
|
||||
echo "Cleanup..."
|
||||
\rm frameno.avi
|
||||
|
||||
echo "Compressing MP3..."
|
||||
mencoder $read_opt $audio_opt -ovc frameno $vf_opt -o frameno.avi >$out_name.2.log 2>&1
|
||||
fi
|
||||
|
||||
if [ "$apass" == "o" ]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
audio_opt="-oac copy"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
echo "Cleanup..."
|
||||
@ -220,16 +257,42 @@ echo "Cleanup..."
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Bufferizing
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
if [ "$vpass" == "1" ]
|
||||
if [ "$input" != "d" ] && [ "$input" != "b" ]
|
||||
then
|
||||
echo "Compressing DivX..."
|
||||
mencoder $read_opt $audio_opt $video_opt $vf_opt -o $divx_name >$out_name.3.log 2>&1
|
||||
else
|
||||
echo "Compressing DivX pass 1..."
|
||||
mencoder $read_opt $audio_opt $video_opt1 $vf_opt -o $divx_name >$out_name.3.log 2>&1
|
||||
|
||||
echo "Compressing DivX pass 2..."
|
||||
mencoder $read_opt $audio_opt $video_opt2 $vf_opt -o $divx_name >$out_name.4.log 2>&1
|
||||
echo "Bufferizing..."
|
||||
mencoder $read_opt1 -oac copy -ovc copy -o $tmp_name >$out_name.1.log 2>&1
|
||||
|
||||
if [ "$input" == "dbo" ]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Video Compression
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
if [ "$video" != "n" ]
|
||||
then
|
||||
if [ "$video" == "1" ]
|
||||
then
|
||||
echo "Compressing DivX..."
|
||||
mencoder $read_opt2 $audio_opt1 $video_opt1 $vf_opt -o $divx_name >$out_name.3.log 2>&1
|
||||
else
|
||||
echo "Compressing DivX pass 1..."
|
||||
mencoder $read_opt2 $audio_opt1 $video_opt1 $vf_opt -o /dev/null >$out_name.3.log 2>&1
|
||||
|
||||
echo "Compressing DivX pass 2..."
|
||||
mencoder $read_opt2 $audio_opt2 $video_opt2 $vf_opt -o $divx_name >$out_name.4.log 2>&1
|
||||
fi
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user