[gst-devel] how to learn from .yuv files and encode with h.264?

Rafael Sousa rafael.lmsousa at gmail.com
Thu Oct 28 16:41:33 CEST 2010


Hi all

I'm implementing a tool using the gstreamer to do the folowing:

   - Read a .YUV file from the disk;
   - While it is reading the file, the coding is done by the coder;
   - At the same time, the coder sends the packets with the video to the
   receiver using RTP;
   - At the receiver, the video is stored.

I found a code to do almost it, but it don't read from a .YUV file and don't
store at the receiver too. I've made some modifications that you already
told me to do but the following error has occurred:

 Error: Encode x264 frame failed.

The function that I think is the trouble is the following the modifications
are in bold:

static GstElement* construct_sender_pipeline(void){

GstElement *pipeline, *filesrc, *time, *gstrtpbin, *venc, *rtpenc;
GstElement *udpsink_rtp, *udpsink_rtcp, *udpsrc_rtcp, *identity;
 GstCaps *caps;
GstPad  *pad;
gboolean err;
GstPadLinkReturn res;
 *GstBuffer *buffer;*
* **gint size;*
 ...

//Video source initialization
*filesrc = gst_element_factory_make("filesrc", "my_filesource");*
 *if (!filesrc){*
* **    g_printerr("Failed to create filesrc");*
* **return 0;*
* **}*
* **g_object_set (G_OBJECT (filesrc), "location", vsrc, NULL);*

 ...


//Create video encoder
venc = gst_element_factory_make("x264enc", "video-encoder");
 if ( !venc ) {
g_printerr("Failed to create %s\n", "x264enc");
return 0;
 }
 //kbits/sec --> bits/sec for H.264 encoder
 bitrate *= 1024;

g_object_set(G_OBJECT (venc), "bitrate", bitrate, NULL);
//bitrate is not controllable

//Choose RTP encoder according to video codec
rtpencoder = g_strdup(select_rtp_encoder("x264enc"));

...

*//Possible problem*
* **size = 352*288*(3/2);*
* **buffer = gst_buffer_try_new_and_alloc (size);*
* **if (buffer==NULL){*
* **  g_printerr("failed to allocate memory\n");*
* **}*
*//Possible problem *
* **gst_buffer_set_caps (buffer,caps);*
 *//Set up the video encoding parameters*
* **caps = gst_caps_new_simple ("video/x-raw-yuv",*
* **"format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),*
* **"width",  G_TYPE_INT, 352,*
* **"height", G_TYPE_INT, 288,*
* **"framerate", GST_TYPE_FRACTION, 25, 1, NULL);*
* **if ( !caps ) {*
* **g_printerr("Failed to create caps\n");*
* **return 0;*
* **}*
 err = gst_element_link_filtered(filesrc, time, caps);
 gst_caps_unref(caps);
*gst_buffer_unref (buffer);*
* *
 ....


 return pipeline;
}


I supressed part of the function, but I put in annex the whole code. There
is something wrong or missing in this function? How can I make what I want
to work?

Please, I need help.

thanks for the previous answers and thanks in advance
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20101028/bfcaeba9/attachment.htm>


More information about the gstreamer-devel mailing list