A problem in playing a streamed H264 video over a network

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

A problem in playing a streamed H264 video over a network

Ibra
Hello,
 
I have written a C application for streaming H.264 encoded videos, and this command describes it:
 
gst-launch v4l2src ! videorate ! video/x-raw-yuv,width=176,height=144,framerate=15/1 ! ffmpegcolorspace ! x264enc bitrate=64 cabac=false ! udpsink host=127.0.0.1 port=8991
and I have written a C application which can receive, decode and display the streamed video, and this command describes it:
 
gst-launch udpsrc caps = "video/x-h264, width=(int)176, height=(int)144, framerate=(fraction)15/1, codec_data=(buffer)014d401effe10018674d401e92540501ed8088000003000800000301e078b17501000468ee3c80, stream-format=(string)avc" multicast-group=127.0.0.1 port=8991 ! h264parse ! ffdec_h264 ! ffmpegcolorspace ! autovideosink
It is working perfectly using the "gst-launch", but when I implement it in a C application, it did not working for me and let me descibe what I am thinking is the problem:
the "caps" property should be included for the "udpsrc" element in order to get the H.264 video displayed. This "caps" property has different parameters as follows:
 
filtercaps = gst_caps_new_simple ("video/x-h264",
  "width", G_TYPE_INT, 176,
  "height", G_TYPE_INT, 144,
  "framerate", GST_TYPE_FRACTION, 15, 1,         
"codec_data", ........!!!!!!!!!!, 014d401effe10018674d401e92540501ed8088000003000800000301e078b17501000468ee3c80,
"stream-format", G_TYPE_STRING, "avc",
NULL);
 
as yuo can see, the problem is that "codec_data" should be of type (buffer) and I am not sure how to deal with this type of value. So, please help in this....
 
Cheers
 
Ibra
 

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

Re: A problem in playing a streamed H264 video over a network

Tim-Philipp Müller-2
On Mon, 2011-09-26 at 22:47 +0100, ibrahim suliman wrote:

Hi,

> gst-launch udpsrc caps = "video/x-h264, width=(int)176,
> height=(int)144, framerate=(fraction)15/1,
> codec_data=(buffer)014d401effe10018674d401e92540501ed8088000003000800000301e078b17501000468ee3c80, stream-format=(string)avc" multicast-group=127.0.0.1 port=8991 ! h264parse ! ffdec_h264 ! ffmpegcolorspace ! autovideosink
>
> It is working perfectly using the "gst-launch", but when I implement
> it in a C application, it did not working for me and let me descibe
> what I am thinking is the problem:
> the "caps" property should be included for the "udpsrc" element in
> order to get the H.264 video displayed. This "caps" property has
> different parameters as follows:
>  
> filtercaps = gst_caps_new_simple ("video/x-h264",
>   "width", G_TYPE_INT, 176,
>   "height", G_TYPE_INT, 144,
>   "framerate", GST_TYPE_FRACTION, 15, 1,          
> "codec_data", ........!!!!!!!!!!,
> 014d401effe10018674d401e92540501ed8088000003000800000301e078b17501000468ee3c80,
> "stream-format", G_TYPE_STRING, "avc",
> NULL);
>  
> as you can see, the problem is that "codec_data" should be of type
> (buffer) and I am not sure how to deal with this type of value. So,
> please help in this....

So first of all your e-mail subject is slightly misleading. Your actual
problem is about how to put a buffer into caps. You could do something
like this:

 const guint8 codec_data[] = { 0x01, 0x4d, .... };
 GstBuffer *buf;
 guint size;

 size = sizeof (codec_data);
 buf = gst_buffer_new_and_alloc (size);
 memcpy (GST_BUFFER_DATA (buf), codec_data, size);
 gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, buf, NULL);
 gst_buffer_unref (buf);

I'm sure you can find more code examples if you grep the GStreamer
plugin source code modules for "codec_data".

Cheers
 -Tim


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

Re: A problem in playing a streamed H264 video over a network

Tim-Philipp Müller-2
> You could do something like this:
>
>  const guint8 codec_data[] = { 0x01, 0x4d, .... };
>  GstBuffer *buf;
>  guint size;
>
>  size = sizeof (codec_data);
>  buf = gst_buffer_new_and_alloc (size);
>  memcpy (GST_BUFFER_DATA (buf), codec_data, size);
>  gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, buf, NULL);
>  gst_buffer_unref (buf);

PS: but of course there's also gst_caps_new_from_string() ...


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

Re: A problem in playing a streamed H264 video over a network

Ibra
In reply to this post by Tim-Philipp Müller-2
Thank you very much Tim, it is working perfectly now.

And you are right, the subject is misleading, and I now can understand why!! sorry about this....

Ibra



Tim-Philipp Müller-2 wrote
On Mon, 2011-09-26 at 22:47 +0100, ibrahim suliman wrote:

Hi,

> gst-launch udpsrc caps = "video/x-h264, width=(int)176,
> height=(int)144, framerate=(fraction)15/1,
> codec_data=(buffer)014d401effe10018674d401e92540501ed8088000003000800000301e078b17501000468ee3c80, stream-format=(string)avc" multicast-group=127.0.0.1 port=8991 ! h264parse ! ffdec_h264 ! ffmpegcolorspace ! autovideosink
>
> It is working perfectly using the "gst-launch", but when I implement
> it in a C application, it did not working for me and let me descibe
> what I am thinking is the problem:
> the "caps" property should be included for the "udpsrc" element in
> order to get the H.264 video displayed. This "caps" property has
> different parameters as follows:
>  
> filtercaps = gst_caps_new_simple ("video/x-h264",
>   "width", G_TYPE_INT, 176,
>   "height", G_TYPE_INT, 144,
>   "framerate", GST_TYPE_FRACTION, 15, 1,          
> "codec_data", ........!!!!!!!!!!,
> 014d401effe10018674d401e92540501ed8088000003000800000301e078b17501000468ee3c80,
> "stream-format", G_TYPE_STRING, "avc",
> NULL);
>  
> as you can see, the problem is that "codec_data" should be of type
> (buffer) and I am not sure how to deal with this type of value. So,
> please help in this....

So first of all your e-mail subject is slightly misleading. Your actual
problem is about how to put a buffer into caps. You could do something
like this:

 const guint8 codec_data[] = { 0x01, 0x4d, .... };
 GstBuffer *buf;
 guint size;

 size = sizeof (codec_data);
 buf = gst_buffer_new_and_alloc (size);
 memcpy (GST_BUFFER_DATA (buf), codec_data, size);
 gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, buf, NULL);
 gst_buffer_unref (buf);

I'm sure you can find more code examples if you grep the GStreamer
plugin source code modules for "codec_data".

Cheers
 -Tim


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

Re: A problem in playing a streamed H264 video over a network

Marc Leeman
btw, add an h264 parser at the end of your sending pipeline and
instruct it to multiplex the configuration data in your stream. It
will simplify your receiver and make your stream playable by more
players.

--
br, marc

The best approach for you requires two steps. The first step is
reading the Manual.
    Wolfgang Denk - u-boot mailing list
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: A problem in playing a streamed H264 video over a network

Wes Miller
Administrator
In reply to this post by Ibra

From: ibrahim suliman <[hidden email]>
Subject: A problem in playing a streamed H264 video over a network

Ibra,

I am not sure if this will help you, but I got better results when I moved gthe CAPS out of the udpsrc element and made them into a separate capsfilter pipe stage:

udpsrc … ! "video/x-h264, width=(int)176,…


Also, consider adding a payloader and depayloader to your pipes.  This will make the receiver caps much easier to handle.

Wes


CONFIDENTIALITY NOTE:

This e-mail and any attachments are confidential. If you are not the intended recipient, be aware that any disclosure, copying, distribution or use of this e-mail or any attachment is prohibited. If you have received this e-mail in error, please notify us immediately by returning it to the sender and delete this copy from your system. Thank you for your cooperation.

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

Re: A problem in playing a streamed H264 video over a network

Ibra
In reply to this post by Marc Leeman
Thank you Marc, I am working on your approach and trying to get it working well.

BTW, I am working on doing some action to the stream. I am trying to change these caps while streaming, say we would like to adjust the resolution or the frame rate on the fly. I am doing this by firstly pausing the pipeline then using the following to adjust the caps:
    gst_caps_set_simple (filtercaps, "width", G_TYPE_INT, 352, "height", G_TYPE_INT, 288, "framerate", GST_TYPE_FRACTION, 15, 1, NULL);   
 after that, I set the pipeline state to playing state.
the caps (filtercaps) got changed but when I set the state back to playing, it seems that no changes were applied!!!
any suggestions....

Ibra


From: Marc Leeman <[hidden email]>
To: Discussion of the development of and with GStreamer <[hidden email]>
Sent: Tuesday, 27 September 2011, 11:01
Subject: Re: A problem in playing a streamed H264 video over a network

btw, add an h264 parser at the end of your sending pipeline and
instruct it to multiplex the configuration data in your stream. It
will simplify your receiver and make your stream playable by more
players.

--
br, marc

The best approach for you requires two steps. The first step is
reading the Manual.
    Wolfgang Denk - u-boot mailing list
_______________________________________________
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