[vdr] How to convert a JPEG image to an HD video frame?

Klaus Schmidinger Klaus.Schmidinger at tvdr.de
Sun Aug 14 12:47:22 CEST 2011


On 24.07.2011 20:07, André Weidemann wrote:
> Hi Klaus,
>
> On 23.07.2011 16:57, Klaus Schmidinger wrote:
>> The VDR plugin 'pictures' (part of the original VDR archive)
>> uses a Perl script named 'pic2mpg', which converts a JPEG
>> image into an MPEG frame that can be displayed directly
>> by VDR's primary output device. This is done in essence
>> by the command sequence
>>
>> jpegtopnm $Pict |
>> pnmscale --xscale=$ScaleW --yscale=$ScaleH |
>> pnmpad --black --width $SW --height $SH |
>> ppmtoy4m -F $framerate -I p -S 420mpeg2 |
>> mpeg2enc -f 3 -b 12500 -a $aspect -q 1 -n $system2 -o $Mpeg
>>
>> (see the actual script for the complete working environment).
>>
>> While this works fine for SD video, I can't seen to figure
>> out how to make this work for an HD video output device.
>> The video frame should be a 1080i frame in my case (my tv
>> can't handle 1080p), but could optionally also be 720p or
>> 1080p, depending on the actual tv's capabilities.
>>
>> Can anybody give me a pointer how this script could generate
>> HD video frames?
>
> I have not used mpeg2enc at all. I usually use convert from ImageMagick and ffmpeg to convert things. You might want to give those two a try.
>
> Here are two simple lines to convert a jpg image to mpeg2:
>
> convert $Pict -background '#000000' -resize 1920x1080 -gravity center -extent 1920x1080 /tmp/test.jpg
> ffmpeg -i /tmp/temp.jpg -an -vcodec mpeg2video -b 2500 -s 1920x1080 -qscale 2 -f mpeg2video $Mpeg
>
> Note: Depending on your distro, ffmpeg may not support mpeg2 video encoding.
>
>
> For mpeg4 the ffmpeg line looks like this:
> ffmpeg -i /tmp/temp.jpg -an -vcodec mpeg4 -b 2500 -s 1920x1080 -qscale 2 -threads 4 -f mp4 -y $Mpeg
>
> For libx264 it looks like this:
> ffmpeg -i /tmp/temp.jpg -an -vcodec libx264 -vpre lossless_ultrafast -s 1920x1080 -qscale 2 -threads 4 -f mp4 $Mpeg
>
> The -vpre parameter requires a preset. They can usually be found under /usr/share/ffmpeg/libx264-*.ffpreset.

Thanks, that was a great help!

I found this command to work pretty good:

   ffmpeg -i /tmp/test.jpg -an -vcodec libx264 -vpre baseline -s 1920x1080 -qscale 2 -f mpegts -y $Mpeg

It generates a decently sized TS file (some 100-200 KB) that can be displayed with
the dvbhddevice plugin on a TT-S2 6400.

Now I wanted to pipe the output of the convert command into ffmpeg (to avoid the temporary file),
but that doesn't seem to work:

   convert $Pict -background '#000000' -resize 1920x1080 -gravity center -extent 1920x1080 - | ffmpeg -i pipe:0 -an -vcodec libx264 -vpre baseline -s 1920x1080 -qscale 2 -f mpegts -y $Mpeg

gives me

ffmpeg version 0.8, Copyright (c) 2000-2011 the FFmpeg developers
   built on Jun 23 2011 09:35:04 with gcc 4.5.1 20101208 [gcc-4_5-branch revision 167585]
   configuration: --shlibdir=/usr/lib --prefix=/usr --mandir=/usr/share/man --libdir=/usr/lib --enable-shared --disable-static --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libspeex --enable-libxvid --enable-postproc --enable-gpl --enable-x11grab 
--extra-cflags='-fomit-frame-pointer -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gsm' --enable-debug --disable-stripping --enable-libgsm --enable-libschroedinger 
--enable-libdirac --enable-avfilter --enable-libvpx --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libdc1394 --enable-pthreads --enable-librtmp
   libavutil    51.  9. 1 / 51.  9. 1
   libavcodec   53.  7. 0 / 53.  7. 0
   libavformat  53.  4. 0 / 53.  4. 0
   libavdevice  53.  1. 1 / 53.  1. 1
   libavfilter   2. 23. 0 /  2. 23. 0
   libswscale    2.  0. 0 /  2.  0. 0
   libpostproc  51.  2. 0 / 51.  2. 0
[mp3 @ 0x807bb00] Format mp3 detected only with low score of 1, misdetection possible!
[mp3 @ 0x807d900] Header missing
     Last message repeated 1 times
[mp3 @ 0x807bb00] Could not find codec parameters (Audio: mp1, 0 channels, s16)
[mp3 @ 0x807bb00] Estimating duration from bitrate, this may be inaccurate
pipe:0: could not find codec parameters


Am I doing something wrong here?

Klaus



More information about the vdr mailing list