<div class="gmail_quote"><span style="font-family:arial, sans-serif;font-size:13px;border-collapse:collapse"><div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">Hi all</div><div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">

<br></div><div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">I&#39;m implementing a tool using the gstreamer to do the folowing:</div>

<div><ul style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px"><li style="margin-left:15px">Read a .YUV file from the disk;</li><li style="margin-left:15px">While it is reading the file, the coding is done by the coder;</li>



<li style="margin-left:15px">At the same time, the coder sends the packets with the video to the receiver using RTP;</li><li style="margin-left:15px">At the receiver, the video is stored.</li></ul><div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">



I found a code to do almost it, but it don&#39;t read from a .YUV file and don&#39;t store at the receiver too. I&#39;ve made some modifications that you already told me to do but the following error has occurred:</div><div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">



<span style="border-collapse:separate;font-family:arial;font-size:small"><br></span></div></div><blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:40px;border-top-style:none;border-right-style:none;border-bottom-style:none;border-left-style:none;border-width:initial;border-color:initial;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px">



<blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:40px;border-top-style:none;border-right-style:none;border-bottom-style:none;border-left-style:none;border-width:initial;border-color:initial;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px">



<div><div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px"><span style="border-collapse:separate;font-family:arial;font-size:small">Error: Encode x264 frame failed.</span></div></div>
<div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px"><span style="border-collapse:separate;font-family:arial;font-size:small"><br></span></div></blockquote></blockquote>The function that I think is the trouble is the following the modifications are in bold:<div>



<br></div><div><div>static GstElement* construct_sender_pipeline(void){</div><div><br></div><div><span style="white-space:pre-wrap">        </span>GstElement *pipeline, *filesrc, *time, *gstrtpbin, *venc, *rtpenc;</div><div><span style="white-space:pre-wrap">        </span>GstElement *udpsink_rtp, *udpsink_rtcp, *udpsrc_rtcp, *identity;</div>



<div><span style="white-space:pre-wrap">        </span>GstCaps *caps;</div><div><span style="white-space:pre-wrap">        </span>GstPad  *pad;</div><div><span style="white-space:pre-wrap">        </span>gboolean err;</div><div><span style="white-space:pre-wrap">        </span>GstPadLinkReturn res;</div>



<div><span style="white-space:pre-wrap">        </span><b>GstBuffer *buffer;</b></div><div><span style="white-space:pre-wrap"><b>        </b></span><b>gint size;</b></div><div><span style="white-space:pre-wrap">                </span></div>
<div><span style="white-space:pre-wrap">        ...</span></div><div><br></div><div><span style="white-space:pre-wrap">        </span>//Video source initialization</div><div><span style="white-space:pre-wrap">        </span><b>filesrc = gst_element_factory_make(&quot;filesrc&quot;, &quot;my_filesource&quot;);</b></div>



<div><span style="white-space:pre-wrap">        </span><b>if (!filesrc){</b></div><div><span style="white-space:pre-wrap"><b>        </b></span><b>    g_printerr(&quot;Failed to create filesrc&quot;);</b></div><div><span style="white-space:pre-wrap"><b>                </b></span><b>return 0;</b></div>



<div><span style="white-space:pre-wrap"><b>        </b></span><b>}</b></div><div><span style="white-space:pre-wrap"><b>        </b></span><b>g_object_set (G_OBJECT (filesrc), &quot;location&quot;, vsrc, NULL);</b></div><div>  <span style="white-space:pre-wrap">        </span></div>



<div><span style="white-space:pre-wrap">        </span>...</div><div><br></div><div><br></div><div><span style="white-space:pre-wrap">        </span>//Create video encoder</div><div><span style="white-space:pre-wrap">        </span>venc = gst_element_factory_make(&quot;x264enc&quot;, &quot;video-encoder&quot;);</div>



<div><span style="white-space:pre-wrap">        </span>if ( !venc ) {</div><div><span style="white-space:pre-wrap">                </span>g_printerr(&quot;Failed to create %s\n&quot;, &quot;x264enc&quot;);</div><div><span style="white-space:pre-wrap">                </span>return 0;</div>



<div><span style="white-space:pre-wrap">        </span>}</div><div><span style="white-space:pre-wrap">        </span></div><div><span style="white-space:pre-wrap">        </span>//kbits/sec --&gt; bits/sec for H.264 encoder</div><div>
<span style="white-space:pre-wrap">        </span>bitrate *= 1024;</div><div><br></div><div><span style="white-space:pre-wrap">        </span>g_object_set(G_OBJECT (venc), &quot;bitrate&quot;, bitrate, NULL);</div><div><span style="white-space:pre-wrap">        </span>//bitrate is not controllable</div>



<div><br></div><div><span style="white-space:pre-wrap">        </span>//Choose RTP encoder according to video codec</div><div><span style="white-space:pre-wrap">        </span>rtpencoder = g_strdup(select_rtp_encoder(&quot;x264enc&quot;));</div>



<div><br></div><div><span style="white-space:pre-wrap">  ...        </span></div><div><span style="white-space:pre-wrap"><br></span></div><div><b>//Possible problem</b></div><div><span style="white-space:pre-wrap"><b>        </b></span><b>size = 352*288*(3/2);</b></div>



<div><span style="white-space:pre-wrap"><b>        </b></span><b>buffer = gst_buffer_try_new_and_alloc (size);</b></div><div><span style="white-space:pre-wrap"><b>        </b></span><b>if (buffer==NULL){</b></div><div><span style="white-space:pre-wrap"><b>        </b></span><b>  g_printerr(&quot;failed to allocate memory\n&quot;);</b></div>



<div><span style="white-space:pre-wrap"><b>        </b></span><b>}</b></div><div><b>//Possible problem<span style="white-space:pre-wrap">        </span></b></div><div><span style="white-space:pre-wrap"><b>        </b></span><b>gst_buffer_set_caps (buffer,caps);</b></div>



<div><span style="white-space:pre-wrap">        </span></div><div><span style="white-space:pre-wrap">        </span><b>//Set up the video encoding parameters</b></div><div><span style="white-space:pre-wrap"><b>        </b></span><b>caps = gst_caps_new_simple (&quot;video/x-raw-yuv&quot;,</b></div>



<div><span style="white-space:pre-wrap"><b>                        </b></span><b>&quot;format&quot;, GST_TYPE_FOURCC, GST_MAKE_FOURCC (&#39;I&#39;, &#39;4&#39;, &#39;2&#39;, &#39;0&#39;),</b></div><div><span style="white-space:pre-wrap"><b>                        </b></span><b>&quot;width&quot;,  G_TYPE_INT, 352,</b></div>



<div><span style="white-space:pre-wrap"><b>                        </b></span><b>&quot;height&quot;, G_TYPE_INT, 288,</b></div><div><span style="white-space:pre-wrap"><b>                        </b></span><b>&quot;framerate&quot;, GST_TYPE_FRACTION, 25, 1, NULL);</b></div>



<div><span style="white-space:pre-wrap"><b>        </b></span><b>if ( !caps ) {</b></div><div><span style="white-space:pre-wrap"><b>                </b></span><b>g_printerr(&quot;Failed to create caps\n&quot;);</b></div><div><span style="white-space:pre-wrap"><b>                </b></span><b>return 0;</b></div>



<div><span style="white-space:pre-wrap"><b>        </b></span><b>}</b></div><div><span style="white-space:pre-wrap">        </span></div><div><span style="white-space:pre-wrap">        </span>err = gst_element_link_filtered(filesrc, time, caps);</div>



<div><span style="white-space:pre-wrap">        </span>gst_caps_unref(caps);</div><div><span style="white-space:pre-wrap">        </span><b>gst_buffer_unref (buffer);</b></div><div><span style="white-space:pre-wrap"><b>        </b></span></div>



<div><span style="white-space:pre-wrap">        ....</span></div><div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap"><br>
</span></div><div><span style="white-space:pre-wrap">        </span>return pipeline;</div><div>}</div><div><div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px"> </div><div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">



<br></div></div><div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">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?</div>



<div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px"><br></div><div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">Please, I need help.</div><div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">



<br></div><div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">thanks for the previous answers and thanks in advance<br>
</div></div></span></div>