code for converting raw image to jpeg image

Antonio Ospite ao2 at ao2.it
Wed Nov 26 14:14:54 PST 2014


On Wed, 26 Nov 2014 10:21:06 -0800 (PST)
David Viana <davidkviana at gmail.com> wrote:

> Hello Kyrylo V Polezhaiev and guys, I'm trying work with this method but it
> doesn't work when my image has a different resolution of 640x480, and only
> in gst-launch-1.0, at gst-launch-0.10 doesn't work.
> Here it is ok:
> gst-launch-1.0 -vvv filesrc location=/tmp/images/frame1.raw blocksize=614400
> ! video/x-raw,format=YUY2,width=640,height=480,framerate=1/1 ! jpegenc !
> filesink location=/tmp/out.jpg
> 
> But, I capture other images with 800x600 in raw, when I try:
> gst-launch-1.0 -vvv filesrc location=/tmp/images/frame2.raw blocksize=720000
> ! video/x-raw,format=YUY2,width=800,height=600,framerate=1/1 ! jpegenc !
> filesink location=/tmp/out.jpg

Well, if the raw data is YUY2 (16bpp) you have that the image should be
800*600*2 = 960000 bytes indeed as the error message tells you.

But your frame seems to only have 614400 bytes (not even the 720000 you
specified in the command line). Are you using the right input file?

And BTW 720000=800*600*1.5 (12bpp) this size would be valid for
some other formats but not YUY2.

> The errors are:
> 0:00:00.028406272  6516      0x19975e0 ERROR                default
> video-frame.c:149:gst_video_frame_map_id: invalid buffer size 614400 <
> 960000
  ^^^^^^
  here!

FYI you can calculate the image size directly in the shell command
line if you are using POSIX shell:

gst-launch-1.0 -vvv filesrc location=/dev/urandom blocksize=$((800*600*2)) num-buffers=1 !
video/x-raw,format=YUY2,width=800,height=600,framerate=1/1 ! jpegenc !
filesink location=/tmp/out.jpg

> 0:00:00.028471267  6516      0x19975e0 WARN                 jpegenc
> gstjpegenc.c:526:gst_jpegenc_handle_frame:<jpegenc0> invalid frame received
> 0:00:00.028505757  6516      0x19975e0 ERROR           videoencoder
> gstvideoencoder.c:2009:gst_video_encoder_finish_frame:<jpegenc0> Output
> state was not configured
> 0:00:00.028561810  6516      0x19975e0 WARN                 basesrc
> gstbasesrc.c:2865:gst_base_src_loop:<filesrc0> error: Internal data flow
> error.
> 0:00:00.028606561  6516      0x19975e0 WARN                 basesrc
> gstbasesrc.c:2865:gst_base_src_loop:<filesrc0> error: streaming task paused,
> reason error (-5)
> ERROR: from element /GstPipeline:pipeline0/GstFileSrc:filesrc0: Internal
> data flow error.
> Additional debug info:
> gstbasesrc.c(2865): gst_base_src_loop ():
> /GstPipeline:pipeline0/GstFileSrc:filesrc0:
> streaming task paused, reason error (-5)
> 
> Any help me, please.
> Thank you guys.
> 

Ciao ciao,
   Antonio

-- 
Antonio Ospite
http://ao2.it

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?


More information about the gstreamer-devel mailing list