From 93314eca39f5963cea2ae9a2514cb10258df12d7 Mon Sep 17 00:00:00 2001 From: diego Date: Sun, 12 Nov 2006 23:38:35 +0000 Subject: update to 0.6.2, patch by Giacomo Comes, comes naic edu git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@20874 b3059339-0415-0410-9bf9-f77b7e298cf2 --- TOOLS/encode2mpeglight | 457 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 303 insertions(+), 154 deletions(-) (limited to 'TOOLS') diff --git a/TOOLS/encode2mpeglight b/TOOLS/encode2mpeglight index 4871b2d7d6..60ad090bdf 100755 --- a/TOOLS/encode2mpeglight +++ b/TOOLS/encode2mpeglight @@ -1,30 +1,30 @@ #!/bin/bash # -# Version: 0.5.5 +# Version: 0.6.2 # # Licence: GPL # # 2004-05-22 Giacomo Comes -# 2006-01-14 +# 2006-11-06 # -# Pourpose: Convert anything MPlayer can play to AVI/VCD/SVCD/DVD mpeg +# Purpose: Convert anything MPlayer can play to AVI/VCD/SVCD/DVD MPEG # -# This program is free software; you can redistribute it and/or modify +# encode2mpeglight is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License. -# This program is distributed in the hope that it will be useful, +# encode2mpeglight is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software +# along with encode2mpeglight; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ############################################################################### -# encode2mpeglight is a program that can create VCD/SVCD/DVD mpegs +# encode2mpeglight is a program that can create VCD/SVCD/DVD MPEGs # and eventually extract VobSub subtitles from a DVD using only # MEncoder/MPlayer. # @@ -43,8 +43,8 @@ # and more, consider to use the full release (http://encode2mpeg.sf.net) # # encode2mpeglight is mainly tested with the stable release of MPlayer, -# I try to make it work with CVS too, but due to the "instable" nature of -# CVS, bugs may suddenly appear. If you find any, please report it to me. +# I try to make it work with SVN too, but due to the "unstable" nature of +# SVN, bugs may suddenly appear. If you find any, please report them to me. ############################################################################### ############################################################################### @@ -68,8 +68,8 @@ OptionsText () { ############################################################################### ModeText () { echo - echo -e "$PROGNAME defaults to encode2mpeg's Mpeg Mode, the others mode are not" - echo -e "available" + echo "$PROGNAME defaults to encode2mpeg's MPEG Mode, the other modes are not" + echo "available." } ############################################################################### usage () { @@ -92,20 +92,26 @@ shortusage () { } ############################################################################### mp_identify () { - mplayer -identify -vo null -ao null -nocache "$@" -frames 0 2>/dev/null + mplayer -msglevel identify=6 -vo md5sum:outfile=/dev/null -ao null -nocache -frames 0 "$@" 2>/dev/null +} +############################################################################### +id_find () { + local ID=$1 + shift + mp_identify "$@" | awk -v id=$ID -F= '$1==id{t=$2}END{print t}' } ############################################################################### get_aspect () { - mplayer -vo null -ao null -nocache -frames 4 "$@" 2>/dev/null | sed '/^Movie-Aspect is/!d;s/.*Movie-Aspect is //;s/:.*//' + mplayer -vc -mpegpes, -vo null -ao null -nocache -frames 4 "$@" 2>/dev/null | sed '/^Movie-Aspect is/!d;s/.*Movie-Aspect is //;s/:.*//' } ############################################################################### mlistopt () { mplayer -list-options 2>&1 | awk '$1=="Name"{m=1}{if(m&&$1!="Name"&&$1!=""&&$1!="Total:")print "\""$1"\""}' } ############################################################################### -pre_log () { +do_log () { echo "$1" - WARN="$WARN${WARN:+\n}$1" + ((LG)) && echo "$1" >>"$output".log || WARN="$WARN${WARN:+\n}$1" } ############################################################################### isarg () { @@ -133,7 +139,7 @@ pr_time () { get_abr () { local INFO ABR INFO=$(mp_identify "${MPLAYEROPT[@]}" ${dvddev:+-dvd-device "$dvddev"} "$@" | grep '^ID_') - ABR=$(echo "$INFO" | grep '^ID_AUDIO_BITRATE' | cut -f2 -d=) + ABR=$(echo "$INFO" | grep '^ID_AUDIO_BITRATE' | tail -1 | cut -f2 -d=) case $(echo "$INFO" | grep '^ID_AUDIO_CODEC' | cut -f2 -d=) in dvdpcm) abr=$((abr+ABR/1024)) ;; *) abr=$((abr+ABR/1000)) ;; @@ -164,12 +170,12 @@ show_html () { elif [[ $1 && ! -d $INSTDOCDIR/html && ! -d $SRCDOCDIR/html ]]; then HTML="http://encode2mpeg.sourceforge.net/html/$1" fi - LIST=(mozilla firefox) + LIST=(mozilla seamonkey firefox) [[ ${HTML:0:1} = / ]] && PREFIX=file:// || PREFIX= for ((i=0;i<${#LIST[*]};i++)); do type ${LIST[i]} &>/dev/null && ${LIST[i]} -remote 'openURL('"$PREFIX$HTML"',new-tab)' 2>/dev/null && return done - LIST=(mozilla firefox opera konqueror epiphany galeon) + LIST=(mozilla firefox seamonkey opera konqueror epiphany galeon) if [[ $BROWSER ]]; then type "$BROWSER" &>/dev/null && LIST=("$BROWSER") || echo "++ WARN: default browser '$BROWSER' not found, using builtin browser list" fi @@ -187,9 +193,9 @@ show_html () { } ############################################################################### -#### variables initialization +#### variable initialization ############################################################################### -abr=;asr=;vbr=;vfr=;videonorm=;frameformat=;output=;audioformat=;mp1=;mp2=;mp3=;ac3=;dts=;lpcm=;normalize=;volume=;multiaudio=;mpegchannels=;quiet=;resume=;blank=;encode=;ofps=;mono=;usesbr=;sbr=;clear=;keep=;frames=;avisplit=;channels=;vcustom=;acustom=;cpu=;interlaced=;mpegaspect=;intra_matrix=;inter_matrix=;fixavi=;mpeg=;crop=;audioid=;dvdaudiolang=;bframes=;firstchap=;lastchap=;dvdtrack=;addchapter=;cdi=;mpegfixaspect=;nowait=;vf=;frameres=;trick=;autocrop=;ac=;afm=;cache=;removecache=;turbo=;dvddev=;srate=;endpos=;fourcc=;menu=;menubg=;dvdtitle=;rotate=;menuvtsbg=;autosync=;telecine=;AFMT=;telesrc=;vcodec=;vrfyumnt=;burniso=;verify=;fixasync=;removedir=;MPGRES=;GOP=;TXTSUBOPT=;usespeed=;testmca=;chconf=;noodml=;pictsrc=;slideaudio=;audioonly=;norc= +abr=;asr=;vbr=;vfr=;videonorm=;frameformat=;output=;audioformat=;mp1=;mp2=;mp3=;ac3=;dts=;lpcm=;aac=;normalize=;volume=;multiaudio=;mpegchannels=;quiet=;resume=;blank=;encode=;ofps=;mono=;usesbr=;sbr=;clear=;keep=;frames=;avisplit=;channels=;vcustom=;acustom=;cpu=;interlaced=;mpegaspect=;intra_matrix=;inter_matrix=;fixavi=;mpeg=;crop=;audioid=;dvdaudiolang=;bframes=;firstchap=;lastchap=;dvdtrack=;addchapter=;cdi=;mpegfixaspect=;nowait=;vf=;frameres=;trick=;autocrop=;afm=;cache=;removecache=;turbo=;dvddev=;srate=;endpos=;fourcc=;menu=;menubg=;dvdtitle=;rotate=;menuvtsbg=;autosync=;telecine=;AFMT=;telesrc=;vcodec=;vrfyumnt=;burniso=;verify=;fixasync=;removedir=;MPGRES=;GOP=;TXTSUBOPT=;usespeed=;testmca=;chconf=;noodml=;pictsrc=;slideaudio=;audioonly=;norc=;rawsub=;vobsubsrc=;af=;lavf=;subrender=;harddup=;overburn= unset encsid encsdx encsla addsub addsdx addsla savecache txtsub txtsubopts zoom=0 scale=1 @@ -238,6 +244,8 @@ DEBUG=0 LAVC= WARN= LOG= +LG=0 +SVN=0 MAXFIX=20 timelen=0 ocrsub=0 @@ -282,7 +290,7 @@ if [[ -s ~/.encode2mpegrc ]]; then [[ ${CMD[i]} = -norc ]] && norc=1 && break done if [[ ! $norc ]] && ! awk '{if($1~"^#")exit 1}' ~/.encode2mpegrc ; then - WARN="$WARN${WARN:+\n}++ WARN: [$PROGNAME] ~/.encode2mpegrc appears to contain comments, ignoring it" + do_log "++ WARN: [$PROGNAME] ~/.encode2mpegrc appears to contain comments, ignoring it" >/dev/null norc=1 fi [[ ! $norc ]] && set -- $(<~/.encode2mpegrc) "$@" @@ -406,7 +414,9 @@ while (($#)) ; do shift ;; -n|-video-norm) # - #-set the video norm of the VCD/SVCD/DVD + # set the video norm of the VCD/SVCD/DVD; NTSC is USA standard, + # PAL is European standard and SECAM is French standard; concerning + #-VCD/SVCD/DVD encoding, SECAM is equivalent to PAL case $2 in n|N|ntsc|NTSC) videonorm=n ;; p|P|pal|PAL) videonorm=p ;; @@ -536,7 +546,7 @@ while (($#)) ; do shift ;; -mpegchannels) #<1-6> - # number of channels of the mpeg audio stream, 1-6 for ac3 and lpcm; + # number of channels of the MPEG audio stream, 1-6 for ac3 and lpcm; # 1-2 for mp1, mp2 and mp3; 3-6 for mp2 Multichannel Audio; for the #-avi audio stream use MPlayer's option -channels mpegchannels=2 @@ -557,9 +567,9 @@ while (($#)) ; do shift ;; -noscale) # - # encode2mpeg automatically scales the video according to the mpeg - # profile chosen, this option disable this feature; used mainly - #-for debug purpose + # encode2mpeg automatically scales the video according to the MPEG + # profile chosen, this option disables this feature; used mainly + # for debug purposes. [[ $2 = doc || $2 = help ]] && isarg $1 $2 direct scale= ;; @@ -569,7 +579,7 @@ while (($#)) ; do YUVSCALEROPT="$YUVSCALEROPT -O MONOCHROME" ;; -split) # - #-split the resulting mpeg stream in MB chunks. + #-split the resulting MPEG stream in MB chunks. split=$2 isarg $1 "$2" direct shift @@ -586,17 +596,18 @@ while (($#)) ; do # 5 libavcodec/mp3 # 6 libavcodec/ac3 for m=[2-4] and i>1 turbo is on # 7 toolame/mp2 + # 8 libfaac/aac #- with n=[3-7] b specify the audio bit rate encode=5:3:2 - echo "$2" | grep -qE '^[0-7]:[0-4]:[1-9](,[0-9]+)?$' && encode=$2 + echo "$2" | grep -qE '^[0-8]:[0-4]:[1-9](,[0-9]+)?$' && encode=$2 isarg $1 "$2" $([[ $mpeg ]] && echo mpeg || echo Avi) shift ;; -telecinesrc) # - # if you use -encode n:0:i in Mpeg Mode, encode2mpeg needs to know - # if the source NTSC mpeg is telecined, otherwise the stream copy may + # if you use -encode n:0:i in MPEG Mode, encode2mpeg needs to know + # if the source NTSC MPEG is telecined, otherwise the stream copy may # not work properly; normally encode2mpeg is able to detect telecined - # sources, but, if the source mpeg is mixed, part not telecined and + # sources, but, if the source MPEG is mixed, part not telecined and # part telecined, encode2mpeg may fail to detect it. In such case, #-you can use this option to specify a telecined source. [[ $2 = doc || $2 = help ]] && isarg $1 $2 mpeg @@ -613,7 +624,7 @@ while (($#)) ; do # increase the encoding speed of 25-50% (with -encode n:1:1); the # output video stream will be bigger and can have poor quality; this # option is mainly intented for testing, but it can be used if you - #-want to create more quickly an mpeg4/avi or a DVD + #-want to create more quickly an MPEG-4/AVI or a DVD. [[ $2 = doc || $2 = help ]] && isarg $1 $2 Avi hispeed=1 ;; @@ -632,7 +643,8 @@ while (($#)) ; do shift ;; -acustom) # - #-specify a custom set of lame options, use with -encode 2:m:i + # specify a custom set of lame options (with -encode 2:m:i) or faac + #-options (with -encode 8:m:i) acustom=$2 isarg $1 "$2" Avi shift @@ -695,8 +707,8 @@ while (($#)) ; do # fps to use when creating video from pictures, default is 1; if # there is a audio file associated with a picture, the duration of #-the audio file is used - slidefps=$(awk -v a=$2 'BEGIN{printf("%.3f",1/a)}') isarg $1 "$2" images + slidefps=$(awk -v a=$2 'BEGIN{printf("%.3f",1/a)}') shift ;; -slideaudio) #