On 11/01/07 13:21, Stefan Huelswitt wrote:
> On 01 Nov 2007 Klaus Schmidinger <[EMAIL PROTECTED]> wrote:
> 
>> I'm looking for a method to convert a JPEG image to an
>> MPEG-2 I-frame that can be displayed through VDR's
>> cDevice::StillPicture() function. The conversion should
>> be done by a (sequence of) shell command(s).
> 
> May be something like this:
> 
> #!/bin/bash
> #
> # requires: ...topnm, pnmscale, pnmcomp, ppmntsc, ppmtoy4m, mpeg2enc
> #
> ...

When I display a picture generated with this script through a call
to DeviceStillPicture(), the display looks very nice for a short while,
and after that slanted lines get jagged. It appears as if the two
interlaced half-pictures are first sent in turn, and finally only
one of them is displayed continuously.

Calling DeviceStillPicture() repeatedly in a loop results in the
display jumping between "nice" and "jagged".

So I thought about sending the picture file to the device through
cPlayer::PlayPes() in a continuous loop. For that purpose I have
added a call to 'mplex' to the script, as can be seen in the attachment.

When I display such a still file on a FF DVB card by calling cPlayer::PlayPes()
in a continuous loop, the image on the tv screen looks like it is
displaying both interlaced half-pictures in turn, but it is "jumpy" (as if
the time between displaying the two half pictures is too long).


Does anybody have an idea how this could be improved, so that
I get a smooth display, with slanted lines not jagged (just as if
a still picture was shown in a normal movie)?

Klaus

#!/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

TMP1=/tmp/image_convert.$$.pnm
TMP2=/tmp/image_convert.$$.m2v
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
#
# 'chroma subsampling mode' mjpegtools >= 1.8.0
#
SUBSAMPLINGMODE=""
if ppmtoy4m -h | egrep -q "'420mpeg2'"; then
    SUBSAMPLINGMODE="-S 420mpeg2"
fi
#
# extract the image size & compute scale value
#
LANG=C # get the decimal point right
$TO_PNM "$IMG" >$TMP1 2>/dev/null
S=`pnmfile $TMP1 | 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 $TMP1 | \
    pnmpad -black -width 704 -height 480 | \
    ppmntsc | \
    ppmtoy4m -v 0 -n 1 -r -F 30000:1001 $SUBSAMPLINGMODE | \
    mpeg2enc -f 7 -T 90 -F 4 -nn -a 2 -v 0 -o "$TMP2"
else
  pnmscale $S $TMP1 | \
    pnmpad -black -width 704 -height 576 | \
    ppmntsc --pal | \
    ppmtoy4m -v 0 -n 1 -r -F 25:1 $SUBSAMPLINGMODE | \
    mpeg2enc -f 7 -T 90 -F 3 -np -a 2 -v 0 -o "$TMP2"
fi
mplex -f 7 -o "$MPG" "$TMP2"
#
# cleanup
#
rm $TMP1 $TMP2
_______________________________________________
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr

Reply via email to