encode2mpeglight
来自「君正早期ucos系统(只有早期的才不没有打包成库),MPLAYER,文件系统,图」· 代码 · 共 1,545 行 · 第 1/5 页
TXT
1,545 行
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 shiftdone[[ -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 ) fifi################################################################################### 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 "$@" ret=$? ; (( ret )) && error_line "$FUNCNAME $*" || true } fi ((DEBUG & 4)) && set -xfi################################################################################### ERROR if some options conflict is detected part 1/2################################################################################### mplayer/mencoderfor a in mplayer mencoder ; do type -f $a &>/dev/null || ! echo "**ERROR: [$PROGNAME] $a missing, install $(echo ${a:0:2} | tr '[:lower:]' '[:upper:]')${a:2}" || exit 1done#### output stream name check[[ ! $output ]] && echo "**ERROR: [$PROGNAME] name of the output stream missing (-o name)" && exit 1#### unspecified video norm[[ ! $videonorm && step -gt 1 && ! ( $mpeg && ${encode%,*} == ?:0:? && ! $menu ) && ${#TITLESET[*]} -eq 0 ]] && \ echo "**ERROR: [$PROGNAME] you must specify a video norm (-n n|p|s)" && exit 1#### libfaac checkif [[ ${encode%,*} == 8:?:? ]]; then ! mencoder -oac help 2>/dev/null | grep -q faac && echo "**ERROR: [$PROGNAME] missing libfaac support in mencoder [-encode 8:m:i]" && exit 1fi#### mpeg4if [[ $vcodec = mpeg4 ]]; then [[ $pictsrc && $step -gt 1 && $mpeg ]] && echo "**ERROR: [$PROGNAME] -vcodec mpeg4, -mpeg and mf://file are not compatible" && exit 1fi#### pictsrcif [[ $pictsrc ]]; then [[ $slideaudio != /dev/null && ${encode%,*} == 0:?:? && $mpeg ]] && \ echo "**ERROR: [$PROGNAME] -encode 0:m:i is not compatible with mf:// in MPEG Mode" && exit 1 [[ $audioonly ]] && echo "**ERROR: [$PROGNAME] -audioonly does not work with mf://" && exit 1fi#### -encode 1:m:i is not allowed[[ ${encode%,*} == 1:?:? ]] && echo "**ERROR: [$PROGNAME] do not use -encode 1:m:i" && exit 1################################################################################### WARN if some options conflict is detected################################################################################### missing toolame supportif [[ ${encode%,*} == 7:?:? ]]; then if ! mencoder -oac help 2>/dev/null | grep -q t[wo]olame ; then encode=4:${encode#?:} do_log "++ WARN: [$PROGNAME] missing toolame support in mencoder, setting -encode $encode" else mencoder -oac help 2>/dev/null | grep -q toolame && TOOLAME=toolame || TOOLAME=twolame fifi################################################################################### set default values for unspecified parameters###############################################################################if [[ ! $multiaudio ]]; then audiostream=1fi###############################################################################if [[ $encode ]]; then case ${encode%%:*} in 0) [[ ! $pictsrc ]] && AFMT=acopy ;; 2|3|5) AFMT=mp3 ;; 4|7) AFMT=mp2 ;; 6) AFMT=ac3 ;; 8) AFMT=aac ;; esac [[ $AFMT ]] && eval : ${audioformat:-\${$AFMT:=copy\}}fi: ${frameformat:=VCD}: ${audioformat:=${AFMT:-mp2}}: ${mp1:=mp2enc}((${mpegchannels:-2}>2)) && : ${mp2:=musicin} || : ${mp2:=mp2enc}: ${mp3:=lame}: ${ac3:=mencoder}: ${dts:=copy}: ${aac:=faac}case $audioformat in mp1) case ${mpegchannels:-2} in 1) : ${abr:=192} ;; 2) : ${abr:=384} ;; esac ;; mp2) case ${mpegchannels:-2} in 1) : ${abr:=112} ;; 2) : ${abr:=224} ;; [3-6]) : ${abr:=384} ;;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?