<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue-Light, Helvetica Neue Light, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div dir="ltr" id="yui_3_16_0_1_1420776109032_8447"><span id="yui_3_16_0_1_1420776109032_8526">Hi ,I want to open audio and Screen grab devices in my application ( will encode and mux them into an output video) like this <br></span></div><div id="yui_3_16_0_1_1420776109032_8641" dir="ltr"><br><span id="yui_3_16_0_1_1420776109032_8526"></span></div><div id="yui_3_16_0_1_1420776109032_8762" dir="ltr"><span class="" style=" color:#c0c0c0;"> </span><span class="" style=" color:#800080;">AVInputFormat</span><span class="" style=" color:#c0c0c0;"> </span><span class="" style=" color:#000000;">*</span><span class="" style=" color:#000000;">ifmt</span><span class="" style=" color:#000000;">=</span><span id="yui_3_16_0_1_1420776109032_9329" class="" style=" color:#000000;">av_find_input_format</span><span class="" style=" color:#000000;">(</span><span class="" style=" color:#008000;">"gdigrab"</span><span class="" style=" color:#000000;">);</span>
</div><pre id="yui_3_16_0_1_1420776109032_8764" class="" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span class="" style=" color:#c0c0c0;">    </span><span class="" style=" color:#808000;">if</span><span class="" style=" color:#000000;">(</span><span id="yui_3_16_0_1_1420776109032_8768" class="" style=" color:#000000;">avformat_open_input</span><span id="yui_3_16_0_1_1420776109032_8767" class="" style=" color:#000000;">(&</span><span id="yui_3_16_0_1_1420776109032_8766" class="" style=" color:#000000;">pFormatCtx</span><span class="" style=" color:#000000;">,</span><span id="yui_3_16_0_1_1420776109032_8765" class="" style=" color:#008000;">"desktop"</span><span id="yui_3_16_0_1_1420776109032_8763" class="" style=" color:#000000;">,</span><span id="yui_3_16_0_1_1420776109032_8802" class="" style=" color:#000000;">ifmt</span><span class="" style=" color:#000000;">,&</span><span class="" style=" color:#000000;">options</span><span id="yui_3_16_0_1_1420776109032_9023" class="" style=" color:#000000;">)!=</span><span class="" style=" color:#000080;">0</span><span class="" style=" color:#000000;">){</span></pre>
<pre id="yui_3_16_0_1_1420776109032_8770" class="" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span class="" style=" color:#c0c0c0;">        </span><span class="" style=" color:#000000;">printf</span><span class="" style=" color:#000000;">(</span><span class="" style=" color:#008000;">"Couldn't</span><span class="" style=" color:#c0c0c0;"> </span><span id="yui_3_16_0_1_1420776109032_8769" class="" style=" color:#008000;">open</span><span class="" style=" color:#c0c0c0;"> </span><span class="" style=" color:#008000;">input</span><span class="" style=" color:#c0c0c0;"> </span><span id="yui_3_16_0_1_1420776109032_8801" class="" style=" color:#008000;">stream.\n"</span><span class="" style=" color:#000000;">);</span></pre>
<pre id="yui_3_16_0_1_1420776109032_8800" class="" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span class="" style=" color:#c0c0c0;">        </span><span class="" style=" color:#808000;">return</span><span class="" style=" color:#c0c0c0;"> </span><span class="" style=" color:#000000;">-</span><span class="" style=" color:#000080;">1</span><span class="" style=" color:#000000;">;</span></pre>
<pre id="yui_3_16_0_1_1420776109032_8771" class="" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span class="" style=" color:#c0c0c0;">    </span><span class="" style=" color:#000000;">}</span></pre>
<pre id="yui_3_16_0_1_1420776109032_8772" class="" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br style="" class=""></pre>
<pre id="yui_3_16_0_1_1420776109032_8774" class="" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span class="" style=" color:#c0c0c0;">   </span><span id="yui_3_16_0_1_1420776109032_8798" class="" style=" color:#008000;">//INPUT</span><span class="" style=" color:#c0c0c0;"> </span><span id="yui_3_16_0_1_1420776109032_8799" class="" style=" color:#008000;">TO</span><span id="yui_3_16_0_1_1420776109032_9014" class="" style=" color:#c0c0c0;"> </span><span id="yui_3_16_0_1_1420776109032_9015" class="" style=" color:#008000;">CAPTURE</span><span class="" style=" color:#c0c0c0;"> </span><span id="yui_3_16_0_1_1420776109032_8773" class="" style=" color:#008000;">AUDIO</span></pre>
<pre id="yui_3_16_0_1_1420776109032_8776" class="" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span id="yui_3_16_0_1_1420776109032_9004" class="" style=" color:#c0c0c0;">    </span><span id="yui_3_16_0_1_1420776109032_8797" class="" style=" color:#800080;">AVInputFormat</span><span id="yui_3_16_0_1_1420776109032_9017" class="" style=" color:#c0c0c0;"> </span><span id="yui_3_16_0_1_1420776109032_9018" class="" style=" color:#000000;">*</span><span id="yui_3_16_0_1_1420776109032_8775" class="" style=" color:#000000;">ifmtAudio</span><span class="" style=" color:#000000;">=</span><span id="yui_3_16_0_1_1420776109032_8817" class="" style=" color:#000000;">av_find_input_format</span><span class="" style=" color:#000000;">(</span><span class="" style=" color:#008000;">"dshow"</span><span id="yui_3_16_0_1_1420776109032_8804" class="" style=" color:#000000;">);</span></pre>
<pre id="yui_3_16_0_1_1420776109032_8778" class="" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span id="yui_3_16_0_1_1420776109032_8796" class="" style=" color:#c0c0c0;"><br></span><span id="yui_3_16_0_1_1420776109032_8777" class="" style=" color:#008000;"></span></pre>
<pre id="yui_3_16_0_1_1420776109032_8780" class="" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span id="yui_3_16_0_1_1420776109032_8795" class="" style=" color:#c0c0c0;">    </span><span id="yui_3_16_0_1_1420776109032_9013" class="" style=" color:#808000;">if</span><span class="" style=" color:#000000;">(</span><span id="yui_3_16_0_1_1420776109032_8779" class="" style=" color:#000000;">avformat_open_input</span><span class="" style=" color:#000000;">(&</span><span id="yui_3_16_0_1_1420776109032_8818" class="" style=" color:#000000;">pFormatCtxAudio</span><span id="yui_3_16_0_1_1420776109032_9022" class="" style=" color:#000000;">,</span><span id="yui_3_16_0_1_1420776109032_8805" class="" style=" color:#008000;">"audio=MicroPhone</span><span class="" style=" color:#c0c0c0;"> </span><span id="yui_3_16_0_1_1420776109032_9330" class="" style=" color:#008000;">(Realtek</span><span class="" style=" color:#c0c0c0;"> </span><span class="" style=" color:#008000;">Hight</span><span class="" style=" color:#c0c0c0;"> </span><span class="" style=" color:#008000;">Defini"</span><span class="" style=" color:#000000;">,</span><span id="yui_3_16_0_1_1420776109032_8814" class="" style=" color:#000000;">ifmtAudio</span><span class="" style=" color:#000000;">,</span><span id="yui_3_16_0_1_1420776109032_8782" class="" style=" color:#000080;">NULL</span><span id="yui_3_16_0_1_1420776109032_8781" class="" style=" color:#000000;">)!=</span><span class="" style=" color:#000080;">0</span><span id="yui_3_16_0_1_1420776109032_9019" class="" style=" color:#000000;">){</span></pre>
<pre id="yui_3_16_0_1_1420776109032_8784" class="" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span id="yui_3_16_0_1_1420776109032_8794" class="" style=" color:#c0c0c0;">        </span><span id="yui_3_16_0_1_1420776109032_8816" class="" style=" color:#000000;">printf</span><span class="" style=" color:#000000;">(</span><span id="yui_3_16_0_1_1420776109032_8783" class="" style=" color:#008000;">"Couldn't</span><span id="yui_3_16_0_1_1420776109032_8811" class="" style=" color:#c0c0c0;"> </span><span id="yui_3_16_0_1_1420776109032_8810" class="" style=" color:#008000;">open</span><span id="yui_3_16_0_1_1420776109032_8809" class="" style=" color:#c0c0c0;"> </span><span id="yui_3_16_0_1_1420776109032_8808" class="" style=" color:#008000;">input</span><span id="yui_3_16_0_1_1420776109032_8807" class="" style=" color:#c0c0c0;"> </span><span id="yui_3_16_0_1_1420776109032_8806" class="" style=" color:#008000;">audio</span><span id="yui_3_16_0_1_1420776109032_8820" class="" style=" color:#c0c0c0;"> </span><span id="yui_3_16_0_1_1420776109032_8819" class="" style=" color:#008000;">stream.\n"</span><span class="" style=" color:#000000;">);</span></pre>
<pre id="yui_3_16_0_1_1420776109032_8786" class="" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span id="yui_3_16_0_1_1420776109032_8793" class="" style=" color:#c0c0c0;">        </span><span id="yui_3_16_0_1_1420776109032_8789" class="" style=" color:#808000;">return</span><span id="yui_3_16_0_1_1420776109032_8788" class="" style=" color:#c0c0c0;"> </span><span id="yui_3_16_0_1_1420776109032_8787" class="" style=" color:#000000;">-</span><span id="yui_3_16_0_1_1420776109032_8785" class="" style=" color:#000080;">1</span><span class="" style=" color:#000000;">;</span></pre>
<pre id="yui_3_16_0_1_1420776109032_8790" class="" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span id="yui_3_16_0_1_1420776109032_8792" class="" style=" color:#c0c0c0;">    </span><span id="yui_3_16_0_1_1420776109032_8791" class="" style=" color:#000000;">}</span><span style="" class="" id="yui_3_16_0_1_1420776109032_8526"><br></span></pre><div id="yui_3_16_0_1_1420776109032_8519"><div id="yui_3_16_0_1_1420776109032_8815" dir="ltr"> but the audio is failing to open .Is this even the right way to open them if I plan to mux encoded streams later .This question is part of a program here:     <a id="yui_3_16_0_1_1420776109032_9332" href="http://stackoverflow.com/questions/27841180/libavcodec-how-to-encode-with-h264-codec-with-mp4-container-using-controllabl">libavcodec : how to encode with h264 codec ,with mp4 container using controllable frame rate and bitrate(through c code)</a> <br></div><div style="width:450px; font-family: 'Georgia', 'Times', 'Times New Roman', 'serif';margin-top:5px; margin-bottom: 5px; background-color: #ffffff;" id="enhancrCard_0" class="link-enhancr-attachment link-enhancr-element" contenteditable="false"><table id="yui_3_16_0_1_1420776109032_9356" class="link-enhancr-element" style="width:450px; height:170px; position: relative; display: block;" border="0" cellpadding="0" cellspacing="0"><tbody id="yui_3_16_0_1_1420776109032_9355"><tr id="yui_3_16_0_1_1420776109032_9365" class="link-enhancr-element"><td id="yui_3_16_0_1_1420776109032_9364" class="link-enhancr-element" colspan="8" style="height: 1px; background-color: #e5e5e5; font-size: 1px; border-collapse: collapse;"><div id="yui_3_16_0_1_1420776109032_9363" class="link-enhancr-element" style="height: 1px; background-color: #e5e5e5; font-size: 1px; line-height:0px;"> </div></td></tr><tr id="yui_3_16_0_1_1420776109032_9359" class="link-enhancr-element"><td rowspan="5" class="link-enhancr-element" style="width: 1px; background-color: #e5e5e5; font-size: 1pt; border-collapse: collapse;"><div class="link-enhancr-element" style="width: 1px; background-color: #e5e5e5; font-size: 1pt;"> </div></td><td id="yui_3_16_0_1_1420776109032_9383" class="link-enhancr-element" rowspan="5" style="vertical-align: middle; width: 168px; height: 168px; background-color: #000000;border-collapse: collapse;"><div id="yui_3_16_0_1_1420776109032_9382" class="link-enhancr-element" style="width: 168px;" align="center"><a id="yui_3_16_0_1_1420776109032_9381" href="http://stackoverflow.com/questions/27841180/libavcodec-how-to-encode-with-h264-codec-with-mp4-container-using-controllabl" class="link-enhancr-card-urlWrapper link-enhancr-element" style="text-decoration: none !important; color: #000000 !important;"><img id="yui_3_16_0_1_1420776109032_9380" alt="image" src="http://cdn.sstatic.net/stackoverflow/img/apple-touch-icon@2.png?v=fde65a5a78c6" class="link-enhancr-thumbnail-image link-enhancr-element" style="display: block; margin: auto;" height="168" width="168"></a></div></td><td rowspan="5" class="link-enhancr-element" style="width: 1px; background-color: #e5e5e5; font-size: 0pt; border-collapse: collapse;"><div class="link-enhancr-element" style="width: 1px; background-color: #e5e5e5; font-size: 1pt;"> </div></td><td id="yui_3_16_0_1_1420776109032_9390" rowspan="5" class="link-enhancr-element" style="width: 14px; background-color: #ffffff; font-size: 0pt; border-collapse: collapse;"><div class="link-enhancr-element" style="width: 14px; background-color: #ffffff; font-size: 14pt;"> </div></td><td id="yui_3_16_0_1_1420776109032_9358" colspan="2" class="link-enhancr-element" style="height: 6px; background-color: #ffffff; font-size: 0pt; border-collapse: collapse;"><div id="yui_3_16_0_1_1420776109032_9357" class="link-enhancr-element" style="height: 6px; background-color: #ffffff; font-size: 6pt;"> </div></td><td id="yui_3_16_0_1_1420776109032_9361" rowspan="5" class="link-enhancr-element" style="width: 20px; background-color: #ffffff; font-size: 0pt; border-collapse: collapse;"><div id="yui_3_16_0_1_1420776109032_9366" class="link-enhancr-element" style="width: 20px; background-color: #ffffff; font-size: 20pt;"> </div></td><td class="link-enhancr-element" rowspan="5" style="width: 1px; background-color: #e5e5e5; font-size: 1pt; border-collapse: collapse;" width="1"><div class="link-enhancr-element" style="width: 1px; background-color: #e5e5e5; font-size: 1pt;"> </div></td></tr><tr id="yui_3_16_0_1_1420776109032_9354"><td id="yui_3_16_0_1_1420776109032_9353" class="link-enhancr-element" colspan="2" style="width: 100%; vertical-align: middle; font-family: 'Georgia', 'Times', 'Times New Roman', 'serif';"><div id="yui_3_16_0_1_1420776109032_9352" class="link-enhancr-text-part link-enhancr-element" style="line-height:16.5px; background-color: #ffffff; height: 135px; width: 245px;"><div id="yui_3_16_0_1_1420776109032_9351" class="link-enhancr-element" style="word-wrap: break-word; word-break: break-all;"><span id="yui_3_16_0_1_1420776109032_9362" class="link-enhancr-element icon  icon-shrink link-enhancr-toggle"></span><span class="link-enhancr-element icon icon-close link-enhancr-delete"></span><a id="yui_3_16_0_1_1420776109032_9350" href="http://stackoverflow.com/questions/27841180/libavcodec-how-to-encode-with-h264-codec-with-mp4-container-using-controllabl" class="link-enhancr-card-urlWrapper link-enhancr-element" style="text-decoration: none !important; color: #000000 !important; line-height: 100%; font-size: 18px; display: block;"><span id="yui_3_16_0_1_1420776109032_9349" class="link-enhancr-element link-enhancr-card-title" style="margin: 0; font-weight: normal;margin-bottom: 3px; font-size: 18px; line-height: 21px; max-height: 43px; color: #000000; overflow: hidden !important; display: inline-block;">libavcodec : how to encode with h264 codec ,with mp4 con...</span></a><div id="yui_3_16_0_1_1420776109032_9367" style="font-size: 13px; line-height: 20px; color: #999999; max-height: 81px; font-family: 'Georgia', 'Times', 'Times New Roman', 'serif';overflow: hidden;" class="link-enhancr-card-description link-enhancr-element">I am trying to record the screen of a pc and encode the recorded frames using h264 encoder and wrap them into a mp4 container.I want to do this because...</div></div></div></td></tr><tr id="yui_3_16_0_1_1420776109032_9370"><td id="yui_3_16_0_1_1420776109032_9369" colspan="2" class="link-enhancr-element" style="height: 4px; background-color: #ffffff; font-size: 0pt; border-collapse: collapse;"><div id="yui_3_16_0_1_1420776109032_9368" class="link-enhancr-element" style="height: 4px; background-color: #ffffff; font-size: 4pt;"></div></td></tr><tr id="yui_3_16_0_1_1420776109032_9373"><td id="yui_3_16_0_1_1420776109032_9387" class="link-enhancr-element" style="vertical-align: middle; font-family: 'Arial', 'Helvetica Neue', 'Helvetica', 'sans-serif';"><div id="yui_3_16_0_1_1420776109032_9386" class="link-enhancr-element" style="font-size: 0pt;"><a id="yui_3_16_0_1_1420776109032_9385" href="http://stackoverflow.com/questions/27841180/libavcodec-how-to-encode-with-h264-codec-with-mp4-container-using-controllabl" class="link-enhancr-card-url link-enhancr-element" style="color: black; text-decoration: none !important;cursor:pointer !important;" target="_blank"><span id="yui_3_16_0_1_1420776109032_9347" class="link-enhancr-element link-enhancr-view-on" style="display: inline-block; line-height: 11px; max-width: 145px; min-width: 85px; overflow: hidden; max-height: 13px; word-break: break-all;"><span id="yui_3_16_0_1_1420776109032_9384" class="link-enhancr-element link-enhancr-mobile-no-resize" style="vertical-align:middle; font-size: 9px; line-height: 11px; color: #999999; -moz-text-size-adjust: none; -ms-text-size-adjust: none; -webkit-text-size-adjust:none; text-size-adjust:none;">Afficher sur <span style="font-weight: bold" class="link-enhancr-view-on-domain">stackoverflow.com</span></span></span></a></div></td><td id="yui_3_16_0_1_1420776109032_9372" class="link-enhancr-element" style="vertical-align: middle; width: 100px; font-family: 'Arial', 'Helvetica Neue', 'Helvetica', 'sans-serif';"><div id="yui_3_16_0_1_1420776109032_9371" class="link-enhancr-element link-enhancr-preview-wrapper" style="max-width: 100px; min-width: 80px; overflow: hidden; text-align: right; line-height: 11px; max-height: 13px; font-size: 0pt;"><span class="link-enhancr-element link-enhancr-preview-by link-enhancr-mobile-no-resize" style="vertical-align:middle; font-size: 9px; line-height: 11px; color: #999999; -moz-text-size-adjust: none; -ms-text-size-adjust: none; -webkit-text-size-adjust:none; text-size-adjust:none;">Aperçu par Yahoo</span></div></td></tr><tr id="yui_3_16_0_1_1420776109032_9376"><td id="yui_3_16_0_1_1420776109032_9375" colspan="2" class="link-enhancr-element" style="height: 9px; background-color: #ffffff; font-size: 0pt; border-collapse: collapse;"><div id="yui_3_16_0_1_1420776109032_9374" class="link-enhancr-element" style="height: 9px; background-color: #ffffff; font-size: 9pt;"></div></td></tr><tr id="yui_3_16_0_1_1420776109032_9379" class="link-enhancr-element"><td id="yui_3_16_0_1_1420776109032_9378" class="link-enhancr-element" colspan="8" style="height: 1px; background-color: #e5e5e5; font-size: 1px; border-collapse: collapse;"><div id="yui_3_16_0_1_1420776109032_9377" class="link-enhancr-element" style="height: 1px; background-color: #e5e5e5; font-size: 1px; line-height:0px"> </div></td></tr></tbody></table></div><div style="" class="" id="yui_3_16_0_1_1420776109032_8815" dir="ltr">  I am working on .I am new to libav* and any assistance will be appreciated.Thanks. <br style="" class=""></div><div style="" class="" id="yui_3_16_0_1_1420776109032_8815" dir="ltr"> </div></div><div id="yui_3_16_0_1_1420776109032_8529"><div id="yui_3_16_0_1_1420776109032_8528"><br></div></div></div></body></html>