Putting Video Frames Into a Buffer for Appsrc

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

Putting Video Frames Into a Buffer for Appsrc

william.l.metcalf
Putting Video Frames Into a Buffer for Appsrc

I am writing a program using GStreamer and the DeckLink API, which will read in video frames and then render them to the screen.  The first step of this process is to caputre the video frames.  Using callback methods in the DeckLink API, I have successfully been able to capture the raw video frames and put them into a void* buffer.  Now I am trying to take this void* buffer and move its contents into a GstBuffer so that I can push it to an appsrc element.

I am pretty inexperience with moving raw video data in between bufffers. Does anyone know what methods are good for completing this task?  Below is a sample of my code to make it a little more clear as to what I am doing exactly.  Thank you in advance.

/* This method is called for each video frame that arrives */
HRESULT STDMETHODCALLTYPE VideoDelegate::VideoInputFrameArrived(IDeckLinkVideoInputFrame *pArrivedFrame, IDeckLinkAudioInputPacket *pArrivedAudio)
{              
        fprintf(stdout, "Video frame arrived.\n");

        /* This method gets the raw video frame bytes and stores them in a void* temp_data */
        pArrivedFrame->GetBytes((void**) &temp_data);

        /* Here is where I need to take temp_data, and somehow move it into the data portion of a GstBuffer video_buffer */

        /* After I have the data in video_buffer, I will push it to the appsrc element */
        gst_app_src_push_buffer(GST_APP_SRC(appsrc), &video_buffer);

        return S_OK;
}


_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Putting Video Frames Into a Buffer for Appsrc

Andrey Nechypurenko-2
Hi,

> Now I am trying to take this void* buffer
> and move its contents into a GstBuffer so that I can push it to an appsrc
> element.

I am also not very experienced gstreamer user, so I can not say for
sure whether your approach with gst_app_src_push_buffer() is feasible
in this situation. However, in our project we were facing very similar
problem. The difference is that the data arrived from the network.
Here is how we solve it.

Gstreamer pipeline is running in own thread. We register callback
function for the AppSrc's "need-data" signal [1]. Networking thread
(in your case it might be the capturing thread) store received frames
into the simple thread-safe queue [2,3]. When the need-data callback
function is invoked, we retrieve the next frame from the queue and use
g_signal_emit_by_name(); to feed the data to appsrc [4]. You can also
take a look at [5] to see how to create the GstBuffer instance out of
raw byte array.

[1] https://www.gitorious.org/veter/cockpit/blobs/master/src/GstMainThread.cpp#line189
[2] https://www.gitorious.org/veter/cockpit/blobs/master/src/BufferQueue.h
[3] https://www.gitorious.org/veter/cockpit/blobs/master/src/Queue.h
[4] https://www.gitorious.org/veter/cockpit/blobs/master/src/GstMainThread.cpp#line142
[5] https://www.gitorious.org/veter/cockpit/blobs/master/src/BufferQueue.cpp#line14

Hope this helps,
Andrey.

----------------------------------------------
http://veter-project.blogspot.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Putting Video Frames Into a Buffer for Appsrc

Josh Doe
In reply to this post by william.l.metcalf
Any particular reason you're not using the decklink source element in
gst-plugins-bad?
http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/tree/sys/decklink

I'd be interested to know, because I'm about to work with a Blackmagic
Design DeckLink Studio 2 card and was planning to use this element.

Thanks,
-Josh

On Thu, Jun 16, 2011 at 11:58 AM, William Metcalf <[hidden email]> wrote:

> I am writing a program using GStreamer and the DeckLink API, which will read
> in video frames and then render them to the screen.  The first step of this
> process is to caputre the video frames.  Using callback methods in the
> DeckLink API, I have successfully been able to capture the raw video frames
> and put them into a void* buffer.  Now I am trying to take this void* buffer
> and move its contents into a GstBuffer so that I can push it to an appsrc
> element.
>
> I am pretty inexperience with moving raw video data in between bufffers.
> Does anyone know what methods are good for completing this task?  Below is a
> sample of my code to make it a little more clear as to what I am doing
> exactly.  Thank you in advance.
>
> /* This method is called for each video frame that arrives */
> HRESULT STDMETHODCALLTYPE
> VideoDelegate::VideoInputFrameArrived(IDeckLinkVideoInputFrame
> *pArrivedFrame, IDeckLinkAudioInputPacket *pArrivedAudio)
> {
>         fprintf(stdout, "Video frame arrived.\n");
>
>         /* This method gets the raw video frame bytes and stores them in a
> void* temp_data */
>         pArrivedFrame->GetBytes((void**) &temp_data);
>
>         /* Here is where I need to take temp_data, and somehow move it into
> the data portion of a GstBuffer video_buffer */
>
>         /* After I have the data in video_buffer, I will push it to the
> appsrc element */
>         gst_app_src_push_buffer(GST_APP_SRC(appsrc), &video_buffer);
>
>         return S_OK;
> }
>
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
>
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

RE: Putting Video Frames Into a Buffer for Appsrc

william.l.metcalf
Andrey, thank you for the information and the links.  I will look through those and see if they solve my problem.

Josh, I am not using the DeckLink source mostly because in my research I never came accross it so I didn't know that it existed.  Secondly, I am using GStreamer on windows and when I do a gst-inspect to list all available elements I do not have a decklink source listed.  I am interested in using the decklink source, but I do not know how to add other elements in Windows.  Do you have any advice or links that could show me how to do this?  Thank you.

-----Original Message-----
From: gstreamer-devel-bounces+wmetcalf=[hidden email] on behalf of Josh Doe
Sent: Thu 6/16/2011 11:45 AM
To: Discussion of the development of and with GStreamer
Subject: Re: Putting Video Frames Into a Buffer for Appsrc
 
Any particular reason you're not using the decklink source element in
gst-plugins-bad?
http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/tree/sys/decklink

I'd be interested to know, because I'm about to work with a Blackmagic
Design DeckLink Studio 2 card and was planning to use this element.

Thanks,
-Josh

On Thu, Jun 16, 2011 at 11:58 AM, William Metcalf <[hidden email]> wrote:

> I am writing a program using GStreamer and the DeckLink API, which will read
> in video frames and then render them to the screen.  The first step of this
> process is to caputre the video frames.  Using callback methods in the
> DeckLink API, I have successfully been able to capture the raw video frames
> and put them into a void* buffer.  Now I am trying to take this void* buffer
> and move its contents into a GstBuffer so that I can push it to an appsrc
> element.
>
> I am pretty inexperience with moving raw video data in between bufffers.
> Does anyone know what methods are good for completing this task?  Below is a
> sample of my code to make it a little more clear as to what I am doing
> exactly.  Thank you in advance.
>
> /* This method is called for each video frame that arrives */
> HRESULT STDMETHODCALLTYPE
> VideoDelegate::VideoInputFrameArrived(IDeckLinkVideoInputFrame
> *pArrivedFrame, IDeckLinkAudioInputPacket *pArrivedAudio)
> {
>         fprintf(stdout, "Video frame arrived.\n");
>
>         /* This method gets the raw video frame bytes and stores them in a
> void* temp_data */
>         pArrivedFrame->GetBytes((void**) &temp_data);
>
>         /* Here is where I need to take temp_data, and somehow move it into
> the data portion of a GstBuffer video_buffer */
>
>         /* After I have the data in video_buffer, I will push it to the
> appsrc element */
>         gst_app_src_push_buffer(GST_APP_SRC(appsrc), &video_buffer);
>
>         return S_OK;
> }
>
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
>
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

winmail.dat (6K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Putting Video Frames Into a Buffer for Appsrc

David Schleef-2
On Thu, Jun 16, 2011 at 11:56:02AM -0500, William Metcalf wrote:
> Andrey, thank you for the information and the links.  I will look through those and see if they solve my problem.
>
> Josh, I am not using the DeckLink source mostly because in my research I never came accross it so I didn't know that it existed.  Secondly, I am using GStreamer on windows and when I do a gst-inspect to list all available elements I do not have a decklink source listed.  I am interested in using the decklink source, but I do not know how to add other elements in Windows.  Do you have any advice or links that could show me how to do this?  Thank you.
>

The decklink plugin (in -bad, btw) is only enabled on Linux, since
it uses some Linux-specific features of the DeckLink API.  It could
be easily ported to Windows by converting those bits to the Windows
version of the API.



David

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel