encode2mpeglight

来自「君正早期ucos系统(只有早期的才不没有打包成库),MPLAYER,文件系统,图」· 代码 · 共 1,545 行 · 第 1/5 页

TXT
1,545
字号
#!/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 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 <encode2mpeglight options>#   will produce almost the same results as:#     encode2mpeg -mpeg -mpegonly <encode2mpeglight 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 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=POSIXset -B +fshopt -u xpg_echo nullglobPROGNAME=${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 txtsuboptszoom=0scale=1fast=1MAXSTEP=6 # burn is the defaultstep=$MAXSTEPsplit=0vbitrate=16000mpegmbr=0overscan=0iter=0bakiter=0hispeed=0BGTITLE=1TANIM=0TFMT=pngTMODE=0TKFRM=0TSECS=5TPART=4TPARTSEC=15TFONTSIZE=1TFONTBG=1TLINES=2TCPR=2MENUERR=0DVDPLAY=0MENUOS=0TSETB=1DVDFS=1VTSMBG=0menufix=0cdburndevice=0,0,0dvdburndevice=/dev/cdrecorderfsize=;fint=;ffrac=;fpre=;audiosize=0ASPECT=(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 MENCODEROPTLPCMPAR=SUBLANG=unset SUBTEXT AUDIOTEXT CHAPTERTEXT TITLESET EXTWAV PROFILE MSRCunset CLEANDEBUG=0LAVC=WARN=LOG=LG=0SVN=0MAXFIX=20timelen=0ocrsub=0slidefps=1default_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,27default_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,83default_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,16default_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,16hires_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,24hires_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,42hires_inter=$default_interkvcd_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,29kvcd_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,79kvcd_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,26kvcd_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,44tmpgenc_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,27tmpgenc_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,83tmpgenc_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,22tmpgenc_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,33TXTSUBDEF=( 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 defaulsmpeg=1encode=7:2:2(($#)) || ! shortusage || exit 1CMD=( "$@" )#### options arrayMOPT=( $(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            ;;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?