--- mplayer.sh 2002-05-06 22:08:25.000000000 +0200 +++ /video/plugins/mplayer.sh 2003-01-03 02:21:26.000000000 +0100 @@ -1,6 +1,6 @@ #!/bin/bash -declare VERSION="0.0.4" +declare VERSION="0.0.5" # History (as always in the source code :-) # @@ -47,33 +47,29 @@ # Ausgabe: in Variable ORIG_X und ORIG_Y (global) # Variablen Definitionen -local TEMP1 TEMP3 -local -a TEMP2[0] XY[0] -local -i ANZAHL i +local TEMP1 ORIG_X=0; ORIG_Y=0 -TEMP1=`$MPLAYER "$FILE" -frames 0 2>&1 | grep -i -e "VIDEO:"` -TEMP2=($TEMP1) +TEMP1=`$MPLAYER -identify "$FILE" 2>&1 | grep -i -e "^ID_VIDEO_"` debugmsg "OutputFromMPLAYER:" "$TEMP1" -debugmsg "ParsedOutput:" "${TEMP2[*]}" -ANZAHL=${#TEMP2[*]} -if test $ANZAHL -le 4; then debugmsg "NumberOfValues:" $ANZAHL; echolog "*** FATAL: Could not determine Source Video Resolution ..."; exit; fi +ORIG_X=`echo "$TEMP1"|grep ID_VIDEO_WIDTH|cut -d"=" -f2` +debugmsg "parsed output for ORIG_X:" $ORIG_X -TEMP3=${TEMP2[2]} -debugvar "TEMP3(...x...)" $TEMP3 +ORIG_Y=`echo "$TEMP1"|grep ID_VIDEO_HEIGHT|cut -d"=" -f2` +debugmsg "parsed output for ORIG_Y:" $ORIG_Y -IFS="x" -XY=($TEMP3) -unset IFS +ORIG_FPS=`echo "$TEMP1"|grep ID_VIDEO_FPS|cut -d"=" -f2` +debugmsg "parsed output for ORIG_FPS:" $ORIG_FPS +test $ORIG_FPS == "14.985" && ORIG_FPS=29.970 && debugmsg "set ORIG_FPS to:" $ORIG_FPS +test $ORIG_FPS == "15.000" && ORIG_FPS=29.970 && debugmsg "set ORIG_FPS to:" $ORIG_FPS +test $ORIG_FPS == "30.000" && ORIG_FPS=29.970 && debugmsg "set ORIG_FPS to:" $ORIG_FPS -ANZAHL=${#XY[*]} -if ! test $ANZAHL -eq 2; then echolog "*** ERROR: Could not determine Resolution..."; debugmsg "XY splitted into" "$ANZAHL" exit; fi +ORIG_ASPECT=`echo "$TEMP1"|grep ID_VIDEO_ASPECT|cut -d"=" -f2` +debugmsg "parsed output for ORIG_ASPECT:" $ORIG_ASPECT -ORIG_X=${XY[0]} -ORIG_Y=${XY[1]} return; } @@ -82,17 +78,31 @@ local -i TEMP1 MAX_X FACT ANZAHL -# 768 -MAX_X=$((4*576/3)) ; debugvar MAX_X $MAX_X +if test $ORIG_FPS == "29.970"; then + if test $ORIG_X -gt 320 -o $ORIG_Y -gt 240; then + # 640 + MAX_X=$((4*480/3)) ; debugvar MAX_X $MAX_X + else + # 320 + MAX_X=$((4*240/3)) ; debugvar MAX_X $MAX_X + fi + test $NEW_Y -gt 480 && NEW_Y=480 # Force FullScreen / Verzichtet auf Aspect Ratio ! + # NEW_X=$(($NEW_Y*$ORIG_X/$ORIG_Y)); +else + if test $ORIG_X -gt 384 -o $ORIG_Y -gt 288; then + # 768 + MAX_X=$((4*576/3)) ; debugvar MAX_X $MAX_X + else + # 384 + MAX_X=$((4*288/3)) ; debugvar MAX_X $MAX_X + fi + test $NEW_Y -gt 576 && NEW_Y=576 # Force FullScreen / Verzichtet auf Aspect Ratio ! + # NEW_X=$(($NEW_Y*$ORIG_X/$ORIG_Y)); +fi NEW_Y=$(($MAX_X*ORIG_Y/$ORIG_X)); debugvar NEW_Y $NEW_Y # NEW_X=$ORIG_X # Hardware Skaling -if test $NEW_Y -gt 576; - then NEW_Y=576 # Force FullScreen / Verzichtet auf Aspect Ratio ! -# NEW_X=$(($NEW_Y*$ORIG_X/$ORIG_Y)); -fi - echolog "*** INFO: For Sqare Pixels we would scale to $MAX_X x $NEW_Y ..." @@ -104,17 +114,24 @@ function choosebestx () { local -i MAX_X INDEX +local XResTEMP +if test $ORIG_FPS == "29.970"; then + XResTEMP=(${XResNTSC[*]}) +else + XResTEMP=(${XResPAL[*]}) +fi +debugvar XResTEMP "${XResTEMP[*]}" -ANZAHL=${DVBsXRes#} -debugvar AnzahlVonDVBsXRes $ANZAHL +ANZAHL=${#XResTEMP[*]} +debugvar AnzahlVonXResTEMP $ANZAHL INDEX=-1 declare repeat=true until ! $repeat; do INDEX=$(($INDEX+1)) - if test ${DVBsXRes[$INDEX]} -ge $ORIG_X; then repeat=false; NEW_X=${DVBsXRes[$INDEX]}; fi - if test $INDEX -ge $ANZAHL; then repeat=false; NEW_X=${DVBsXRES[$ANZAHL]}; fi + if test ${XResTEMP[$INDEX]} -ge $ORIG_X; then repeat=false; NEW_X=${XResTEMP[$INDEX]}; fi + if test $INDEX -ge $ANZAHL; then repeat=false; NEW_X=${XResTEMP[$ANZAHL]}; fi done debugvar NEW_X $NEW_X @@ -219,8 +236,14 @@ declare -i ORIG_X ORIG_Y declare -i NEW_X NEW_Y +declare ORIG_FPS ORIG_ASPECT declare CMDLINE declare FILE=$1 +SLAVE="-slave -nolirc" + +if [ "$2" != "SLAVE" ]; then + SLAVE="" +fi echolog "*** Starting mplayer.sh Version $VERSION" @@ -267,9 +290,13 @@ if ! test -z "$USERDEF"; then echolog "*** Use Option USERDEF at your own risk !"; fi debugvar USERDEF "${USERDEF[*]}" -declare -a DVBsXRes[0] -declare DVBsXRes=(`readcfg DVBsXRes`) -if test -z $DVBsXRes; then errorcfg DVBsXRes; exit; else debugvar DVBsXRes "$DVBsXRes"; fi +declare -a XResPAL[0] +declare XResPAL=(`readcfg XResPAL`) +if test -z $XResPAL; then errorcfg XResPAL; exit; else debugvar XResPAL "${XResPAL[*]}"; fi + +declare -a XResNTSC[0] +declare XResNTSC=(`readcfg XResNTSC`) +if test -z $XResNTSC; then errorcfg XResNTSC; exit; else debugvar XResNTSC "${XResNTSC[*]}"; fi # Try to determine the video attributes @@ -279,24 +306,63 @@ echolog "*** INFO: Source Video has Resolution of $ORIG_X x $ORIG_Y ..." -if test $ORIG_X -eq 0 || test $ORIG_Y -eq 0; then echolog "*** FATAL: Illegal Resolution ..."; exit; fi +if test $ORIG_X -eq 0 -o $ORIG_Y -eq 0; then echolog "*** FATAL: Illegal Resolution ..."; exit; fi -if test $ORIG_Y -eq 576; - then echolog "*** FIXME: Add check in DVBsXRes - if not contained, apply skaling" #FIXME - CMDLINE="$MPLAYER -vo mpegpes -ao mpegpes -afm 9 -vop $VOP $FDSTR $CACHESTR $LIRCSTR $USERDEF" - debugvar CMDLINE "$CMDLINE" - exec $CMDLINE "$FILE" - - echo "*** Done."; - else calcnewxy choosebestx - echolog "*** Scaling to $NEW_X x $NEW_Y for DVBs Output..." - CMDLINE="$MPLAYER -vo mpegpes -ao mpegpes -afm 9 -vop $VOP,expand=$NEW_X:576,scale=$NEW_X:$NEW_Y $FDSTR $CACHESTR $LIRCSTR $USERDEF" -# CMDLINE="$MPLAYER -vo mpegpes -ao mpegpes -afm 9 -vop $VOP,scale=$NEW_X:$NEW_Y,expand=$NEW_X:576 $FDSTR $CACHESTR $LIRCSTR $USERDEF" + case $ORIG_FPS in + "23.976") + debugmsg "Film" + ;; + + "25.000") + debugmsg "PAL" + case $ORIG_Y in + "288"|"576") + CMDLINE="$MPLAYER -vo mpegpes -ao mpegpes -afm 9 -vop $VOP=-1:$ORIG_FPS,expand=-1:-1:-1:-1:1,scale=-1:-1 $FDSTR $CACHESTR $LIRCSTR $USERDEF $SLAVE" + ;; + + *) + ;; + esac + ;; + + "29.970") + debugmsg "NTSC" + if test \( $ORIG_Y -eq 240 -o $ORIG_Y -eq 480 \) -a $ORIG_X -ne 320; then + CMDLINE="$MPLAYER -vo mpegpes -ao mpegpes -afm 9 -vop $VOP=-1:$ORIG_FPS,expand=-1:-1:-1:-1:1,scale=-1:-1 $FDSTR $CACHESTR $LIRCSTR $USERDEF $SLAVE" + else + if test $ORIG_X > 352 -o $ORIG_Y > 240; then + debugmsg "ORIG_Y greater than 240:" $ORIG_Y + CMDLINE="$MPLAYER -vo mpegpes -ao mpegpes -afm 9 -vop $VOP=-1:$ORIG_FPS,expand=$NEW_X:480:-1:-1:1,scale=$NEW_X:$NEW_Y $FDSTR $CACHESTR $LIRCSTR $USERDEF $SLAVE" + else + debugmsg "ORIG_Y less than or equal to 240:" $ORIG_Y + CMDLINE="$MPLAYER -vo mpegpes -ao mpegpes -afm 9 -vop $VOP=-1:$ORIG_FPS,expand=$NEW_X:240:-1:-1:1,scale=$NEW_X:$NEW_Y $FDSTR $CACHESTR $LIRCSTR $USERDEF $SLAVE" + fi + fi + ;; + + *) + debugmsg "unknown FPS" $ORIG_FPS + ;; + esac + if test $NEW_X -eq 0 -o $NEW_Y -eq 0; then echolog "*** FATAL: Illegal Resolution ..."; exit; fi + if test -z $CMDLINE; then + if test $ORIG_X -gt 384 -o $ORIG_Y -gt 288; then + debugmsg "ORIG_Y greater than 288:" $ORIG_Y + CMDLINE="$MPLAYER -vo mpegpes -ao mpegpes -afm 9 -vop $VOP=-1:25,expand=$NEW_X:576:-1:-1:1,scale=$NEW_X:$NEW_Y $FDSTR $CACHESTR $LIRCSTR $USERDEF $SLAVE" + else + debugmsg "ORIG_Y less than or equal to 288:" $ORIG_Y + CMDLINE="$MPLAYER -vo mpegpes -ao mpegpes -afm 9 -vop $VOP=-1:25,expand=$NEW_X:288:-1:-1:1,scale=$NEW_X:$NEW_Y $FDSTR $CACHESTR $LIRCSTR $USERDEF $SLAVE" + fi + echolog "*** Scaling to $NEW_X x $NEW_Y for DVBs Output..." + fi +# CMDLINE="$MPLAYER -vo mpegpes -ao mpegpes -afm 9 -vop $VOP=-1:$ORIG_FPS,expand=$NEW_X:576:-1:-1:1,scale=$NEW_X:$NEW_Y $FDSTR $CACHESTR $LIRCSTR $USERDEF $SLAVE" + #CMDLINE="$MPLAYER -vo mpegpes -ao mpegpes -afm 9 -vop $VOP=-1,$ORIG_FPS,expand=$NEW_X:576,scale=$NEW_X:$NEW_Y $FDSTR $CACHESTR $LIRCSTR $USERDEF $SLAVE" +# CMDLINE="$MPLAYER -vo mpegpes -ao mpegpes -afm 9 -vop $VOP,scale=$NEW_X:$NEW_Y,expand=$NEW_X:576 $FDSTR $CACHESTR $LIRCSTR $USERDEF $SLAVE" debugvar CMDLINE "$CMDLINE" exec $CMDLINE "$FILE" - echo "*** Done."; -fi