<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<p style="margin: 0in 0in 8pt; line-height: 107%; font-size: 11pt; font-family: Calibri, sans-serif">
I have an issue that has me stumped. I have written a program than creates a flash video container (H.264 video and AAC audio streams) and writes it to a URL. If the URL is a file it is and playable and uploadable with no issues. But if the URL is a RTMP then
 it is stream but with buffering waits. But if the URL is pipe:1 passed to ffmpeg -i - -acodec copy -vcodec copy -f flv rtmp://a.rtmp.youtube.com/live2/<key> works just fine.</p>
<p style="margin: 0in 0in 8pt; line-height: 107%; font-size: 11pt; font-family: Calibri, sans-serif">
Here is the setup code:</p>
<p style="margin: 0in 0in 8pt; line-height: 107%; font-size: 11pt; font-family: Calibri, sans-serif;margin-bottom:0in;margin-bottom:.0001pt">
<span style="mso-tab-count:1"><br>
</span></p>
<p style="margin: 0in 0in 8pt; line-height: 107%; font-size: 11pt; font-family: Calibri, sans-serif;margin-bottom:0in;margin-bottom:.0001pt">
<span style="mso-tab-count:1">                </span>int status=0;</p>
<p style="margin: 0in 0in 8pt; line-height: 107%; font-size: 11pt; font-family: Calibri, sans-serif;margin-bottom:0in;margin-bottom:.0001pt">
<o:p> </o:p><span style="font-family: Calibri, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">//</span><span style="font-family: Calibri, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);"> 
</span><span style="font-family: Calibri, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">setup format context and io context</span></p>
<p style="margin: 0in 0in 8pt; line-height: 107%; font-size: 11pt; font-family: Calibri, sans-serif;margin-bottom:0in;margin-bottom:.0001pt">
//<span style="mso-spacerun:yes">  </span>tried with and without avformat_network_init();</p>
<p style="margin: 0in 0in 8pt; line-height: 107%; font-size: 11pt; font-family: Calibri, sans-serif;margin-bottom:0in;margin-bottom:.0001pt">
//<span style="mso-tab-count:1">            </span>avformat_network_init();</p>
<p style="margin: 0in 0in 8pt; line-height: 107%; font-size: 11pt; font-family: Calibri, sans-serif;margin-bottom:0in;margin-bottom:.0001pt">
<span style="mso-tab-count:1">                </span>if ((status = avio_open(&io_ctx, filename, AVIO_FLAG_WRITE)))</p>
<p style="margin: 0in 0in 8pt; line-height: 107%; font-size: 11pt; font-family: Calibri, sans-serif;margin-bottom:0in;margin-bottom:.0001pt">
<span style="mso-tab-count:2">                                </span>{</p>
<p style="margin: 0in 0in 8pt; line-height: 107%; font-size: 11pt; font-family: Calibri, sans-serif;margin-bottom:0in;margin-bottom:.0001pt">
<span style="mso-tab-count:2">                                </span>fprintf(stderr, "Could not open output file '%s' (error '%s')\n", filename, av_err2str(status));</p>
<p style="margin: 0in 0in 8pt; line-height: 107%; font-size: 11pt; font-family: Calibri, sans-serif;margin-bottom:0in;margin-bottom:.0001pt">
<span style="mso-tab-count:2">                                </span>return -1;</p>
<p style="margin: 0in 0in 8pt; line-height: 107%; font-size: 11pt; font-family: Calibri, sans-serif;margin-bottom:0in;margin-bottom:.0001pt">
<span style="mso-tab-count:2">                                </span>}</p>
<p style="margin: 0in 0in 8pt; line-height: 107%; font-size: 11pt; font-family: Calibri, sans-serif;margin-bottom:0in;margin-bottom:.0001pt">
<span style="mso-tab-count:1">                </span>avformat_alloc_output_context2(&flv_frmtctx, NULL, "flv", NULL);</p>
<p style="margin: 0in 0in 8pt; line-height: 107%; font-size: 11pt; font-family: Calibri, sans-serif;margin-bottom:0in;margin-bottom:.0001pt">
<span style="mso-tab-count:1">                </span>if (!flv_frmtctx) </p>
<p style="margin: 0in 0in 8pt; line-height: 107%; font-size: 11pt; font-family: Calibri, sans-serif;margin-bottom:0in;margin-bottom:.0001pt">
<span style="mso-tab-count:2">                                </span>{</p>
<p style="margin: 0in 0in 8pt; line-height: 107%; font-size: 11pt; font-family: Calibri, sans-serif;margin-bottom:0in;margin-bottom:.0001pt">
<span style="mso-tab-count:2">                                </span>fprintf(stderr, "Could not allocate output format context\n");</p>
<p style="margin: 0in 0in 8pt; line-height: 107%; font-size: 11pt; font-family: Calibri, sans-serif;margin-bottom:0in;margin-bottom:.0001pt">
<span style="mso-tab-count:2">                                </span>return -1;</p>
<p style="margin: 0in 0in 8pt; line-height: 107%; font-size: 11pt; font-family: Calibri, sans-serif;margin-bottom:0in;margin-bottom:.0001pt">
<span style="mso-tab-count:2">                                </span>}</p>
<p style="margin: 0in 0in 8pt; line-height: 107%; font-size: 11pt; font-family: Calibri, sans-serif;margin-bottom:0in;margin-bottom:.0001pt">
<span style="mso-tab-count:1">                </span>flv_frmtctx->pb = io_ctx;</p>
<p style="margin: 0in 0in 8pt; line-height: 107%; font-size: 11pt; font-family: Calibri, sans-serif;margin-bottom:0in;margin-bottom:.0001pt">
<span style="mso-tab-count:1">                </span>if (!(flv_frmtctx->url = av_strdup(filename)))
</p>
<p style="margin: 0in 0in 8pt; line-height: 107%; font-size: 11pt; font-family: Calibri, sans-serif;margin-bottom:0in;margin-bottom:.0001pt">
<span style="mso-tab-count:2">                                </span>{</p>
<p style="margin: 0in 0in 8pt; line-height: 107%; font-size: 11pt; font-family: Calibri, sans-serif;margin-top:0in;margin-right:0in;margin-bottom:0in;
margin-left:.5in;margin-bottom:.0001pt;text-indent:.5in">
   fprintf(stderr, "Could not copy url.\n");</p>
<p style="margin: 0in 0in 8pt; line-height: 107%; font-size: 11pt; font-family: Calibri, sans-serif;margin-bottom:0in;margin-bottom:.0001pt">
<span style="mso-spacerun:yes">        </span><span style="mso-tab-count:2">                        </span>return -1;</p>
<p style="margin: 0in 0in 8pt; line-height: 107%; font-size: 11pt; font-family: Calibri, sans-serif;margin-bottom:0in;margin-bottom:.0001pt">
<span style="mso-tab-count:2">                                </span>}</p>
<p style="margin: 0in 0in 8pt; line-height: 107%; font-size: 11pt; font-family: Calibri, sans-serif">
<o:p> </o:p></p>
<p style="margin: 0in 0in 8pt; line-height: 107%; font-size: 11pt; font-family: Calibri, sans-serif">
The I understand the FFMPEG command is just a passthru with just copy of both streams and no changes to either stream or container but it streams just fine.</p>
<p style="margin: 0in 0in 8pt; line-height: 107%; font-size: 11pt; font-family: Calibri, sans-serif">
So any ideas what I am doing wrong or missing in my code that is being done by FFMPEG?</p>
<p style="margin: 0in 0in 8pt; line-height: 107%; font-size: 11pt; font-family: Calibri, sans-serif">
<o:p> </o:p></p>
<p style="margin: 0in 0in 8pt; line-height: 107%; font-size: 11pt; font-family: Calibri, sans-serif">
<o:p> </o:p></p>
<br>
</div>
</body>
</html>