diff options
author | LarsAC <LarsAC@e10066b5-e1e2-0310-b819-94efdf66514b> | 2005-07-29 23:00:53 +0000 |
---|---|---|
committer | LarsAC <LarsAC@e10066b5-e1e2-0310-b819-94efdf66514b> | 2005-07-29 23:00:53 +0000 |
commit | 335def9f61ce75a3857bd21745c629005c37db79 (patch) | |
tree | daae8b1105c422542181a4bf5568f684b6e955b9 /scripts | |
parent | da2367d81a6a117554b31080a6e722b51150b8f8 (diff) | |
download | vdr-plugin-muggle-335def9f61ce75a3857bd21745c629005c37db79.tar.gz vdr-plugin-muggle-335def9f61ce75a3857bd21745c629005c37db79.tar.bz2 |
Merged from 0.1.7-wr
git-svn-id: https://vdr-muggle.svn.sourceforge.net/svnroot/vdr-muggle/trunk/muggle-plugin@791 e10066b5-e1e2-0310-b819-94efdf66514b
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/image_convert.sh | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/scripts/image_convert.sh b/scripts/image_convert.sh new file mode 100755 index 0000000..1fbe153 --- /dev/null +++ b/scripts/image_convert.sh @@ -0,0 +1,80 @@ +#!/bin/bash +# +# requires: ...topnm, pnmscale, pnmcomp, ppmntsc, ppmtoy4m, mpeg2enc +# + +# video format. pal or ntsc +FORMAT=pal + +# target image width/height (taking into account visible screen area) +if [ "$FORMAT" = "ntsc" ]; then + TW=600 + TH=420 +else + TW=632 + TH=512 +fi + +TMP=/tmp/image_convert.$$.pnm +IMG=$1 +MPG=$2 + +DIR=`dirname "$MPG"` +if [ ! -d "$DIR" ]; then + mkdir -p "$DIR" +fi +# +# get the file type and set the according converter to PNM +# +FILE_TYPE=`file -i -L -b "$IMG" 2>/dev/null | cut -f2 -d/` +case "$FILE_TYPE" in + jpg | jpeg) + TO_PNM=jpegtopnm + ;; + tiff) + TO_PNM=tifftopnm + ;; + bmp | x-bmp) + TO_PNM=bmptoppm + ;; + png | x-png) + TO_PNM=pngtopnm + ;; + Netpbm | pnm | x-portable-pixmap) + TO_PNM=cat + ;; + gif) + TO_PNM=giftopnm + ;; + *) + echo "filetype '$FILE_TYPE' is not supported" + exit 1 + ;; +esac +# +# extract the image size & compute scale value +# +LANG=C # get the decimal point right +$TO_PNM "$IMG" >$TMP 2>/dev/null +S=`pnmfile $TMP | awk '{ printf "%d %d ",$4,$6 }'` +S=`echo $S $TW $TH | awk '{ sw=$3/$1; sh=$4/$2; s=(sw<sh)?sw:sh; printf "%.4f\n",(s>1)?1.0:s; }'` +# +# now run the conversion +# +if [ "$FORMAT" = "ntsc" ]; then + pnmscale $S $TMP | \ + pnmpad -black -width 704 -height 480 | \ + ppmntsc | \ + ppmtoy4m -v 0 -n 1 -r -F 30000:1001 | \ + mpeg2enc -f 7 -T 90 -F 4 -nn -a 2 -v 0 -o "$MPG" +else + pnmscale $S $TMP | \ + pnmpad -black -width 704 -height 576 | \ + ppmntsc --pal | \ + ppmtoy4m -v 0 -n 1 -r -F 25:1 | \ + mpeg2enc -f 7 -T 90 -F 3 -np -a 2 -v 0 -o "$MPG" +fi +# +# cleanup +# +rm $TMP |