summaryrefslogtreecommitdiffstats
path: root/TOOLS
diff options
context:
space:
mode:
authordiego <diego@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-09-07 12:58:23 +0000
committerdiego <diego@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-09-07 12:58:23 +0000
commit583ba8dcb7e82edf8c5d44b7ad371268812d3c93 (patch)
tree97442e32e828ccaaeb1416a76ff7bf3fc962ead1 /TOOLS
parent5e5c1feb69bd6b6869d866e09d1c6099af070a99 (diff)
downloadmpv-583ba8dcb7e82edf8c5d44b7ad371268812d3c93.tar.bz2
mpv-583ba8dcb7e82edf8c5d44b7ad371268812d3c93.tar.xz
Remove encode2mpeglight, it is only an outdated stripped-down version of the
tool maintained externally at http://encode2mpeg.sf.net/. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27537 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'TOOLS')
-rw-r--r--TOOLS/README16
-rwxr-xr-xTOOLS/encode2mpeglight.sh2000
2 files changed, 0 insertions, 2016 deletions
diff --git a/TOOLS/README b/TOOLS/README
index 7aa32bd150..4fc0968948 100644
--- a/TOOLS/README
+++ b/TOOLS/README
@@ -173,22 +173,6 @@ Note: You will need vcdimager/cdrecord to master/burn the resulting
-encode2mpeglight.sh
-
-Author: Giacomo Comes
-
-Description: Convert anything MPlayer can play to VCD/SVCD/DVD MPEG.
-
-Usage: encode2mpeglight.sh -o <NAME> -n <NORM> [options] <source>
- For help and documentation run:
- encode2mpeglight.sh -h
- encode2mpeglight.sh -l
- encode2mpeglight.sh -doc
-
-Note: This script uses only MEncode/MPlayer. Check the final log
- file for informations/warnings about the encoding process.
-
-
Tech scripts in the TOOLS dir
-----------------------------
diff --git a/TOOLS/encode2mpeglight.sh b/TOOLS/encode2mpeglight.sh
deleted file mode 100755
index e5b7a3018d..0000000000
--- a/TOOLS/encode2mpeglight.sh
+++ /dev/null
@@ -1,2000 +0,0 @@
-#!/bin/bash
-#
-# Version: 0.6.3
-#
-# Licence: GPL
-#
-# 2004-05-22 Giacomo Comes <encode2mpeg at users.sourceforge.net>
-# 2006-11-06 <encode2mpeg at email.it>
-#
-# Purpose: Convert anything MPlayer can play to AVI/VCD/SVCD/DVD MPEG
-#
-# encode2mpeglight.sh 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.
-
-# encode2mpeglight.sh 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 encode2mpeglight.sh; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-
-###############################################################################
-# encode2mpeglight.sh is a program that can create VCD/SVCD/DVD MPEGs
-# and eventually extract VobSub subtitles from a DVD using only
-# MEncoder/MPlayer.
-#
-# encode2mpeglight.sh is a stripped release of encode2mpeg and therefore the
-# code is redundant in several places, with many variables defined and
-# used for no apparent reason. This cannot be avoided easily.
-# A command line like:
-# encode2mpeglight.sh <encode2mpeglight.sh options>
-# will produce almost the same results as:
-# encode2mpeg -mpeg -mpegonly <encode2mpeglight.sh options>
-#
-# If you need more features like:
-# - two or more audio streams, chapters, subtitles, menu
-# - creation, burn and verification of the disk image
-# - creation of MPEG-4 avi and subtitles for a hardware player
-# and more, consider to use the full release (http://encode2mpeg.sf.net)
-#
-# encode2mpeglight.sh is mainly tested with the stable release of MPlayer,
-# 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.
-###############################################################################
-
-###############################################################################
-#### start
-###############################################################################
-export LC_ALL=POSIX
-set -B +f
-shopt -u xpg_echo nullglob
-PROGNAME=${0##*/}
-PROGFILE=$(type -p "$0")
-VERSION=$(awk '$2=="Version:"{print $3;exit}' <"$PROGFILE")
-BROWSER=
-
-###############################################################################
-#### some functions
-###############################################################################
-OptionsText () {
- echo
- echo "Arguments enclosed in [ ] are optional"
-}
-###############################################################################
-ModeText () {
- echo
- echo "$PROGNAME defaults to encode2mpeg's MPEG Mode, the other modes are not"
- echo "available."
-}
-###############################################################################
-usage () {
- echo -e "Usage: $PROGNAME options source\nOptions:"
- sed -n '/^#### PARSING/,/^done/!d;/^done/q;/^[ ]*-[^)]*)/,/#-/!d;s/)$//;s/) *#/ /;s/#-/# /;s/ *#L.$//;s/#//;p' "$PROGFILE"
- ModeText
- OptionsText
-}
-###############################################################################
-shortusage () {
- echo -e "\n$PROGNAME v. $VERSION Copyright (C) 2004-2006 Giacomo Comes\n"
- echo "This is free software; see the source for copying conditions. There is NO"
- echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,"
- echo "to the extent permitted by law."
- echo
- echo "Usage: $PROGNAME options source"
- echo "Options:"
- sed -n '/^#### PARSING/,/^done/!d;/^done/q;/^[ ]*-[^)]*)/!d;s/)$//;s/) *#/ /;s/ *#L.$//;p' "$PROGFILE"
- OptionsText
-}
-###############################################################################
-mp_identify () {
- 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 -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"\""}'
-}
-###############################################################################
-do_log () {
- echo "$1"
- ((LG)) && echo "$1" >>"$output".log || WARN="$WARN${WARN:+\n}$1"
-}
-###############################################################################
-isarg () {
- if [[ ${2:0:1} = - || ! $2 || $2 = help ]]; then
- [[ ${2:0:1} = - ]] && echo "**ERROR: [$PROGNAME] invalid argument '$2' for option '$1'"
- [[ ! $2 ]] && echo "**ERROR: [$PROGNAME] invalid null argument for option '$1'"
- "$PROGFILE" -norc -l | sed '/^ '$1'$/,/^ -/!d' | sed '$d'
- "$PROGFILE" -norc -l | sed '/^ '$1'[ |]/,/^ -/!d' | sed '$d'
- exit 1
- fi
- if [[ $2 = doc ]]; then
- show_html ${3:+$3.html}
- exit
- fi
-}
-###############################################################################
-pr_date () {
- echo "[$(date '+%Y-%m-%d %H:%M:%S')]"
-}
-###############################################################################
-pr_time () {
- date '+%j %H %M %S' | awk '{print $1*86400+$2*3600+$3*60+$4}'
-}
-###############################################################################
-get_abr () {
- local INFO ABR
- INFO=$(mp_identify "${MPLAYEROPT[@]}" ${dvddev:+-dvd-device "$dvddev"} "$@" | grep '^ID_')
- 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)) ;;
- esac
-}
-###############################################################################
-get_pwd () {
- pushd &>/dev/null "$1"
- echo "$PWD/$2"
- popd &>/dev/null
-}
-###############################################################################
-show_html () {
- local i LIST HTML PREFIX OPTION INSTDOCDIR SRCDOCDIR
- INSTDOCDIR=${PROGFILE%/bin/$PROGNAME}/share/doc/encode2mpeg
- SRCDOCDIR=${PROGFILE%/$PROGNAME}/doc
- if [[ -f $INSTDOCDIR/encode2mpeg.html ]]; then
- HTML=$(get_pwd "$INSTDOCDIR" encode2mpeg.html)
- elif [[ -f $SRCDOCDIR/encode2mpeg.html ]]; then
- HTML=$(get_pwd "$SRCDOCDIR" encode2mpeg.html)
- else
- HTML="http://encode2mpeg.sourceforge.net"
- fi
- if [[ -f $INSTDOCDIR/html/$1 ]]; then
- HTML=$(get_pwd "$INSTDOCDIR/html" $1)
- elif [[ -f $SRCDOCDIR/html/$1 ]]; then
- HTML=$(get_pwd "$SRCDOCDIR/html" $1)
- elif [[ $1 && ! -d $INSTDOCDIR/html && ! -d $SRCDOCDIR/html ]]; then
- HTML="http://encode2mpeg.sourceforge.net/html/$1"
- fi
- 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 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
- for ((i=0;i<${#LIST[*]};i++)); do
- if type "${LIST[i]}" &>/dev/null; then
- case ${LIST[i]} in
- opera) OPTION=--newpage ;;
- epiphany|galeon) OPTION=--new-tab ;;
- *) OPTION= ;;
- esac
- "${LIST[i]}" $OPTION "$HTML" &
- return
- fi
- done
-}
-
-###############################################################################
-#### variable initialization
-###############################################################################
-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
-fast=1
-MAXSTEP=6 # burn is the default
-step=$MAXSTEP
-split=0
-vbitrate=16000
-mpegmbr=0
-overscan=0
-iter=0
-bakiter=0
-hispeed=0
-BGTITLE=1
-TANIM=0
-TFMT=png
-TMODE=0
-TKFRM=0
-TSECS=5
-TPART=4
-TPARTSEC=15
-TFONTSIZE=1
-TFONTBG=1
-TLINES=2
-TCPR=2
-MENUERR=0
-DVDPLAY=0
-MENUOS=0
-TSETB=1
-DVDFS=1
-VTSMBG=0
-menufix=0
-cdburndevice=0,0,0
-dvdburndevice=/dev/cdrecorder
-fsize=;fint=;ffrac=;fpre=;audiosize=0
-ASPECT=(1 1 4/3 16/9 2.21)
-CH6LIST=(l r ls rs c lfe)
-TOOL=
-MPEG2ENCOPT=;YUVSCALEROPT=;YUVDENOISE=;MPLEXOPT=;VCDIMAGEROPT=;DVDAUTHOROPT=;CDRDAOOPT=;GROWISOFSOPT=;MUSICINOPT=
-unset MPLAYEROPT MPLEXSTREAM MENCODEROPT
-LPCMPAR=
-SUBLANG=
-unset SUBTEXT AUDIOTEXT CHAPTERTEXT TITLESET EXTWAV PROFILE MSRC
-unset CLEAN
-DEBUG=0
-LAVC=
-WARN=
-LOG=
-LG=0
-SVN=0
-MAXFIX=20
-timelen=0
-ocrsub=0
-slidefps=1
-default_intra=8,16,19,22,26,27,29,34,16,16,22,24,27,29,34,37,19,22,26,27,29,34,34,38,22,22,26,27,29,34,37,40,22,26,27
-default_intra=$default_intra,29,32,35,40,48,26,27,29,32,35,40,48,58,26,27,29,34,38,46,56,69,27,29,35,38,46,56,69,83
-default_inter=16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16
-default_inter=$default_inter,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16
-hires_intra=8,16,18,20,24,25,26,30,16,16,20,23,25,26,30,30,18,20,22,24,26,28,29,31,20,21,23,24,26,28,31,31,21,23,24
-hires_intra=$hires_intra,25,28,30,30,33,23,24,25,28,30,30,33,36,24,25,26,29,29,31,34,38,25,26,28,29,31,34,38,42
-hires_inter=$default_inter
-kvcd_intra=8,9,12,22,26,27,29,34,9,10,14,26,27,29,34,37,12,14,18,27,29,34,37,38,22,26,27,31,36,37,38,40,26,27,29
-kvcd_intra=$kvcd_intra,36,39,38,40,48,27,29,34,37,38,40,48,58,29,34,37,38,40,48,58,69,34,37,38,40,48,58,69,79
-kvcd_inter=16,18,20,22,24,26,28,30,18,20,22,24,26,28,30,32,20,22,24,26,28,30,32,34,22,24,26,30,32,32,34,36,24,26
-kvcd_inter=$kvcd_inter,28,32,34,34,36,38,26,28,30,32,34,36,38,40,28,30,32,34,36,38,42,42,30,32,34,36,38,40,42,44
-tmpgenc_intra=8,16,19,22,26,27,29,34,16,16,22,24,27,29,34,37,19,22,26,27,29,34,34,38,22,22,26,27,29,34,37,40,22,26,27
-tmpgenc_intra=$tmpgenc_intra,29,32,35,40,48,26,27,29,32,35,40,40,58,26,27,29,34,38,46,56,69,27,29,35,38,46,56,69,83
-tmpgenc_inter=16,17,18,19,20,21,22,23,17,18,19,20,21,22,23,24,18,19,20,21,22,23,24,25,19,20,21,22,23,24,26,27,20,21,22
-tmpgenc_inter=$tmpgenc_inter,23,25,26,27,28,21,22,23,24,26,27,28,30,22,23,24,26,27,28,30,31,23,24,25,27,28,30,31,33
-TXTSUBDEF=( languageId nolang delay 0 font arial.ttf size 28 bottom-margin 30 characterset ISO8859-1 movie-height-reduction 0 fps default )
-AVISUBDEF=( format SubViewer name-extension null fileformat unix version-number off delay 0 fps default suffix default )
-
-#### encode2mpeglight.sh defauls
-mpeg=1
-encode=7:2:2
-
-(($#)) || ! shortusage || exit 1
-CMD=( "$@" )
-
-#### options array
-MOPT=( $(mlistopt | grep -v -e : -e '*')
- $(mlistopt | sed -n '/:/s/:.*/"/p' | uniq)
- $(mplayer -vfhelp 2>&1 | awk '/vf-/{printf("\"%s\"\n",$1)}')
- $(mplayer -zrhelp 2>/dev/null | awk '$1~/^-zr/{printf("\"%s\"\n",substr($1,2))}') )
-
-###############################################################################
-#### check rc file
-###############################################################################
-if [[ -s ~/.encode2mpegrc ]]; then
- for ((i=0;i<${#CMD[*]};i++)); do
- [[ ${CMD[i]} = -norc ]] && norc=1 && break
- done
- if [[ ! $norc ]] && ! awk '{if($1~"^#")exit 1}' ~/.encode2mpegrc ; then
- do_log "++ WARN: [$PROGNAME] ~/.encode2mpegrc appears to contain comments, ignoring it" >/dev/null
- norc=1
- fi
- [[ ! $norc ]] && set -- $(<~/.encode2mpegrc) "$@"
-fi
-
-###############################################################################
-#### arguments parsing
-###############################################################################
-while (($#)) ; do
-#### PARSING
- case $1 in
- -h|-help)
- #-list the available options
- [[ $2 = doc || $2 = help ]] && isarg $1 $2
- shortusage
- exit
- ;;
- -l|-longhelp)
- #-print this help page
- [[ $2 = doc || $2 = help ]] && isarg $1 $2
- usage
- exit
- ;;
- -doc|-documentation) #[[<browser>:][<html page>]]
- #-show the html documentation
- [[ $2 = doc || $2 = help ]] && isarg $1 $2
- [[ ${2%:*} != $2 ]] && BROWSER=${2%:*}
- show_html ${2#*:}
- exit
- ;;
- -noshowlog)
- #-do not show the log file
- [[ $2 = doc || $2 = help ]] && isarg $1 $2
- quiet=1
- ;;
- -o|-output) #<filename>
- #-filename of the output stream
- echo "$2" | grep -q '/' && [[ ! -d ${2%/*} ]] && echo "**ERROR: [$PROGNAME] directory ${2%/*} argument of '$1' not found" && exit 1
- output=$2
- shift
- ;;
- -a) #<n>
- # aspect ratio VCD SVCD DVD
- # 1 - 1:1 x * x x = mpeg2enc and mencoder
- # 2 - 4:3 x x x * = mencoder only
- # 3 - 16:9 x x x
- #- 4 - 2.21:1 * x
- MPEG2ENCOPT="$MPEG2ENCOPT -a $2"
- [[ $2 -eq 0 ]] && MPEG2ENCOPT="${MPEG2ENCOPT% ${2}} 1"
- mpegaspect=$2
- isarg $1 "$2" direct
- shift
- ;;
- -mpegfixaspect) #[pad|crop]
- # force the aspect ratio of the source video to match the one
- # specified with -a; this can be done padding the video with
- #-black lines or cropping the video; the default is padding
- [[ $2 = doc || $2 = help ]] && isarg $1 $2 aspect
- mpegfixaspect=0
- if [[ $2 = pad || $2 = crop ]]; then
- [[ $2 = crop ]] && mpegfixaspect=1
- shift
- fi
- ;;
- -rotate) #<0-3>
- # rotate the source video by 90 degrees; set -mpegfixaspect;
- # 0 rotate clockwise and flip, 1 rotate clockwise
- #-2 rotate counterclockwise, 3 rotate counterclockwise and flip
- rotate=1
- echo "$2" | grep -q '^[0-3]$' && rotate=$2
- isarg $1 "$2" aspect
- shift
- : ${mpegfixaspect:=0}
- ;;
- -overscan) #<n>
- # shrink the video of n% and surround it with black borders,
- # n can be 1-99, using 10 should make visible on a TV the full video
- # image; if n is negative, the result is a magnification of the
- # central part of the image; n>0 set -mpegfixaspect pad, n<0 set
- #--mpegfixaspect crop; in Avi Mode n can only be positive
- echo "$2" | grep -qE '^-?[0-9]?[0-9]$' && overscan=$2
- [[ ${2:0:1} = - ]] && mpegfixaspect=1 || mpegfixaspect=0
- isarg $1 "${2#-}" $( ((step==1)) && echo Avi || echo aspect)
- shift
- ;;
- -abr) #<n>
- #-audio bit rate of the VCD/SVCD/DVD [MP2:224,MP3:128,AC3:448]
- if [[ $2 = list ]]; then
- sed '/^check_abr/,/case/!d;/'"$audioformat"':/!d;/[^0-9]'"$asr"'/!d;s/[^)]*)//;s/ */ /g;s/^/'"$audioformat $asr"'/' "$PROGFILE"
- exit
- fi
- abr=$2
- isarg $1 "$2" direct
- shift
- ;;
- -asr) #<n>
- #-audio sample rate of the VCD/SVCD/DVD [MP2/MP3:44100,AC3:48000]
- asr=$2
- isarg $1 "$2" direct
- shift
- ;;
- -vbr) #<n>
- #-video bit rate of the VCD/SVCD/DVD [VCD:1152,SVCD:2500,DVD:7500]
- vbr=$2
- isarg $1 "$2" direct
- shift
- ;;
- -vfr) #<n>
- # video frame rate of the output stream
- # [NTSC/VCD:4,NTSC/SVCD-DVD:1,PAL:3,AVI:2]
- # 1 - 24000.0/1001.0 (NTSC 3:2 pulldown converted FILM)
- # 2 - 24.0 (NATIVE FILM)
- # 3 - 25.0 (PAL/SECAM VIDEO / converted FILM)
- # 4 - 30000.0/1001.0 (NTSC VIDEO)
- # 5 - 30.0
- # 6 - 50.0 (PAL FIELD RATE)
- # 7 - 60000.0/1001.0 (NTSC FIELD RATE)
- #- 8 - 60.0
- vfr=$2
- isarg $1 "$2" direct
- shift
- ;;
- -n|-video-norm) #<n|p|s>
- # 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 ;;
- s|S|secam|SECAM) videonorm=s ;;
- doc|help) isarg $1 $2 direct ;;
- *) echo "**ERROR: [$PROGNAME] invalid argument '$2' for option '$1'" ; "$PROGFILE" -norc $1 help ; exit 1 ;;
- esac
- shift
- ;;
- -p|-pulldown|-telecine) #
- # set a flag in the output stream of the SVCD/DVD that tell the
- # decoder to play the movie as NTSC video using "3:2 pull-down"
- #-instead of "-vfr 4" use "-vfr 1 -p" (smaller output stream)
- [[ $2 = doc || $2 = help ]] && isarg $1 $2 direct
- telecine=1
- ;;
- -res) #<1-7>
- # force one of the following video resolutios:
- # PAL NTSC
- # 1 352x288 352x240 (VCD)
- # 2 352x576 352x480 (CVD)
- # 3 480x576 480x480 (SVCD)
- # 4 528x576 528x480 (KVCD)
- # 5 544x576 544x480 (KVCD)
- # 6 704x576 704x480 (DVB)
- #- 7 720x576 720x480 (DVD)
- isarg $1 "$2" direct
- echo "$2" | grep -q '^[1-7]$' && MPGRES=$2
- shift
- ;;
- -gop) #<n>
- # set the number of pictures per GOP; the default value is the one
- #-required by the standard
- isarg $1 "$2" direct
- GOP=$2
- shift
- ;;
- -kvcd) #<1-4>
- # generate KVCD (www.kvcd.net) compliant frames on output; the
- # following resolutions are possible:
- # PAL NTSC GOP
- # 1 528x576 528x480 24
- # 2 528x576 528x480 def
- # 3 544x576 544x480 24
- #- 4 544x576 544x480 def
- isarg $1 "$2" direct
- a=1
- echo "$2" | grep -q '^[1-4]$' && a=$2
- shift 2
- set -- " " -qmatrix kvcd -res $((3+(a+1)/2)) $([[ $a = [13] ]] && echo "-gop 24") "$@"
- ;;
- -vcd) #
- #-generate VCD compliant frames on output (default)
- [[ $2 = doc || $2 = help ]] && isarg $1 $2 direct
- frameformat=VCD
- ;;
- -svcd) #[1-2]
- # generate SVCD compliant frames on output; the following resolutions
- # are possible: PAL NTSC
- # 1 480x576 480x480
- # 2 352x288 352x240
- #-default is 1
- [[ $2 = doc || $2 = help ]] && isarg $1 $2 direct
- frameformat=SVCD
- frameres=1
- echo "$2" | grep -q '^[1-2]$' && frameres=$2 && shift
- ;;
- -svcdht) #
- # enable the VCD header trick; this trick could allow to play SVCD on
- # DVD player that does not support SVCD. For more details see:
- #-http://www.videohelp.com/svcd
- [[ $2 = doc || $2 = help ]] && isarg $1 $2 direct
- trick=1
- ;;
- -dvd) #[1-5]
- # generate DVD compliant frames on output; the following resolutions
- # are possible: PAL NTSC
- # 1 720x576 720x480
- # 2 704x576 704x480
- # 3 480x576 480x480 (non standard DVD-SVCD)
- # 4 352x576 352x480
- # 5 352x288 352x240
- #-default is 1
- [[ $2 = doc || $2 = help ]] && isarg $1 $2 direct
- frameformat=DVD
- frameres=1
- echo "$2" | grep -q '^[1-5]$' && frameres=$2 && shift
- ;;
- -vcodec) #<mpeg1|mpeg2|mpeg4>
- #-force the selected video codec [VCD:mpeg1,SVCD-DVD:mpeg2,AVI:mpeg4]
- isarg $1 "$2" Avi
- [[ $2 = mpeg[124] ]] && vcodec=$2 && [[ ${vcodec:4:1} = [12] ]] && vcodec=${vcodec}video
- shift
- ;;
- -qmatrix) #<kvcd|tmpgenc|default|hi-res>
- # mpeg2enc custom quantization matrices: kvcd produce a smaller
- #-output stream, hi-res is good for hi-quality source material
- case $2 in
- kvcd|tmpgenc|default|hi-res)
- MPEG2ENCOPT="$MPEG2ENCOPT -K $2"
- intra_matrix=$(eval echo \$${2/-}_intra)
- inter_matrix=$(eval echo \$${2/-}_inter)
- ;;
- *)
- MPEG2ENCOPT="$MPEG2ENCOPT -K default"
- intra_matrix=
- inter_matrix=
- ;;
- esac
- isarg $1 "$2" direct
- shift
- ;;
- -mpeg1vbr) #
- # produce a VCD/MPEG-1 variable bit rate stream, the output stream
- # is smaller and a complete movie could fit in one VCD; check if
- #-your hardware player support variable bit rate VCD
- [[ $2 = doc || $2 = help ]] && isarg $1 $2 direct
- MPEG2ENCOPT="$MPEG2ENCOPT -q 8"
- LAVC=":vrc_buf_size=327"
- ;;
- -mpegmbr) #<n>
- # set the maximum video bit rate; the default is the value of vbr;
- #-a value of 0 remove the limit
- mpegmbr=$2
- [[ $2 -eq 0 ]] && mpegmbr=
- isarg $1 "$2" mpeg
- shift
- ;;
- -mpegchannels) #<1-6>
- # 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
- isarg $1 "$2" direct
- echo "$2" | grep -q '^[1-6]$' && mpegchannels=$2
- shift
- ;;
- -normalize)
- #-normalize to the audio stream(s)
- [[ $2 = doc || $2 = help ]] && isarg $1 $2 $([[ $encode ]] && echo Avi || echo direct)
- normalize=1
- ;;
- -volume) #<n>
- # change amplitude of the audio stream; less than 1.0 decreases,
- #-greater than 1.0 increases (float)
- volume=$2
- isarg $1 "$2" direct
- shift
- ;;
- -noscale) #
- # 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=
- ;;
- -monochrome)
- #-create B/W video or avoid color artifacts in B/W source streams
- [[ $2 = doc || $2 = help ]] && isarg $1 $2 direct
- YUVSCALEROPT="$YUVSCALEROPT -O MONOCHROME"
- ;;
- -split) #<n>
- #-split the resulting MPEG stream in <n> MB chunks.
- split=$2
- isarg $1 "$2" direct
- shift
- ;;
- -encode) #<n:m:i[,b]>
- # the parameter n:m:i selects the audio codec, video codec options
- # and number of pass for mencoder, possible values are:
- # n m i
- # 0 copy 0 copy 1
- # 1 pcm 1 libavcodec/mpeg 2
- # 2 mp3lame/fast 2 as 1 + mbd=2 3
- # 3 mp3lame/standard 3 as 1 + compression opts
- # 4 libavcodec/mp2 4 as 1 + quality opts
- # 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-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
- # not work properly; normally encode2mpeg is able to detect telecined
- # 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
- telesrc=1
- ;;
- -turbo) #<0-1>
- # disable (0) or force (1) turbo mode for the first pass of N pass
- #-encoding (N>1)
- echo "$2" | grep -q '^[0-1]$' && turbo=$2
- isarg $1 "$2" Avi
- shift
- ;;
- -hispeed) #
- # 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 MPEG-4/AVI or a DVD.
- [[ $2 = doc || $2 = help ]] && isarg $1 $2 Avi
- hispeed=1
- ;;
- -bframes) #<0-4>
- # specify the number of B frames; if -encode is n:3:i the default 2,
- #-otherwise the default is no B frames; for VCD the default is 2
- echo "$2" | grep -q '^[0-4]$' && bframes=$2
- isarg $1 "$2" Avi
- shift
- ;;
- -vcustom) #<libavcodec options>
- # specify a custom set of video options for libavcodec, use with
- #--encode n:1:i
- vcustom=$2
- isarg $1 "$2" Avi
- shift
- ;;
- -acustom) #<mp3lame options>
- # 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
- ;;
- -encsid) #<sid0,sid1,...>
- #-dump the DVD vobsub, sid is the number you give the -sid option
- # of MPlayer.
- encsid=( ${2//,/ } )
- isarg $1 "$2" subtitle
- shift
- ;;
- -encsdx) #<sid0,sid1,...>
- # if you dump subtitle 2 and 4 and you want them to have id 0 and 1
- #-use -encsid 2,4 -encsdx 0,1
- encsdx=( ${2//,/ } )
- isarg $1 "$2" subtitle
- shift
- ;;
- -encsla) #<sla0,sla1,...>
- #-see doc/html/subtitle.html
- encsla=( ${2//,/ } )
- isarg $1 "$2" subtitle
- shift
- ;;
- -usespeed) #
- # do frame rate conversion changing the playback speed; this option
- # can be used if you are converting from NTSC 24fps, with or without
- # telecine, to PAL 25fps and viceversa; during normal frame rate
- # conversion, frames are skipped or duplicated as needed; with this
- #-option all the frames are encoded
- [[ $2 = doc || $2 = help ]] && isarg $1 $2 mpeg
- usespeed=1
- ;;
- -usesbr) #[1-6|>100]
- # use the suggested video bitrate to set the output stream size
- # 1 - for 650MB CD 4 - for 2 x 650MB CD
- # 2 - for 700MB CD (default) 5 - for 2 x 700MB CD
- # 3 - for 800MB CD 6 - for 2 x 800MB CD
- # n where n > 100 will set the file size to n MB
- #-with -multiaudio you must to set the streamsize in MB
- usesbr=2
- SBR=(650 700 800 "2 x 650" "2 x 700" "2 x 800")
- echo "$2" | grep -q '^[1-6]$' && usesbr=$2 && shift
- echo "$2" | grep -qE '^[1-9][0-9]{2,}$' && usesbr=$2 && shift
- [[ $2 = doc || $2 = help ]] && isarg $1 $2 Avi
- ;;
- -cpu) #<n>
- #-number of cpu to use, default all the cpu present in the system
- cpu=1
- echo "$2" | grep -q '^[1-8]$' && cpu=$2
- isarg $1 "$2" Avi
- shift
- ;;
- -interlaced)
- #-turn on optimization for interlaced source video.
- [[ $2 = doc || $2 = help ]] && isarg $1 $2 $([[ $mpeg ]] && echo mpeg || echo Avi)
- interlaced=1
- ;;
- -slidefps) #<n>
- # 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
- isarg $1 "$2" images
- slidefps=$(awk -v a=$2 'BEGIN{printf("%.3f",1/a)}')
- shift
- ;;
- -slideaudio) #<audio file>
- # use the content of <audio file> as audio stream when creating video
- #-from pictures; it works correctly only if used with mf://singlepic
- slideaudio=$2
- if [[ ! -f $2 && $2 != /dev/null ]]; then
- [[ $2 = doc || $2 = help || ! $2 ]] && isarg $1 "$2" images || ! echo "**ERROR: [$PROGNAME] slide audio file '$2' not found" || exit 1
- fi
- shift
- ;;
- -norc)
- #-do not use the settings in the file $HOME/.encode2mpegrc
- [[ $2 = doc || $2 = help ]] && isarg $1 $2 rc
- ;;
- -debug)
- # make a more verbose log file and creates a debug file; if you are
- # submitting a bug report, use this option and compress and send the
- #-log file and the debug file
- [[ $2 = doc || $2 = help ]] && isarg $1 $2
- echo "$2" | grep -q '^[0-7]$' && DEBUG=$2 && shift || DEBUG=3
- ;;
- (-frames)
- frames=$2
- isarg $1 $2
- shift
- ;;
- (-channels)
- channels=$2
- isarg $1 $2
- shift
- ;;
- (-srate)
- MPLAYEROPT=( "${MPLAYEROPT[@]}" -srate $2 -af-adv force=1 )
- srate=$2
- isarg $1 $2
- shift
- ;;
- (-endpos)
- endpos=$2
- isarg $1 $2
- shift
- ;;
- (-hr-edl-seek)
- MENCODEROPT=( "${MENCODEROPT[@]}" $1 )
- ;;
- (-vf)
- vf="-vf $2"
- MPLAYEROPT=( "${MPLAYEROPT[@]}" $vf )
- isarg $1 $2
- shift
- ;;
- (-af)
- af="-af $2"
- isarg $1 $2
- shift
- ;;
- (-dvd-device)
- dvddev=$2
- isarg $1 $2
- shift
- ;;
- (mf://*)
- MPLAYEROPT[${#MPLAYEROPT[*]}]=$1
- pictsrc=1
- a=$IFS
- IFS=,
- PICTSRC=( ${1#mf://} )
- IFS=$a
- srate=48000
- ;;
- (-sub)
- [[ ! -f $2 ]] && echo "**ERROR: [$PROGNAME] subtitle file '$2' not found" && exit 1
- MPLAYEROPT=( "${MPLAYEROPT[@]}" $1 "$2" )
- subrender=1
- shift
- ;;
- (-mpeg|-mpegonly|-nosplit) ;;
- *)
- if [[ ! $TOOL ]]; then
- [[ ${1:0:1} = - ]] && ! echo "${MOPT[@]}" | grep -q "\"${1#-}\"" && \
- echo -e "Unknown option $1\nIf this is a valid MPlayer option add '-toolopts mplayer' in front of it" && exit 1
- MPLAYEROPT[${#MPLAYEROPT[*]}]=$1
- else
- case $TOOL in
- *)
- MPLAYEROPT[${#MPLAYEROPT[*]}]=$1
- ;;
- esac
- fi
- ;;
- esac
- shift
-done
-
-[[ -s ~/.encode2mpegrc && ! $norc ]] && do_log " INFO: [$PROGNAME] using .encode2mpegrc settings: '$(<~/.encode2mpegrc)'"
-if [[ $subrender || $harddup ]]; then
- if [[ $vf ]]; then
- vf=$vf${subrender:+,expand=::::1}
- [[ $harddup ]] && ! echo $vf | grep -q harddup && vf=$vf,harddup
- for ((a=0;a<${#MPLAYEROPT[*]};a++)); do
- [[ ${MPLAYEROPT[a]} = -vf ]] && MPLAYEROPT[a+1]=${vf#-vf }
- done
- else
- vf="-vf ${subrender:+expand=::::1}${harddup:+${subrender:+,}harddup}"
- MPLAYEROPT=( "${MPLAYEROPT[@]}" $vf )
- fi
-fi
-
-###############################################################################
-#### debug part
-###############################################################################
-if ((DEBUG)); then
- if ((DEBUG & 1)); then
- #### redirect stdout and stderr to the debug file
- exec 3>&1
- rm -f "$output".debug.fifo
- mkfifo "$output".debug.fifo
- tee "$output".debug <"$output".debug.fifo >&3 &
- PROCTEE=$!
- exec &>"$output".debug.fifo
- trap 'rm "$output".debug.fifo' 0
- fi
- if ((DEBUG & 2)); then
- #### catch mplayer/mencoder errors
- mplayer () {
- command mplayer "$@"
- ret=$? ; (( ret )) && error_line "$FUNCNAME $*" || true
- }
- mencoder () {
- command mencoder "$@"
-