gst buffer to image

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

gst buffer to image

Mailing List SVR
Hi all,

I'm using a simple playbin pipeline, I can get the last frame with something
like this:

In [124]: frame=player.get_property("frame")

In [125]: frame
Out[125]: <gst.Buffer 0x1fed6f0 of size 115200 and data 0x49484445>

now I can access frame.data that would be the raw frame data, but how to
convert this frame to a jpg or png image? I tried to save the frame to a file
and to convert with jpegenc and pngenc with no success, any suggestions?

thanks
Nicola

------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing.
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: gst buffer to image

Mailing List SVR
In data sabato 5 dicembre 2009 19:39:31, Mailing List SVR ha scritto:
: > Hi all,
>
> I'm using a simple playbin pipeline, I can get the last frame with
>  something like this:
>
> In [124]: frame=player.get_property("frame")
>
> In [125]: frame
> Out[125]: <gst.Buffer 0x1fed6f0 of size 115200 and data 0x49484445>

additionally:

In [34]: frame.get_caps().to_string()
Out[34]: 'video/x-raw-yuv, width=(int)320, height=(int)240,
framerate=(fraction)10/1, format=(fourcc)I420, interlaced=(boolean)false,
pixel-aspect-ratio=(fraction)1/1'

I tried this pipeline:

gst-launch-0.10 -v filesrc location=/tmp/frame  ! "video/x-raw-yuv,
width=(int)320, height=(int)240, framerate=(fraction)10/1,
format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-
ratio=(fraction)1/1"  ! jpegenc ! filesink location=test.jpg

but the jpg generated is bad (attacched). I attacch also the saved frame.data


>
> now I can access frame.data that would be the raw frame data, but how to
> convert this frame to a jpg or png image? I tried to save the frame to a
>  file and to convert with jpegenc and pngenc with no success, any
>  suggestions?
>
> thanks
> Nicola
>
> ---------------------------------------------------------------------------
> --- Join us December 9, 2009 for the Red Hat Virtual Experience,
> a free event focused on virtualization and cloud computing.
> Attend in-depth sessions from your desk. Your couch. Anywhere.
> http://p.sf.net/sfu/redhat-sfdev2dev
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>

------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing.
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel

test.jpg (827K) Download Attachment
frame (153K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: gst buffer to image

Mailing List SVR
I solved myself pushing the frame to a second pipeline,

thanks
Nicola

In data sabato 5 dicembre 2009 23:27:59, Mailing List SVR ha scritto:
: > In data sabato 5 dicembre 2009 19:39:31, Mailing List SVR ha scritto:

> : > Hi all,
> >
> > I'm using a simple playbin pipeline, I can get the last frame with
> >  something like this:
> >
> > In [124]: frame=player.get_property("frame")
> >
> > In [125]: frame
> > Out[125]: <gst.Buffer 0x1fed6f0 of size 115200 and data 0x49484445>
>
> additionally:
>
> In [34]: frame.get_caps().to_string()
> Out[34]: 'video/x-raw-yuv, width=(int)320, height=(int)240,
> framerate=(fraction)10/1, format=(fourcc)I420, interlaced=(boolean)false,
> pixel-aspect-ratio=(fraction)1/1'
>
> I tried this pipeline:
>
> gst-launch-0.10 -v filesrc location=/tmp/frame  ! "video/x-raw-yuv,
> width=(int)320, height=(int)240, framerate=(fraction)10/1,
> format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-
> ratio=(fraction)1/1"  ! jpegenc ! filesink location=test.jpg
>
> but the jpg generated is bad (attacched). I attacch also the saved
>  frame.data
>
> > now I can access frame.data that would be the raw frame data, but how to
> > convert this frame to a jpg or png image? I tried to save the frame to a
> >  file and to convert with jpegenc and pngenc with no success, any
> >  suggestions?
> >
> > thanks
> > Nicola
> >
> > -------------------------------------------------------------------------
> >-- --- Join us December 9, 2009 for the Red Hat Virtual Experience, a free
> > event focused on virtualization and cloud computing.
> > Attend in-depth sessions from your desk. Your couch. Anywhere.
> > http://p.sf.net/sfu/redhat-sfdev2dev
> > _______________________________________________
> > gstreamer-devel mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>

------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing.
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: gst buffer to image

Gabriel Duarte
How!

On Sun, Dec 6, 2009 at 6:02 AM, Mailing List SVR <[hidden email]> wrote:
I solved myself pushing the frame to a second pipeline,

thanks
Nicola

In data sabato 5 dicembre 2009 23:27:59, Mailing List SVR ha scritto:
: > In data sabato 5 dicembre 2009 19:39:31, Mailing List SVR ha scritto:
> : > Hi all,
> >
> > I'm using a simple playbin pipeline, I can get the last frame with
> >  something like this:
> >
> > In [124]: frame=player.get_property("frame")
> >
> > In [125]: frame
> > Out[125]: <gst.Buffer 0x1fed6f0 of size 115200 and data 0x49484445>
>
> additionally:
>
> In [34]: frame.get_caps().to_string()
> Out[34]: 'video/x-raw-yuv, width=(int)320, height=(int)240,
> framerate=(fraction)10/1, format=(fourcc)I420, interlaced=(boolean)false,
> pixel-aspect-ratio=(fraction)1/1'
>
> I tried this pipeline:
>
> gst-launch-0.10 -v filesrc location=/tmp/frame  ! "video/x-raw-yuv,
> width=(int)320, height=(int)240, framerate=(fraction)10/1,
> format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-
> ratio=(fraction)1/1"  ! jpegenc ! filesink location=test.jpg
>
> but the jpg generated is bad (attacched). I attacch also the saved
>  frame.data
>
> > now I can access frame.data that would be the raw frame data, but how to
> > convert this frame to a jpg or png image? I tried to save the frame to a
> >  file and to convert with jpegenc and pngenc with no success, any
> >  suggestions?
> >
> > thanks
> > Nicola
> >
> > -------------------------------------------------------------------------
> >-- --- Join us December 9, 2009 for the Red Hat Virtual Experience, a free
> > event focused on virtualization and cloud computing.
> > Attend in-depth sessions from your desk. Your couch. Anywhere.
> > http://p.sf.net/sfu/redhat-sfdev2dev
> > _______________________________________________
> > gstreamer-devel mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>

------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing.
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel



--
Gabriel Duarte
Linux User #471185
Rio de Janeiro - RJ
http://kinuxlinux.org/gabriel_duarte

Phones:
(55) (21) 9463-7760 /*Mobile*/
(55) (21) 2464-9302 /*Home*/
(55) (21) 2529-5080 /*Work*/


-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS d- s: a--- C++ UL+++ P L++++ E- W+ N++ o++ K++ w---
O- M- V- PS++ PE++ Y PGP- t++ 5-- X+++ R tv++ b++ DI+ D++
G++ e+ h* r+ y++++
------END GEEK CODE BLOCK------

------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing.
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: gst buffer to image

Mailing List SVR
In data domenica 6 dicembre 2009 13:47:20, Gabriel Duarte ha scritto:
: > How!

Basically you have to use a pipeline like this

gst.parse_launch('fakesrc name=src ! queue name=queue ! ffmpegcolorspace !
video/x-raw-rgb,width=320,height=240 ! pngenc ! fakesink name=sink signal-
handoffs=true')

and then push the frame with something like:

queue.get_pad('src').push(frame)

this way you'll get a png image,

Nicola

>
> On Sun, Dec 6, 2009 at 6:02 AM, Mailing List SVR
<[hidden email]>wrote:

> > I solved myself pushing the frame to a second pipeline,
> >
> > thanks
> > Nicola
> >
> > In data sabato 5 dicembre 2009 23:27:59, Mailing List SVR ha scritto:
> > : > In data sabato 5 dicembre 2009 19:39:31, Mailing List SVR ha scritto:
> > > : > Hi all,
> > > >
> > > > I'm using a simple playbin pipeline, I can get the last frame with
> > > >  something like this:
> > > >
> > > > In [124]: frame=player.get_property("frame")
> > > >
> > > > In [125]: frame
> > > > Out[125]: <gst.Buffer 0x1fed6f0 of size 115200 and data 0x49484445>
> > >
> > > additionally:
> > >
> > > In [34]: frame.get_caps().to_string()
> > > Out[34]: 'video/x-raw-yuv, width=(int)320, height=(int)240,
> > > framerate=(fraction)10/1, format=(fourcc)I420,
> > > interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1'
> > >
> > > I tried this pipeline:
> > >
> > > gst-launch-0.10 -v filesrc location=/tmp/frame  ! "video/x-raw-yuv,
> > > width=(int)320, height=(int)240, framerate=(fraction)10/1,
> > > format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-
> > > ratio=(fraction)1/1"  ! jpegenc ! filesink location=test.jpg
> > >
> > > but the jpg generated is bad (attacched). I attacch also the saved
> > >  frame.data
> > >
> > > > now I can access frame.data that would be the raw frame data, but how
> >
> > to
> >
> > > > convert this frame to a jpg or png image? I tried to save the frame
> > > > to
> >
> > a
> >
> > > >  file and to convert with jpegenc and pngenc with no success, any
> > > >  suggestions?
> > > >
> > > > thanks
> > > > Nicola
> >
> > -------------------------------------------------------------------------
> >
> > > >-- --- Join us December 9, 2009 for the Red Hat Virtual Experience, a
> >
> > free
> >
> > > > event focused on virtualization and cloud computing.
> > > > Attend in-depth sessions from your desk. Your couch. Anywhere.
> > > > http://p.sf.net/sfu/redhat-sfdev2dev
> > > > _______________________________________________
> > > > gstreamer-devel mailing list
> > > > [hidden email]
> > > > https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
> >
> > -------------------------------------------------------------------------
> >----- Join us December 9, 2009 for the Red Hat Virtual Experience,
> > a free event focused on virtualization and cloud computing.
> > Attend in-depth sessions from your desk. Your couch. Anywhere.
> > http://p.sf.net/sfu/redhat-sfdev2dev
> > _______________________________________________
> > gstreamer-devel mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>

------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing.
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: gst buffer to image

Stefan Sauer
Am 07.12.2009 02:48, schrieb Mailing List SVR:

> In data domenica 6 dicembre 2009 13:47:20, Gabriel Duarte ha scritto:
> : > How!
>
> Basically you have to use a pipeline like this
>
> gst.parse_launch('fakesrc name=src ! queue name=queue ! ffmpegcolorspace !
> video/x-raw-rgb,width=320,height=240 ! pngenc ! fakesink name=sink signal-
> handoffs=true')
>
> and then push the frame with something like:
>
> queue.get_pad('src').push(frame)
>
> this way you'll get a png image,

irks, thats quite a hack. You should atleast use the handoff signal in fakesrc
or even better use appsrc. Both playbin and camerabin have such code (see
gstscreenshot.c in -base/gst/playback/)

Stefan

>
> Nicola
>
>>
>> On Sun, Dec 6, 2009 at 6:02 AM, Mailing List SVR
> <[hidden email]>wrote:
>>> I solved myself pushing the frame to a second pipeline,
>>>
>>> thanks
>>> Nicola
>>>
>>> In data sabato 5 dicembre 2009 23:27:59, Mailing List SVR ha scritto:
>>> : > In data sabato 5 dicembre 2009 19:39:31, Mailing List SVR ha scritto:
>>>> : > Hi all,
>>>>>
>>>>> I'm using a simple playbin pipeline, I can get the last frame with
>>>>>  something like this:
>>>>>
>>>>> In [124]: frame=player.get_property("frame")
>>>>>
>>>>> In [125]: frame
>>>>> Out[125]: <gst.Buffer 0x1fed6f0 of size 115200 and data 0x49484445>
>>>>
>>>> additionally:
>>>>
>>>> In [34]: frame.get_caps().to_string()
>>>> Out[34]: 'video/x-raw-yuv, width=(int)320, height=(int)240,
>>>> framerate=(fraction)10/1, format=(fourcc)I420,
>>>> interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1'
>>>>
>>>> I tried this pipeline:
>>>>
>>>> gst-launch-0.10 -v filesrc location=/tmp/frame  ! "video/x-raw-yuv,
>>>> width=(int)320, height=(int)240, framerate=(fraction)10/1,
>>>> format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-
>>>> ratio=(fraction)1/1"  ! jpegenc ! filesink location=test.jpg
>>>>
>>>> but the jpg generated is bad (attacched). I attacch also the saved
>>>>  frame.data
>>>>
>>>>> now I can access frame.data that would be the raw frame data, but how
>>>
>>> to
>>>
>>>>> convert this frame to a jpg or png image? I tried to save the frame
>>>>> to
>>>
>>> a
>>>
>>>>>  file and to convert with jpegenc and pngenc with no success, any
>>>>>  suggestions?
>>>>>
>>>>> thanks
>>>>> Nicola
>>>
>>> -------------------------------------------------------------------------
>>>
>>>>> -- --- Join us December 9, 2009 for the Red Hat Virtual Experience, a
>>>
>>> free
>>>
>>>>> event focused on virtualization and cloud computing.
>>>>> Attend in-depth sessions from your desk. Your couch. Anywhere.
>>>>> http://p.sf.net/sfu/redhat-sfdev2dev
>>>>> _______________________________________________
>>>>> gstreamer-devel mailing list
>>>>> [hidden email]
>>>>> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>>>
>>> -------------------------------------------------------------------------
>>> ----- Join us December 9, 2009 for the Red Hat Virtual Experience,
>>> a free event focused on virtualization and cloud computing.
>>> Attend in-depth sessions from your desk. Your couch. Anywhere.
>>> http://p.sf.net/sfu/redhat-sfdev2dev
>>> _______________________________________________
>>> gstreamer-devel mailing list
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>>
>
> ------------------------------------------------------------------------------
> Join us December 9, 2009 for the Red Hat Virtual Experience,
> a free event focused on virtualization and cloud computing.
> Attend in-depth sessions from your desk. Your couch. Anywhere.
> http://p.sf.net/sfu/redhat-sfdev2dev
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel


------------------------------------------------------------------------------
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: gst buffer to image

Olivier Aubert-2
> irks, thats quite a hack. You should atleast use the handoff signal in fakesrc
> or even better use appsrc. Both playbin and camerabin have such code (see
> gstscreenshot.c in -base/gst/playback/)
This snapshot/conversion issue is becoming a FAQ (search for the keyword
"snapshot" in the mailing-list archive). I will maybe find some time
next week to propose a FAQ entry with appropriate information.

As for using the handoff signal or using appsrc, I think that this
advice cannot be followed when programming in python, as long as the
following bug (for which I have proposed a patch) remains open:
https://bugzilla.gnome.org/show_bug.cgi?id=589582

I have proposed on this list 2 different solutions for snapshotting (one
based on a pipeline conversion of the playbin.props.frame data, and the
other one using a dedicated pipeline with a custom sink). I am now using
the last one for my video annotation application (cf
http://www.advene.org/ ), but I would very much like to also be able to
use the first one, for the live stream annotation case (live annotation
of a webcam stream).

Regards,
Olivier


------------------------------------------------------------------------------
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel