Add crop support,

Add OSD sub title support,
Fix minor bugs.
This commit is contained in:
agibert 2009-02-17 08:29:55 +00:00
parent e4e9cc18e5
commit 200c20a80e

View File

@ -5,9 +5,9 @@
# (C) 2004-2009 Arnaud G. Gibert # (C) 2004-2009 Arnaud G. Gibert
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------
# $RCSfile: dvd2divx,v $ # $RCSfile: dvd2divx,v $
# $Revision: 1.6 $ # $Revision: 1.7 $
# $Name: $ # $Name: $
# $Date: 2009/01/06 00:16:22 $ # $Date: 2009/02/17 08:29:55 $
# $Author: agibert $ # $Author: agibert $
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------
@ -32,10 +32,10 @@
# Usage exemple # Usage exemple
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------
# #!/bin/bash # #!/bin/bash
# # 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 # # divx_root divx_title input dvd_device dvd_title chapter angle alang slang audio abr asrate stereo sub video vcodec vqual vbr crop xsize aspect deint threads
# #-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- # #-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# dvd2divx cobra 1 dbo /dev/dvd0 10 1- 1 fr - - - - - - - - - - - - - # dvd2divx cobra 1 dbo /dev/cdrom1 10 1- 1 fr - - - - - - - - - - - - - - -
# dvd2divx cobra 1 b - - - - - - fvp 128 - n 2a xvid 3 1000 480 4/3 y 4 # dvd2divx cobra 1 b - - - - - - fvp 128 - n - 2a xvid 3 1000 - 480 4/3 y 4
@ -48,21 +48,24 @@ title=${5} #
chapter=${6} # chapter=${6} #
angle=${7} # angle=${7} #
alang=${8} # en|fr|... alang=${8} # en|fr|...
slang=${9} # -|en|fr|... slang=${9} # -|en|fr|...|0|1|... (lang or id)
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
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) 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} # abr=${11} #
asrate=${12} # -|xxx (resample audio) asrate=${12} # -|xxx (resample audio)
stereo=${13} # y|n 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) sub=${14} # -|f|o (-: no subtitles | f: file subtitles | o: OSD subtitles)
vcodec=${15} # -|lavc|xvid #------------------------------------------------------------------------------
vquality=${16} # 0|1|2|... (0: realtime | 1: fast | 2: High quality | 3: very high quality) video=${15} # 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)
vbr=${17} # vcodec=${16} # -|lavc|xvid
xsize=${18} # -|... vquality=${17} # 0|1|2|3 (0: realtime | 1: fast | 2: High quality | 3: very high quality)
aspect=${19} # -|4/3|16/9|... vbr=${18} #
deint=${20} # y|n crop=${19} # -|width:height:x:y
threads=${21} # -|1.. xsize=${20} # -|...
aspect=${21} # -|4/3|16/9|...
deint=${22} # y|n
threads=${23} # -|1..
@ -76,9 +79,8 @@ out_name=../$divx_root-$divx_title
echo "DivX: [$divx_name] title: ($title)" echo "DivX: [$divx_name] title: ($title)"
echo "Input: [$input] device: [$dvd_device] title: ($title) chapter: ($chapter) angle: ($angle) alang: ($alang) slang: ($slang)" 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 "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)" echo "Sub: [$sub]"
echo "Video: [$video] vcodec: [$vcodec] vquality: [$vquality] vbr: ($vbr) crop: ($crop) xsize: ($xsize) aspect: ($aspect) deint: ($deint) threards: ($threads)"
@ -86,16 +88,36 @@ echo "Video: [$video] vcodec: [$vcodec] vquality: [$vquality] vbr: ($vbr)
# DVDRip Setup # DVDRip Setup
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------
shopt -s extglob
if [ "$dvd_device" != "-" ] if [ "$dvd_device" != "-" ]
then then
device_opt="-dvd-device $dvd_device" device_opt="-dvd-device $dvd_device"
fi fi
if [ "$slang" == "-" ] if [ "$sub" == "-" ]
then then
slang_opt="" slang_opt=""
else else
slang_opt="-slang $slang -vobsubout $out_name -vobsuboutid $slang -vobsuboutindex 0" if [ "$slang" != "-" ]
then
if [[ "$slang" == +([[:digit:]]) ]]
then
slang_opt="-sid $slang"
else
slang_opt="-slang $slang"
fi
if [ "$sub" == "f" ]
then
slang_opt+=" -vobsubout $out_name -vobsuboutid $slang -vobsuboutindex 0"
else
if [ "$sub" == "o" ]
then
slang_opt+=" -ass"
fi
fi
fi
fi fi
read_dvd_opt="$device_opt dvd://$title -chapter $chapter -dvdangle $angle -alang $alang $slang_opt" read_dvd_opt="$device_opt dvd://$title -chapter $chapter -dvdangle $angle -alang $alang $slang_opt"
@ -123,8 +145,6 @@ esac
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------
# Audio Setup # Audio Setup
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------
@ -171,8 +191,6 @@ fi
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------
# Video Setup # Video Setup
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------
@ -201,7 +219,7 @@ if [ "$video" != "n" ]
then then
if [ "$video" == "1" ] if [ "$video" == "1" ]
then then
video_opt1=$(eval echo \${video_${vcodec}_header_11}:\${video_${vcodec}_${vquality}}) video_opt1=$(eval echo \${video_${vcodec}_header_11}:\${video_${vcodec}_body_${vquality}})
else else
if [ "$video" == "2a" ] if [ "$video" == "2a" ]
then then
@ -215,14 +233,19 @@ then
fi fi
fi fi
if [ "$deint" == "y" ] if [ "$crop" != "-" ]
then then
vf_opt="-vf-add lavcdeint" vf_opt="-vf-add crop=$crop"
fi fi
if [ "$xsize" != "-" ] if [ "$xsize" != "-" ]
then then
vf_opt="$vf_opt -vf-add scale -zoom -xy $xsize" vf_opt+=" -vf-add scale -zoom -xy $xsize"
fi
if [ "$deint" == "y" ]
then
vf_opt+=" -vf-add lavcdeint"
fi fi
if [ "$aspect" == "-" ] if [ "$aspect" == "-" ]
@ -242,6 +265,8 @@ fi
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------
mkdir $tmpdir_name mkdir $tmpdir_name
@ -249,6 +274,8 @@ cd $tmpdir_name
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------
echo "Cleanup..." echo "Cleanup..."
@ -257,8 +284,6 @@ echo "Cleanup..."
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------
# Bufferizing # Bufferizing
#----------------------------------------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------------------