<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">I always had to decode from the latest
key frame up to the desired stream time nal,<br>
<br>
On 6/10/2013 2:36 PM, Faraz Khan wrote:<br>
</div>
<blockquote
cite="mid:CAOgunuZmQ=xFNqzoo6UR4p8gmiPHQ23QzcFkjVeuXKz71toMiQ@mail.gmail.com"
type="cite">
<div dir="ltr">Hi all,
<div>I'm trying to use ffmpeg as a decoder for a real-time x264
stream that I'm generating. It works fine if I try to decode
entire frames, but if I try to decode a single NALU the
decoder errors out saying 'no frame'. I've tried using the
parser (av_parser_parse2) but the h264 decoder doesnt seem to
like that output either. I'm using x264 with annex-b and
repeat-headers on. </div>
<div><br>
</div>
<div>The encoder config is as follows:<br>
<br>
x264params.b_sliced_threads = 1;<br>
x264params.i_slice_max_size = 1350;<br>
x264params.i_width = yuvSize.width;<br>
x264params.i_height = yuvSize.height;<br>
x264params.i_fps_num = 10;<br>
x264params.i_fps_den = 1;<br>
x264params.b_vfr_input = 0;<br>
x264params.rc.i_bitrate = 1500;<br>
<br>
</div>
<div> // Intra refres:<br>
x264params.i_keyint_max = 50000000;<br>
x264params.b_intra_refresh = 1;<br>
<br>
</div>
<div>//Rate control:<br>
<br>
x264params.rc.i_rc_method = X264_RC_ABR;<br>
x264params.rc.i_vbv_buffer_size = 300;<br>
x264params.rc.i_vbv_max_bitrate = 1500;<br>
<br>
</div>
<div>//For streaming:<br>
x264params.b_repeat_headers = 1;<br>
x264params.b_annexb = 1;<br>
<br>
</div>
<div>x264_param_apply_profile(&x264params, "baseline");</div>
<div><br>
</div>
<div style=""><br>
</div>
<div style=""><br>
</div>
<div style="">I do the encode with:</div>
<div style="">
<p class=""> <span class="">int</span> frame_size = <span
class="">x264_encoder_encode</span>(<span class="">x264Encoder</span>,
&nals, &i_nals, &<span class="">pic_in</span>,
&<span class="">pic_out</span>);</p>
<p class=""><br>
</p>
<p class="">Now, since the max slice size is 1350, each packet
output is a udp packet of size < MTU (this is true) and
sent across the network.<br>
</p>
<p class="" style="">I iterate over the nals[i].p_payload and
send them over to the ffmpeg side for decoding. I receive
the correct packet on the remote side. </p>
<p class="" style="">If I assemble ALL the NALUs that were
output in this frame and feed it directly to the decoder
(even without the parser), it works fine! If I feed one NALU
at a time, it fails (event with the parse). I'm sending it
to the parser like:<br>
</p>
<p class="" style=""><br>
</p>
<p class="" style="">int plen = av_parser_parse2(codecParser,
decoderContext, &outbuf, &outside,
indata,inlength,0,0,0);</p>
<p class="" style=""><br>
</p>
<p class="" style="">plen always reports that it consumed the
entire NALU that I gave it - after consuming a few NALUs,
the outsize and outbuf are set to some value. Feeding it
into the decoder using:</p>
<p class="" style=""><br>
</p>
<p class="" style=""> int len =
avcodec_decode_video2(decoderContext,decoderOutframe,
&gotpic,&avpkt);</p>
<p class="" style=""><br>
</p>
<p class="" style="">Results in it saying 'No frame'. Again,
if avpkt.data contains the entire frame (all NALUs
concatenated) it will work! </p>
<p class="" style=""><br>
</p>
<p class="" style="">I'm obviously doing some obviously wrong
- but I really cant figure out why it wont decode a single
NALU. Or is this a limitation in ffmpeg?</p>
<p class="" style=""><br>
</p>
<p class="" style="">
Thanks Guys!</p>
<p class="" style=""><br>
</p>
<p class="" style=""><br>
</p>
</div>
<div>
<div dir="ltr"><br>
<div>--</div>
<div>Faraz Khan</div>
<div>Simple Collaboration Screensharing</div>
<div><a moz-do-not-send="true"
href="http://www.screenhero.com" target="_blank">www.screenhero.com</a></div>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Libav-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a>
<a class="moz-txt-link-freetext" href="http://ffmpeg.org/mailman/listinfo/libav-user">http://ffmpeg.org/mailman/listinfo/libav-user</a>
</pre>
</blockquote>
<br>
</body>
</html>