<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Sprechblasentext Zchn";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0in;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:.5in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
span.SprechblasentextZchn
        {mso-style-name:"Sprechblasentext Zchn";
        mso-style-priority:99;
        mso-style-link:Sprechblasentext;
        font-family:"Tahoma","sans-serif";}
p.BalloonText, li.BalloonText, div.BalloonText
        {mso-style-name:"Balloon Text";
        mso-style-link:"Balloon Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
span.E-MailFormatvorlage22
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.E-MailFormatvorlage23
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.E-MailFormatvorlage24
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.E-MailFormatvorlage25
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.E-MailFormatvorlage26
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.E-MailFormatvorlage27
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:15277589;
        mso-list-type:hybrid;
        mso-list-template-ids:-1372666742 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level2
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level3
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level4
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level5
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level6
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level7
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level8
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level9
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=DE link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>Hm, i really dont believe your problem is the flushing part itself.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>I wonder if the pkt you are sending to the encoder is initialized – at least i cannot see how. There is a huge number of issues in avcodec_encode_video2 that occur when you send it a pkt that it did not expect.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>Here is how I flush at the end of transcoding:<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>       <span style='color:blue'>int</span> stillgotframes = 1;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>       <span style='color:blue'>while</span>(stillgotframes){<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>             AVPacket pkt; <o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>             av_init_packet(&pkt);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>             <span style='color:blue'>int</span> got_packet=0;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>             <span style='color:blue'>int</span> ret = -1;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>             pkt.size = video_outbuf_size; //1000000<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>             pkt.data = video_outbuf; // constant location in memory<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>             ret = avcodec_encode_video2(video_st->codec, &pkt, NULL, &got_packet);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>             av_interleaved_write_frame(oc, &pkt);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>             </span><span style='font-size:9.5pt;font-family:Consolas'>stillgotframes = got_packet;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas'>       }<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><a name="_MailEndCompose"><span lang=EN-US style='color:#1F497D'>Harry<o:p></o:p></span></a></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>Von:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> libav-user-bounces@ffmpeg.org [mailto:libav-user-bounces@ffmpeg.org] <b>Im Auftrag von </b>Ashwin Chandra - SISA<br><b>Gesendet:</b> Friday, February 08, 2013 7:22 PM<br><b>An:</b> This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter.<br><b>Betreff:</b> Re: [Libav-user] Problem with using libavcodec with AV_CODEC_ID_H264<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>All those presets I tried but didn’t help.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> <a href="mailto:libav-user-bounces@ffmpeg.org">libav-user-bounces@ffmpeg.org</a> [<a href="mailto:libav-user-bounces@ffmpeg.org">mailto:libav-user-bounces@ffmpeg.org</a>] <b>On Behalf Of </b>Ashwin Chandra - SISA<br><b>Sent:</b> Friday, February 08, 2013 8:39 AM<br><b>To:</b> This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter.<br><b>Subject:</b> Re: [Libav-user] Problem with using libavcodec with AV_CODEC_ID_H264<o:p></o:p></span></p></div></div><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>But the decoding_encoding example works for me without any changes. The problem is if you just want to encode two frames and flush them all out. With 25 there doesn’t seem to be any issues.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> <a href="mailto:libav-user-bounces@ffmpeg.org">libav-user-bounces@ffmpeg.org</a> [<a href="mailto:libav-user-bounces@ffmpeg.org">mailto:libav-user-bounces@ffmpeg.org</a>] <b>On Behalf Of </b>Harald Jordan<br><b>Sent:</b> Friday, February 08, 2013 12:53 AM<br><b>To:</b> 'This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter.'<br><b>Subject:</b> Re: [Libav-user] Problem with using libavcodec with AV_CODEC_ID_H264<o:p></o:p></span></p></div></div><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-AU style='color:#1F497D'>If you did not make any changes to the open_video and add_video functions of the decoding_encoding example, it cannot work. For H264 you need to manually define a set a of H264 private settings before opening the codec.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-AU style='color:#1F497D'><a href="http://stackoverflow.com/questions/3553003/encoding-h-264-with-libavcodec-x264">http://stackoverflow.com/questions/3553003/encoding-h-264-with-libavcodec-x264</a><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-AU style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-AU style='color:#1F497D'>Harry<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-AU style='color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>Von:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> <a href="mailto:libav-user-bounces@ffmpeg.org">libav-user-bounces@ffmpeg.org</a> [<a href="mailto:libav-user-bounces@ffmpeg.org">mailto:libav-user-bounces@ffmpeg.org</a>] <b>Im Auftrag von </b>Ashwin Chandra - SISA<br><b>Gesendet:</b> Freitag, 08. Februar 2013 00:29<br><b>An:</b> This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter.<br><b>Betreff:</b> Re: [Libav-user] Problem with using libavcodec with AV_CODEC_ID_H264<o:p></o:p></span></p></div></div><p class=MsoNormal><span lang=EN-AU><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>To be clearer, I modified the decoding_encoding.c example in ffmpeg to cause the problem.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>I basically changed the video_encode_example() to encode 1 second worth of video and then flush the delayed frame. The code below is exactly the same except 25 frames was replaced with 1 frame.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>Now if I take this code block and duplicate it again, so that it basically runs twice, the second </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>avcodec_encode_video2() will hang.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas;color:green'>/* encode 1 second of video */</span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>    <span style='color:blue'>for</span>(i=0;i<1;i++) {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>        av_init_packet(&pkt);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>        pkt.data = NULL;    <span style='color:green'>// packet data will be allocated by the encoder</span><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>        pkt.size = 0;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>        fflush(stdout);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>        <span style='color:green'>/* prepare a dummy image */</span><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>        <span style='color:green'>/* Y */</span><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>        <span style='color:blue'>for</span>(y=0;y<c->height;y++) {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>            <span style='color:blue'>for</span>(x=0;x<c->width;x++) {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>                frame->data[0][y * frame->linesize[0] + x] = x + y + i * 3;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>           }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>        }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>        <span style='color:green'>/* Cb and Cr */</span><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>        <span style='color:blue'>for</span>(y=0;y<c->height/2;y++) {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>            <span style='color:blue'>for</span>(x=0;x<c->width/2;x++) {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>                frame->data[1][y * frame->linesize[1] + x] = 128 + y + i * 2;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>                frame->data[2][y * frame->linesize[2] + x] = 64 + x + i * 5;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>            }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>        }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>        frame->pts = i;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>        <span style='color:green'>/* encode the image */</span><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>        ret = avcodec_encode_video2(c, &pkt, frame, &got_output);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>        <span style='color:blue'>if</span> (ret < 0) {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>            fprintf(stderr, <span style='color:#A31515'>"Error encoding frame\n"</span>);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>            exit(1);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>        }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>        <o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>        <span style='color:blue'>if</span> (got_output) {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>            printf(<span style='color:#A31515'>"Write frame %3d (size=%5d)\n"</span>, i, pkt.size);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>            fwrite(pkt.data, 1, pkt.size, f);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>            av_free_packet(&pkt);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>        }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>    }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>    <span style='color:green'>/* get the delayed frames */</span><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>    <span style='color:blue'>for</span> (got_output = 1; got_output; i++) {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>        fflush(stdout);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>        ret = avcodec_encode_video2(c, &pkt, NULL, &got_output);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>        <span style='color:blue'>if</span> (ret < 0) {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>            fprintf(stderr, <span style='color:#A31515'>"Error encoding frame\n"</span>);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>            exit(1);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>        }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>        <span style='color:blue'>if</span> (got_output) {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>            printf(<span style='color:#A31515'>"Write frame %3d (size=%5d)\n"</span>, i, pkt.size);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>            fwrite(pkt.data, 1, pkt.size, f);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>            av_free_packet(&pkt);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>        }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>    }<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> <a href="mailto:libav-user-bounces@ffmpeg.org">libav-user-bounces@ffmpeg.org</a> [<a href="mailto:libav-user-bounces@ffmpeg.org">mailto:libav-user-bounces@ffmpeg.org</a>] <b>On Behalf Of </b>Ashwin Chandra - SISA<br><b>Sent:</b> Thursday, February 07, 2013 3:08 PM<br><b>To:</b> <a href="mailto:libav-user@ffmpeg.org">libav-user@ffmpeg.org</a><br><b>Subject:</b> [Libav-user] Problem with using libavcodec with AV_CODEC_ID_H264<o:p></o:p></span></p></div></div><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US>I have some code that takes a running stream of uncompressed video data and encodes it using </span><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>AV_CODEC_ID_H264.<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>The sequence I follow is<o:p></o:p></span></p><p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo2;text-autospace:none'><![if !supportLists]><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'><span style='mso-list:Ignore'>1.<span style='font:7.0pt "Times New Roman"'>  </span></span></span><![endif]><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>Call avcodec_encode_video2 on the AVFrame which contains my uncompressed frame.<o:p></o:p></span></p><p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo2;text-autospace:none'><![if !supportLists]><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'><span style='mso-list:Ignore'>2.<span style='font:7.0pt "Times New Roman"'>  </span></span></span><![endif]><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>Call avcodec_encode_video2 again passing NULL in the AVFrame parameter.<o:p></o:p></span></p><p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo2;text-autospace:none'><![if !supportLists]><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'><span style='mso-list:Ignore'>3.<span style='font:7.0pt "Times New Roman"'>  </span></span></span><![endif]><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>Repeat 2. Until a frame arrives from the encoder.<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>This seems to work fine if the codec is MPEG2, but with H264, it hangs inside avcodec_encode_video2 at step 2) on the second frame. I don’t have debug symbols and can’t figure out why. Does there need to be a minimum set of uncompressed data in the encoder before trying to flush out an encoded frame for H264? If so, how do I know when it is safe to flush a frame?<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'><o:p> </o:p></span></p></div></body></html>