From badc033ef7dcbf1f322627b37403f969cc70c41d Mon Sep 17 00:00:00 2001 From: diego Date: Mon, 7 Jul 2008 09:30:22 +0000 Subject: Give all shell scripts a .sh suffix for consistency. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27230 b3059339-0415-0410-9bf9-f77b7e298cf2 --- TOOLS/README | 34 +- TOOLS/aconvert | 13 - TOOLS/aconvert.sh | 13 + TOOLS/divx2svcd | 369 --------- TOOLS/divx2svcd.sh | 369 +++++++++ TOOLS/encode2mpeglight | 2000 --------------------------------------------- TOOLS/encode2mpeglight.sh | 2000 +++++++++++++++++++++++++++++++++++++++++++++ TOOLS/mencvcd | 440 ---------- TOOLS/mencvcd.sh | 440 ++++++++++ TOOLS/midentify | 18 - TOOLS/midentify.sh | 18 + TOOLS/mpconsole | 12 - TOOLS/mpconsole.sh | 12 + 13 files changed, 2869 insertions(+), 2869 deletions(-) delete mode 100755 TOOLS/aconvert create mode 100755 TOOLS/aconvert.sh delete mode 100755 TOOLS/divx2svcd create mode 100755 TOOLS/divx2svcd.sh delete mode 100755 TOOLS/encode2mpeglight create mode 100755 TOOLS/encode2mpeglight.sh delete mode 100755 TOOLS/mencvcd create mode 100755 TOOLS/mencvcd.sh delete mode 100755 TOOLS/midentify create mode 100755 TOOLS/midentify.sh delete mode 100755 TOOLS/mpconsole create mode 100755 TOOLS/mpconsole.sh (limited to 'TOOLS') diff --git a/TOOLS/README b/TOOLS/README index baf072ef26..7acf57daef 100644 --- a/TOOLS/README +++ b/TOOLS/README @@ -25,24 +25,24 @@ Description: Examples of custom fragment program for OpenGL video out driver Usage: mplayer -vo gl:yuv=4:customprog=edgedetect.fp -midentify +midentify.sh Author: Tobias Diedrich Description: Runs 'mplayer -identify' for all arguments while preventing video window flashing. -Usage: midentify file1 [file2 ...] +Usage: midentify.sh file1 [file2 ...] -mpconsole +mpconsole.sh Author: Rich Felker Description: Script to run MPlayer on the console (fbdev/mga_vid/etc.) without the console text and/or flashing cursor getting in the way. -Usage: mpconsole [mplayer options] +Usage: mpconsole.sh [mplayer options] mplmult.sh @@ -90,25 +90,25 @@ Usage: wma2ogg [options] <-f FILE1 | -f FILE2 ... | -a> MEncoder scripts in the TOOLS dir --------------------------------- -divx2svcd +divx2svcd.sh Author: Miklos Vajna Description: A simple utility that creates an SVCD from a video in an AVI container. -Usage: divx2svcd [options] - see 'divx2svcd -h' for more info +Usage: divx2svcd.sh [options] + see 'divx2svcd.sh -h' for more info -mencvcd +mencvcd.sh Author: Jürgen Hammelmann Description: Converts DVD (or anything else that MPlayer plays) to (S)VCD -Usage: mencvcd [mencvcd options] [mplayer options] - see 'mencvcd -h' for more info +Usage: mencvcd.sh [mencvcd.sh options] [mplayer options] + see 'mencvcd.sh -h' for more info Note: Requires MPlayer, mjpegtools, VCDImager, cdrdao, and optionally LAME, tooLAME and SoX. @@ -143,14 +143,14 @@ Usage: --help show help --dvd-device device to pull the video off (default: /dev/dvd) -aconvert +aconvert.sh Author: Jonas Jermann Description: A hack to allow MEncoder to read respectively encode from audio only files. -Usage: aconvert <"input file"> <"output file"> <"options"> +Usage: aconvert.sh <"input file"> <"output file"> <"options"> If no options are specified the following is assumed: -oac lavc -lavcopts acodec=mp3:abitrate=192 @@ -173,17 +173,17 @@ Note: You will need vcdimager/cdrecord to master/burn the resulting -encode2mpeglight +encode2mpeglight.sh Author: Giacomo Comes Description: Convert anything MPlayer can play to VCD/SVCD/DVD MPEG. -Usage: encode2mpeglight -o -n [options] +Usage: encode2mpeglight.sh -o -n [options] For help and documentation run: - encode2mpeglight -h - encode2mpeglight -l - encode2mpeglight -doc + 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. diff --git a/TOOLS/aconvert b/TOOLS/aconvert deleted file mode 100755 index 37a031115f..0000000000 --- a/TOOLS/aconvert +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -# Author: Jonas Jermann -# Description: A hack to allow mencoder to encode from an audio only file - -if [ "$1" = "" ]; then - echo "Usage: $0 <\"input file\"> <\"output file\"> <\"options\">" - exit 0 -fi - -options=${3:-"-oac mp3lame"} - -mencoder -demuxer rawvideo -rawvideo w=1:h=1 -ovc copy -of rawaudio -endpos `mplayer -identify $1 -frames 0 2>&1 | grep ID_LENGTH | cut -d "=" -f 2` -audiofile $1 -o $2 $options $1 diff --git a/TOOLS/aconvert.sh b/TOOLS/aconvert.sh new file mode 100755 index 0000000000..37a031115f --- /dev/null +++ b/TOOLS/aconvert.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# Author: Jonas Jermann +# Description: A hack to allow mencoder to encode from an audio only file + +if [ "$1" = "" ]; then + echo "Usage: $0 <\"input file\"> <\"output file\"> <\"options\">" + exit 0 +fi + +options=${3:-"-oac mp3lame"} + +mencoder -demuxer rawvideo -rawvideo w=1:h=1 -ovc copy -of rawaudio -endpos `mplayer -identify $1 -frames 0 2>&1 | grep ID_LENGTH | cut -d "=" -f 2` -audiofile $1 -o $2 $options $1 diff --git a/TOOLS/divx2svcd b/TOOLS/divx2svcd deleted file mode 100755 index 4782dd679c..0000000000 --- a/TOOLS/divx2svcd +++ /dev/null @@ -1,369 +0,0 @@ -#!/bin/bash - -# (c) 2003 Vajna Miklos -# divx2svcd for MPlayer -# distributed under GPL License - -# simple utility that creates a SVCD from a video in an AVI container - -# The newest version of this utility can be found at -# http://vmiklos.uw.hu/divx2svcd/divx2svcd -# MPlayer available at -# http://www.mplayerhq.hu/MPlayer/releases/MPlayer-1.0pre3try2.tar.bz2 - -###changelog### -#nobody cares about it :-) -cat >/dev/null < -- support for toolame instead of mp2enc -- suppert for libavcodec mpeg2video codec instead of mpeg2enc - -0.2 -- support for tcmplex instead of mplex - -0.1rc2-rc4 -- small bugfixes - -0.1rc1 -- initial release - -EOF - - -###preparing### -#help - -usage() -{ - cat </dev/null 2>&1 -bcbin=`which bc 2>/dev/null` -if [ $? != 0 ]; then - cat </dev/null 2>&1 -bcbin=`which vcdimager 2>/dev/null` -if [ $? != 0 ]; then - cat </dev/null 2>&1 -if [ $? = 0 ]; then - tcp_path=`which tcmplex-panteltje 2>&1` -else - tcp_path="x" -fi -which tcmplex >/dev/null 2>&1 -if [ $? = 0 ]; then - tc_path=`which tcmplex 2>&1` -else - tc_path="x" -fi - -if [ -x $tcp_path ]; then - tcbin=tcmplex-panteltje - tcopt=-0 -elif [ -x $tc_path ]; then - tcbin=tcmplex - tcopt=-p -else - cat </dev/null 2>&1 -cdrbin=`which cdrecord 2>/dev/null` -if [ $? != 0 ]; then - cat <= 2.01a14 - echo -n "Checking for cdrecord version >= 2.01a14... " - $cdrbin cuefile=a 2>&1 |grep 'Bad Option' >/dev/null 2>&1 - if [ "$?" = 0 ]; then - cat <= 2.01a14. You can download it at -ftp://ftp.berlios.de/pub/cdrecord/alpha/cdrtools-2.01a20.tar.gz -EOF - else - echo "`$cdrbin -version |cut -d ' ' -f 2`" - fi -fi -fi - -#checking for sub avariable - -if [ -f "$nev.sub" ]; then - subopts=$nev.sub -else - subopts='' -fi - -if [ "x$subopts" = "x" ]; then - subs='' -else - subs='-sub ' -fi - -#checking for what height needed -inputwidth=`mplayer -vo null -ao null "$input" -frames 1 2>/dev/null |grep '=>'|cut -d ' ' -f 5|cut -d x -f 1` -inputheight=`mplayer -vo null -ao null "$input" -frames 1 2>/dev/null |grep '=>'|cut -d ' ' -f 5|cut -d x -f 2` -svcdaspect=`echo -e "scale=10\n1.596/($inputwidth/$inputheight)"|bc /dev/stdin` -height=`echo -e "scale=10\n$svcdaspect*480"|bc /dev/stdin|cut -d . -f 1` - -#checking for ratios less than 1.33 -istoohigh=`expr $height \> 577` -if [ "$istoohigh" = 1 ]; then - height=576 -fi - -#find out the vf options -if [ "$height" = 576 ]; then - vfopts='-vf scale=480:576' -else - #-vf processes filters in reverse order - exy=`echo -e "scale=10\n(576-$height)/2"|bc /dev/stdin|cut -d . -f 1` - vfopts="-vf scale=480:$height,expand=480:576:0:$exy:1" - echo "Using filter options: '$vfopts'" -fi - -#finish displaying informations -if [ "$burning" = 1 ]; then -#asking for cd -cat < template - $tcbin -i "$nev.m2v" $tcopt "$nev.mp2" -o "$nev.mpg" -m s -F template - rm template - rm "$nev.m2v" "$nev.mp2" -fi - -for i in *mpg -do - nev2=`basename "$i" .mpg` - #creating images - vcdimager -t svcd -c "$nev2.cue" -b "$nev2.bin" "$i" - #burning if needs - if [ "$burning" = 1 ]; then - if [ "$firstcd" != 1 ]; then - cat < +# divx2svcd for MPlayer +# distributed under GPL License + +# simple utility that creates a SVCD from a video in an AVI container + +# The newest version of this utility can be found at +# http://vmiklos.uw.hu/divx2svcd/divx2svcd +# MPlayer available at +# http://www.mplayerhq.hu/MPlayer/releases/MPlayer-1.0pre3try2.tar.bz2 + +###changelog### +#nobody cares about it :-) +cat >/dev/null < +- support for toolame instead of mp2enc +- suppert for libavcodec mpeg2video codec instead of mpeg2enc + +0.2 +- support for tcmplex instead of mplex + +0.1rc2-rc4 +- small bugfixes + +0.1rc1 +- initial release + +EOF + + +###preparing### +#help + +usage() +{ + cat </dev/null 2>&1 +bcbin=`which bc 2>/dev/null` +if [ $? != 0 ]; then + cat </dev/null 2>&1 +bcbin=`which vcdimager 2>/dev/null` +if [ $? != 0 ]; then + cat </dev/null 2>&1 +if [ $? = 0 ]; then + tcp_path=`which tcmplex-panteltje 2>&1` +else + tcp_path="x" +fi +which tcmplex >/dev/null 2>&1 +if [ $? = 0 ]; then + tc_path=`which tcmplex 2>&1` +else + tc_path="x" +fi + +if [ -x $tcp_path ]; then + tcbin=tcmplex-panteltje + tcopt=-0 +elif [ -x $tc_path ]; then + tcbin=tcmplex + tcopt=-p +else + cat </dev/null 2>&1 +cdrbin=`which cdrecord 2>/dev/null` +if [ $? != 0 ]; then + cat <= 2.01a14 + echo -n "Checking for cdrecord version >= 2.01a14... " + $cdrbin cuefile=a 2>&1 |grep 'Bad Option' >/dev/null 2>&1 + if [ "$?" = 0 ]; then + cat <= 2.01a14. You can download it at +ftp://ftp.berlios.de/pub/cdrecord/alpha/cdrtools-2.01a20.tar.gz +EOF + else + echo "`$cdrbin -version |cut -d ' ' -f 2`" + fi +fi +fi + +#checking for sub avariable + +if [ -f "$nev.sub" ]; then + subopts=$nev.sub +else + subopts='' +fi + +if [ "x$subopts" = "x" ]; then + subs='' +else + subs='-sub ' +fi + +#checking for what height needed +inputwidth=`mplayer -vo null -ao null "$input" -frames 1 2>/dev/null |grep '=>'|cut -d ' ' -f 5|cut -d x -f 1` +inputheight=`mplayer -vo null -ao null "$input" -frames 1 2>/dev/null |grep '=>'|cut -d ' ' -f 5|cut -d x -f 2` +svcdaspect=`echo -e "scale=10\n1.596/($inputwidth/$inputheight)"|bc /dev/stdin` +height=`echo -e "scale=10\n$svcdaspect*480"|bc /dev/stdin|cut -d . -f 1` + +#checking for ratios less than 1.33 +istoohigh=`expr $height \> 577` +if [ "$istoohigh" = 1 ]; then + height=576 +fi + +#find out the vf options +if [ "$height" = 576 ]; then + vfopts='-vf scale=480:576' +else + #-vf processes filters in reverse order + exy=`echo -e "scale=10\n(576-$height)/2"|bc /dev/stdin|cut -d . -f 1` + vfopts="-vf scale=480:$height,expand=480:576:0:$exy:1" + echo "Using filter options: '$vfopts'" +fi + +#finish displaying informations +if [ "$burning" = 1 ]; then +#asking for cd +cat < template + $tcbin -i "$nev.m2v" $tcopt "$nev.mp2" -o "$nev.mpg" -m s -F template + rm template + rm "$nev.m2v" "$nev.mp2" +fi + +for i in *mpg +do + nev2=`basename "$i" .mpg` + #creating images + vcdimager -t svcd -c "$nev2.cue" -b "$nev2.bin" "$i" + #burning if needs + if [ "$burning" = 1 ]; then + if [ "$firstcd" != 1 ]; then + cat < -# 2006-11-06 -# -# Purpose: Convert anything MPlayer can play to AVI/VCD/SVCD/DVD MPEG -# -# 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. - -# 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 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 -# and eventually extract VobSub subtitles from a DVD using only -# MEncoder/MPlayer. -# -# encode2mpeglight 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 -# will produce almost the same results as: -# encode2mpeg -mpeg -mpegonly -# -# 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 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 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) #[[:][]] - #-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 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) # - # 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) # - # 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) # - #-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) # - #-audio sample rate of the VCD/SVCD/DVD [MP2/MP3:44100,AC3:48000] - asr=$2 - isarg $1 "$2" direct - shift - ;; - -vbr) # - #-video bit rate of the VCD/SVCD/DVD [VCD:1152,SVCD:2500,DVD:7500] - vbr=$2 - isarg $1 "$2" direct - shift - ;; - -vfr) # - # 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) # - # 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) # - # 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) # - #-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) # - # 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) # - # 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) # - # 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) # - #-split the resulting MPEG stream in MB chunks. - split=$2 - isarg $1 "$2" direct - shift - ;; - -encode) # - # 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) # - # specify a custom set of video options for libavcodec, use with - #--encode n:1:i - vcustom=$2 - isarg $1 "$2" Avi - shift - ;; - -acustom) # - # 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) # - #-dump the DVD vobsub, sid is the number you give the -sid option - # of MPlayer. - encsid=( ${2//,/ } ) - isarg $1 "$2" subtitle - shift - ;; - -encsdx) # - # 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) # - #-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) # - #-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) # - # 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) #