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
#-----------------------------------------------------------------------------------------------------------------------------------
# $RCSfile: dvd2divx,v $
# $Revision: 1.6 $
# $Revision: 1.7 $
# $Name: $
# $Date: 2009/01/06 00:16:22 $
# $Date: 2009/02/17 08:29:55 $
# $Author: agibert $
#-----------------------------------------------------------------------------------------------------------------------------------
@ -32,10 +32,10 @@
# Usage exemple
#-----------------------------------------------------------------------------------------------------------------------------------
# #!/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
# #--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# 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
# # 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/cdrom1 10 1- 1 fr - - - - - - - - - - - - - - -
# dvd2divx cobra 1 b - - - - - - fvp 128 - n - 2a xvid 3 1000 - 480 4/3 y 4
@ -48,21 +48,24 @@ title=${5} #
chapter=${6} #
angle=${7} #
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} #
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..
sub=${14} # -|f|o (-: no subtitles | f: file subtitles | o: OSD subtitles)
#------------------------------------------------------------------------------
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)
vcodec=${16} # -|lavc|xvid
vquality=${17} # 0|1|2|3 (0: realtime | 1: fast | 2: High quality | 3: very high quality)
vbr=${18} #
crop=${19} # -|width:height:x:y
xsize=${20} # -|...
aspect=${21} # -|4/3|16/9|...
deint=${22} # y|n
threads=${23} # -|1..
@ -73,12 +76,11 @@ divx_name=../$divx_root-$divx_title.avi
tmp_name=../$divx_root-$divx_title.vob
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 "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
#-----------------------------------------------------------------------------------------------------------------------------------
shopt -s extglob
if [ "$dvd_device" != "-" ]
then
device_opt="-dvd-device $dvd_device"
fi
if [ "$slang" == "-" ]
if [ "$sub" == "-" ]
then
slang_opt=""
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
read_dvd_opt="$device_opt dvd://$title -chapter $chapter -dvdangle $angle -alang $alang $slang_opt"
@ -123,8 +145,6 @@ esac
#-----------------------------------------------------------------------------------------------------------------------------------
# Audio Setup
#-----------------------------------------------------------------------------------------------------------------------------------
@ -171,8 +191,6 @@ fi
#-----------------------------------------------------------------------------------------------------------------------------------
# Video Setup
#-----------------------------------------------------------------------------------------------------------------------------------
@ -201,7 +219,7 @@ if [ "$video" != "n" ]
then
if [ "$video" == "1" ]
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
if [ "$video" == "2a" ]
then
@ -215,14 +233,19 @@ then
fi
fi
if [ "$deint" == "y" ]
if [ "$crop" != "-" ]
then
vf_opt="-vf-add lavcdeint"
vf_opt="-vf-add crop=$crop"
fi
if [ "$xsize" != "-" ]
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
if [ "$aspect" == "-" ]
@ -242,6 +265,8 @@ fi
#-----------------------------------------------------------------------------------------------------------------------------------
mkdir $tmpdir_name
@ -249,6 +274,8 @@ cd $tmpdir_name
#-----------------------------------------------------------------------------------------------------------------------------------
echo "Cleanup..."
@ -257,8 +284,6 @@ echo "Cleanup..."
#-----------------------------------------------------------------------------------------------------------------------------------
# Bufferizing
#-----------------------------------------------------------------------------------------------------------------------------------