Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
ffmpeg-doc / usr / share / doc / ffmpeg-doc / api / transcoding_8c-example.html
Size: Mime:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>FFmpeg: transcoding.c</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">FFmpeg
   &#160;<span id="projectnumber">2.7.1</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="examples.html"><span>Examples</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">transcoding.c</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><pre class="fragment"><span class="comment">/*</span>
<span class="comment"> * Copyright (c) 2010 Nicolas George</span>
<span class="comment"> * Copyright (c) 2011 Stefano Sabatini</span>
<span class="comment"> * Copyright (c) 2014 Andrey Utkin</span>
<span class="comment"> *</span>
<span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining a copy</span>
<span class="comment"> * of this software and associated documentation files (the &quot;Software&quot;), to deal</span>
<span class="comment"> * in the Software without restriction, including without limitation the rights</span>
<span class="comment"> * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell</span>
<span class="comment"> * copies of the Software, and to permit persons to whom the Software is</span>
<span class="comment"> * furnished to do so, subject to the following conditions:</span>
<span class="comment"> *</span>
<span class="comment"> * The above copyright notice and this permission notice shall be included in</span>
<span class="comment"> * all copies or substantial portions of the Software.</span>
<span class="comment"> *</span>
<span class="comment"> * THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR</span>
<span class="comment"> * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span>
<span class="comment"> * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL</span>
<span class="comment"> * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span>
<span class="comment"> * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,</span>
<span class="comment"> * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN</span>
<span class="comment"> * THE SOFTWARE.</span>
<span class="comment"> */</span>
<span class="comment"></span>
<span class="comment">/**</span>
<span class="comment"> * @file</span>
<span class="comment"> * API example for demuxing, decoding, filtering, encoding and muxing</span>
<span class="comment"> * @example transcoding.c</span>
<span class="comment"> */</span>

<span class="preprocessor">#include &lt;<a class="code" href="libavcodec_2avcodec_8h.html" title="Libavcodec external API header.">libavcodec/avcodec.h</a>&gt;</span>
<span class="preprocessor">#include &lt;<a class="code" href="avformat_8h.html" title="Main libavformat public API header.">libavformat/avformat.h</a>&gt;</span>
<span class="preprocessor">#include &lt;<a class="code" href="avfiltergraph_8h.html">libavfilter/avfiltergraph.h</a>&gt;</span>
<span class="preprocessor">#include &lt;<a class="code" href="libavfilter_2avcodec_8h.html" title="libavcodec/libavfilter gluing utilities">libavfilter/avcodec.h</a>&gt;</span>
<span class="preprocessor">#include &lt;<a class="code" href="buffersink_8h.html" title="memory buffer sink API for audio and video">libavfilter/buffersink.h</a>&gt;</span>
<span class="preprocessor">#include &lt;<a class="code" href="buffersrc_8h.html" title="Memory buffer source API.">libavfilter/buffersrc.h</a>&gt;</span>
<span class="preprocessor">#include &lt;<a class="code" href="opt_8h.html" title="AVOptions.">libavutil/opt.h</a>&gt;</span>
<span class="preprocessor">#include &lt;<a class="code" href="pixdesc_8h.html">libavutil/pixdesc.h</a>&gt;</span>

<span class="keyword">static</span> <a name="_a0"></a><a class="code" href="structAVFormatContext.html" title="Format I/O context.">AVFormatContext</a> *<a name="a1"></a><a class="code" href="transcoding_8c.html#a24170971d926c1359c289f2515dec3d7">ifmt_ctx</a>;
<span class="keyword">static</span> <a class="code" href="structAVFormatContext.html" title="Format I/O context.">AVFormatContext</a> *<a name="a2"></a><a class="code" href="transcoding_8c.html#aad50129a22f90b00b5d5cc7551175093">ofmt_ctx</a>;
<span class="keyword">typedef</span> <span class="keyword">struct </span><a name="_a3"></a><a class="code" href="structFilteringContext.html">FilteringContext</a> {
    <a name="_a4"></a><a class="code" href="structAVFilterContext.html" title="An instance of a filter.">AVFilterContext</a> *<a name="a5"></a><a class="code" href="structFilteringContext.html#a4476c9e6fb492172c909ae4a47c47233">buffersink_ctx</a>;
    <a class="code" href="structAVFilterContext.html" title="An instance of a filter.">AVFilterContext</a> *<a name="a6"></a><a class="code" href="structFilteringContext.html#a25c500d3728df3a9f904e6d86cf55f11">buffersrc_ctx</a>;
    <a name="_a7"></a><a class="code" href="structAVFilterGraph.html">AVFilterGraph</a> *<a name="a8"></a><a class="code" href="structFilteringContext.html#aaf35e44d4e6100095b1db444e2d316cd">filter_graph</a>;
} <a class="code" href="structFilteringContext.html">FilteringContext</a>;
<span class="keyword">static</span> <a class="code" href="structFilteringContext.html">FilteringContext</a> *<a name="a9"></a><a class="code" href="transcoding_8c.html#aac21c1c8f68cdafd001a6a13dc4d7fb7">filter_ctx</a>;

<span class="keyword">static</span> <span class="keywordtype">int</span> <a name="a10"></a><a class="code" href="filtering__audio_8c.html#abd04bf1a933d4d2698482f4949c61fed">open_input_file</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *filename)
{
    <span class="keywordtype">int</span> ret;
    <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i;

    ifmt_ctx = NULL;
    <span class="keywordflow">if</span> ((ret = <a name="a11"></a><a class="code" href="group__lavf__decoding.html#ga10a404346c646e4ab58f4ed798baca32" title="Open an input stream and read the header.">avformat_open_input</a>(&amp;ifmt_ctx, filename, NULL, NULL)) &lt; 0) {
        <a name="a12"></a><a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a name="a13"></a><a class="code" href="group__lavu__log__constants.html#gaffe151ff4cd8a24b2e77ac8d9616c85c" title="Something went wrong and cannot losslessly be recovered.">AV_LOG_ERROR</a>, <span class="stringliteral">&quot;Cannot open input file\n&quot;</span>);
        <span class="keywordflow">return</span> ret;
    }

    <span class="keywordflow">if</span> ((ret = <a name="a14"></a><a class="code" href="group__lavf__decoding.html#gad42172e27cddafb81096939783b157bb" title="Read packets of a media file to get stream information.">avformat_find_stream_info</a>(ifmt_ctx, NULL)) &lt; 0) {
        <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a class="code" href="group__lavu__log__constants.html#gaffe151ff4cd8a24b2e77ac8d9616c85c" title="Something went wrong and cannot losslessly be recovered.">AV_LOG_ERROR</a>, <span class="stringliteral">&quot;Cannot find stream information\n&quot;</span>);
        <span class="keywordflow">return</span> ret;
    }

    <span class="keywordflow">for</span> (i = 0; i &lt; ifmt_ctx-&gt;<a name="a15"></a><a class="code" href="structAVFormatContext.html#a0b748d924898b08b89ff4974afd17285" title="Number of elements in AVFormatContext.streams.">nb_streams</a>; i++) {
        <a name="_a16"></a><a class="code" href="structAVStream.html" title="Stream structure.">AVStream</a> *stream;
        <a name="_a17"></a><a class="code" href="structAVCodecContext.html" title="main external API structure.">AVCodecContext</a> *codec_ctx;
        stream = ifmt_ctx-&gt;<a name="a18"></a><a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[i];
        codec_ctx = stream-&gt;<a name="a19"></a><a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>;
        <span class="comment">/* Reencode video &amp; audio and remux subtitles etc. */</span>
        <span class="keywordflow">if</span> (codec_ctx-&gt;<a name="a20"></a><a class="code" href="structAVCodecContext.html#a3f99ca3115c44e6d7772c9384faf15e6">codec_type</a> == <a name="a21"></a><a class="code" href="group__lavu__misc.html#gga9a84bba4713dfced21a1a56163be1f48ac1a46f59be5c6c2d3412ab172d6b8cf5">AVMEDIA_TYPE_VIDEO</a>
                || codec_ctx-&gt;<a class="code" href="structAVCodecContext.html#a3f99ca3115c44e6d7772c9384faf15e6">codec_type</a> == <a name="a22"></a><a class="code" href="group__lavu__misc.html#gga9a84bba4713dfced21a1a56163be1f48a7b4e33b8f30ac94d34ce8d9f7c33927a">AVMEDIA_TYPE_AUDIO</a>) {
            <span class="comment">/* Open decoder */</span>
            ret = <a name="a23"></a><a class="code" href="group__lavc__core.html#ga11f785a188d7d9df71621001465b0f1d" title="Initialize the AVCodecContext to use the given AVCodec.">avcodec_open2</a>(codec_ctx,
                    <a name="a24"></a><a class="code" href="group__lavc__decoding.html#ga19a0ca553277f019dd5b0fec6e1f9dca" title="Find a registered decoder with a matching codec ID.">avcodec_find_decoder</a>(codec_ctx-&gt;<a name="a25"></a><a class="code" href="structAVCodecContext.html#adc5f65d6099fd8339c1580c091777223">codec_id</a>), NULL);
            <span class="keywordflow">if</span> (ret &lt; 0) {
                <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a class="code" href="group__lavu__log__constants.html#gaffe151ff4cd8a24b2e77ac8d9616c85c" title="Something went wrong and cannot losslessly be recovered.">AV_LOG_ERROR</a>, <span class="stringliteral">&quot;Failed to open decoder for stream #%u\n&quot;</span>, i);
                <span class="keywordflow">return</span> ret;
            }
        }
    }

    <a name="a26"></a><a class="code" href="group__lavf__misc.html#gae2645941f2dc779c307eb6314fd39f10" title="Print detailed information about the input or output format, such as duration, bitrate, streams, container, programs, metadata, side data, codec and time base.">av_dump_format</a>(ifmt_ctx, 0, filename, 0);
    <span class="keywordflow">return</span> 0;
}

<span class="keyword">static</span> <span class="keywordtype">int</span> <a name="a27"></a><a class="code" href="transcode__aac_8c.html#a617f4760254c119fc7caa222f3fcbd21" title="Open an output file and the required encoder.">open_output_file</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *filename)
{
    <a class="code" href="structAVStream.html" title="Stream structure.">AVStream</a> *out_stream;
    <a class="code" href="structAVStream.html" title="Stream structure.">AVStream</a> *in_stream;
    <a class="code" href="structAVCodecContext.html" title="main external API structure.">AVCodecContext</a> *<a name="a28"></a><a class="code" href="filtering__audio_8c.html#ac2bf6798f37e95d3d2ff2d44e4ab3c12">dec_ctx</a>, *enc_ctx;
    <a name="_a29"></a><a class="code" href="structAVCodec.html" title="AVCodec.">AVCodec</a> *encoder;
    <span class="keywordtype">int</span> ret;
    <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i;

    ofmt_ctx = NULL;
    <a name="a30"></a><a class="code" href="avformat_8h.html#a6ddf3d982feb45fa5081420ee911f5d5" title="Allocate an AVFormatContext for an output format.">avformat_alloc_output_context2</a>(&amp;ofmt_ctx, NULL, NULL, filename);
    <span class="keywordflow">if</span> (!ofmt_ctx) {
        <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a class="code" href="group__lavu__log__constants.html#gaffe151ff4cd8a24b2e77ac8d9616c85c" title="Something went wrong and cannot losslessly be recovered.">AV_LOG_ERROR</a>, <span class="stringliteral">&quot;Could not create output context\n&quot;</span>);
        <span class="keywordflow">return</span> <a name="a31"></a><a class="code" href="group__lavu__error.html#ga4ebaa288c7684a26a591c501208910e4" title="Unknown error, typically from an external library.">AVERROR_UNKNOWN</a>;
    }


    <span class="keywordflow">for</span> (i = 0; i &lt; ifmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#a0b748d924898b08b89ff4974afd17285" title="Number of elements in AVFormatContext.streams.">nb_streams</a>; i++) {
        out_stream = <a name="a32"></a><a class="code" href="group__lavf__core.html#gadcb0fd3e507d9b58fe78f61f8ad39827" title="Add a new stream to a media file.">avformat_new_stream</a>(ofmt_ctx, NULL);
        <span class="keywordflow">if</span> (!out_stream) {
            <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a class="code" href="group__lavu__log__constants.html#gaffe151ff4cd8a24b2e77ac8d9616c85c" title="Something went wrong and cannot losslessly be recovered.">AV_LOG_ERROR</a>, <span class="stringliteral">&quot;Failed allocating output stream\n&quot;</span>);
            <span class="keywordflow">return</span> <a class="code" href="group__lavu__error.html#ga4ebaa288c7684a26a591c501208910e4" title="Unknown error, typically from an external library.">AVERROR_UNKNOWN</a>;
        }

        in_stream = ifmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[i];
        dec_ctx = in_stream-&gt;<a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>;
        enc_ctx = out_stream-&gt;<a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>;

        <span class="keywordflow">if</span> (dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#a3f99ca3115c44e6d7772c9384faf15e6">codec_type</a> == <a class="code" href="group__lavu__misc.html#gga9a84bba4713dfced21a1a56163be1f48ac1a46f59be5c6c2d3412ab172d6b8cf5">AVMEDIA_TYPE_VIDEO</a>
                || dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#a3f99ca3115c44e6d7772c9384faf15e6">codec_type</a> == <a class="code" href="group__lavu__misc.html#gga9a84bba4713dfced21a1a56163be1f48a7b4e33b8f30ac94d34ce8d9f7c33927a">AVMEDIA_TYPE_AUDIO</a>) {
            <span class="comment">/* in this example, we choose transcoding to same codec */</span>
            encoder = <a name="a33"></a><a class="code" href="group__lavc__encoding.html#ga9f820c481615c3a02d0407bac0bdbf25" title="Find a registered encoder with a matching codec ID.">avcodec_find_encoder</a>(dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#adc5f65d6099fd8339c1580c091777223">codec_id</a>);
            <span class="keywordflow">if</span> (!encoder) {
                <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a name="a34"></a><a class="code" href="group__lavu__log__constants.html#ga96970a2980bf6ad28cd403e7dc52d6c5" title="Something went wrong and recovery is not possible.">AV_LOG_FATAL</a>, <span class="stringliteral">&quot;Necessary encoder not found\n&quot;</span>);
                <span class="keywordflow">return</span> <a name="a35"></a><a class="code" href="group__lavu__error.html#gaa6e5781e75b15ce44b0baea170c98a45" title="Invalid data found when processing input.">AVERROR_INVALIDDATA</a>;
            }

            <span class="comment">/* In this example, we transcode to same properties (picture size,</span>
<span class="comment">             * sample rate etc.). These properties can be changed for output</span>
<span class="comment">             * streams easily using filters */</span>
            <span class="keywordflow">if</span> (dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#a3f99ca3115c44e6d7772c9384faf15e6">codec_type</a> == <a class="code" href="group__lavu__misc.html#gga9a84bba4713dfced21a1a56163be1f48ac1a46f59be5c6c2d3412ab172d6b8cf5">AVMEDIA_TYPE_VIDEO</a>) {
                enc_ctx-&gt;<a name="a36"></a><a class="code" href="structAVCodecContext.html#a0449afd803eb107bd4dbc8b5ea22e363">height</a> = dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#a0449afd803eb107bd4dbc8b5ea22e363">height</a>;
                enc_ctx-&gt;<a name="a37"></a><a class="code" href="structAVCodecContext.html#a0d8f46461754e8abea0847dcbc41b956" title="picture width / height.">width</a> = dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#a0d8f46461754e8abea0847dcbc41b956" title="picture width / height.">width</a>;
                enc_ctx-&gt;<a name="a38"></a><a class="code" href="structAVCodecContext.html#a5252d34fbce300228d4dbda19a8c3293" title="sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...">sample_aspect_ratio</a> = dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#a5252d34fbce300228d4dbda19a8c3293" title="sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...">sample_aspect_ratio</a>;
                <span class="comment">/* take first format from list of supported formats */</span>
                enc_ctx-&gt;<a name="a39"></a><a class="code" href="structAVCodecContext.html#a0425c77b3d06d71e5db88b1d7e1b37f2" title="Pixel format, see AV_PIX_FMT_xxx.">pix_fmt</a> = encoder-&gt;<a name="a40"></a><a class="code" href="structAVCodec.html#ac2b97bd3c19686025e1b7d577329c250" title="array of supported pixel formats, or NULL if unknown, array is terminated by -1">pix_fmts</a>[0];
                <span class="comment">/* video time_base can be set to whatever is handy and supported by encoder */</span>
                enc_ctx-&gt;<a name="a41"></a><a class="code" href="structAVCodecContext.html#ab7bfeb9fa5840aac090e2b0bd0ef7589" title="This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...">time_base</a> = dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#ab7bfeb9fa5840aac090e2b0bd0ef7589" title="This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...">time_base</a>;
            } <span class="keywordflow">else</span> {
                enc_ctx-&gt;<a name="a42"></a><a class="code" href="structAVCodecContext.html#a8ff0b000c463361e234af48d03aadfc0" title="samples per second">sample_rate</a> = dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#a8ff0b000c463361e234af48d03aadfc0" title="samples per second">sample_rate</a>;
                enc_ctx-&gt;<a name="a43"></a><a class="code" href="structAVCodecContext.html#aeb08c575a79eb84fc4155dda88f46c06" title="Audio channel layout.">channel_layout</a> = dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#aeb08c575a79eb84fc4155dda88f46c06" title="Audio channel layout.">channel_layout</a>;
                enc_ctx-&gt;<a name="a44"></a><a class="code" href="structAVCodecContext.html#ac1e6c2cd1269caa7570575725c682a49" title="number of audio channels">channels</a> = <a name="a45"></a><a class="code" href="group__channel__mask__c.html#gac95619abeb32e4a3daa18e3ff3419380" title="Return the number of channels in the channel layout.">av_get_channel_layout_nb_channels</a>(enc_ctx-&gt;<a class="code" href="structAVCodecContext.html#aeb08c575a79eb84fc4155dda88f46c06" title="Audio channel layout.">channel_layout</a>);
                <span class="comment">/* take first format from list of supported formats */</span>
                enc_ctx-&gt;<a name="a46"></a><a class="code" href="structAVCodecContext.html#a1bdba69ea111e2a9d03fdaa7a46a4c45" title="audio sample format">sample_fmt</a> = encoder-&gt;<a name="a47"></a><a class="code" href="structAVCodec.html#aac19f4c45370f715412ad5c7b78daacf" title="array of supported sample formats, or NULL if unknown, array is terminated by -1">sample_fmts</a>[0];
                enc_ctx-&gt;<a class="code" href="structAVCodecContext.html#ab7bfeb9fa5840aac090e2b0bd0ef7589" title="This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...">time_base</a> = (<a name="_a48"></a><a class="code" href="structAVRational.html" title="rational number numerator/denominator">AVRational</a>){1, enc_ctx-&gt;<a class="code" href="structAVCodecContext.html#a8ff0b000c463361e234af48d03aadfc0" title="samples per second">sample_rate</a>};
            }

            <span class="comment">/* Third parameter can be used to pass settings to encoder */</span>
            ret = <a class="code" href="group__lavc__core.html#ga11f785a188d7d9df71621001465b0f1d" title="Initialize the AVCodecContext to use the given AVCodec.">avcodec_open2</a>(enc_ctx, encoder, NULL);
            <span class="keywordflow">if</span> (ret &lt; 0) {
                <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a class="code" href="group__lavu__log__constants.html#gaffe151ff4cd8a24b2e77ac8d9616c85c" title="Something went wrong and cannot losslessly be recovered.">AV_LOG_ERROR</a>, <span class="stringliteral">&quot;Cannot open video encoder for stream #%u\n&quot;</span>, i);
                <span class="keywordflow">return</span> ret;
            }
        } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#a3f99ca3115c44e6d7772c9384faf15e6">codec_type</a> == <a name="a49"></a><a class="code" href="group__lavu__misc.html#gga9a84bba4713dfced21a1a56163be1f48afdadbd6c4f612c59f6b6c7c6f84fd347" title="Usually treated as AVMEDIA_TYPE_DATA.">AVMEDIA_TYPE_UNKNOWN</a>) {
            <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a class="code" href="group__lavu__log__constants.html#ga96970a2980bf6ad28cd403e7dc52d6c5" title="Something went wrong and recovery is not possible.">AV_LOG_FATAL</a>, <span class="stringliteral">&quot;Elementary stream #%d is of unknown type, cannot proceed\n&quot;</span>, i);
            <span class="keywordflow">return</span> <a class="code" href="group__lavu__error.html#gaa6e5781e75b15ce44b0baea170c98a45" title="Invalid data found when processing input.">AVERROR_INVALIDDATA</a>;
        } <span class="keywordflow">else</span> {
            <span class="comment">/* if this stream must be remuxed */</span>
            ret = <a name="a50"></a><a class="code" href="group__lavc__core.html#ga3933b21b9dcb9173df3e56673b7a7d76" title="Copy the settings of the source AVCodecContext into the destination AVCodecContext.">avcodec_copy_context</a>(ofmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[i]-&gt;<a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>,
                    ifmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[i]-&gt;<a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>);
            <span class="keywordflow">if</span> (ret &lt; 0) {
                <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a class="code" href="group__lavu__log__constants.html#gaffe151ff4cd8a24b2e77ac8d9616c85c" title="Something went wrong and cannot losslessly be recovered.">AV_LOG_ERROR</a>, <span class="stringliteral">&quot;Copying stream context failed\n&quot;</span>);
                <span class="keywordflow">return</span> ret;
            }
        }

        <span class="keywordflow">if</span> (ofmt_ctx-&gt;<a name="a51"></a><a class="code" href="structAVFormatContext.html#a20d80ac07e38ff5c268d15aaf2798b98" title="The output container format.">oformat</a>-&gt;<a name="a52"></a><a class="code" href="structAVOutputFormat.html#aad55a00e728a020c1dcfaaf695320445" title="can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_RAWPICTURE, AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS, AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, AVFMT_ALLOW_FLUSH, AVFMT_TS_NONSTRICT">flags</a> &amp; <a name="a53"></a><a class="code" href="avformat_8h.html#ab203c7b734e9c31b7c37d34f6e2c6aef" title="Format wants global header.">AVFMT_GLOBALHEADER</a>)
            enc_ctx-&gt;<a name="a54"></a><a class="code" href="structAVCodecContext.html#abb01e291550fa3fb96188af4d494587e" title="CODEC_FLAG_*.">flags</a> |= <a name="a55"></a><a class="code" href="group__lavc__core.html#gaab6ceefd617cf265ef7ea1b87ed5933e" title="Place global headers in extradata instead of every keyframe.">CODEC_FLAG_GLOBAL_HEADER</a>;

    }
    <a class="code" href="group__lavf__misc.html#gae2645941f2dc779c307eb6314fd39f10" title="Print detailed information about the input or output format, such as duration, bitrate, streams, container, programs, metadata, side data, codec and time base.">av_dump_format</a>(ofmt_ctx, 0, filename, 1);

    <span class="keywordflow">if</span> (!(ofmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#a20d80ac07e38ff5c268d15aaf2798b98" title="The output container format.">oformat</a>-&gt;<a class="code" href="structAVOutputFormat.html#aad55a00e728a020c1dcfaaf695320445" title="can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_RAWPICTURE, AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS, AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, AVFMT_ALLOW_FLUSH, AVFMT_TS_NONSTRICT">flags</a> &amp; <a name="a56"></a><a class="code" href="avformat_8h.html#a752cce390d480521919aa5d8be24ac0b" title="Demuxer will use avio_open, no opened file should be provided by the caller.">AVFMT_NOFILE</a>)) {
        ret = <a name="a57"></a><a class="code" href="avio_8h.html#a371a670112abc5f3e15bc570da076301" title="Create and initialize a AVIOContext for accessing the resource indicated by url.">avio_open</a>(&amp;ofmt_ctx-&gt;<a name="a58"></a><a class="code" href="structAVFormatContext.html#a1e7324262b6b78522e52064daaa7bc87" title="I/O context.">pb</a>, filename, <a name="a59"></a><a class="code" href="avio_8h.html#a5c9308f296545a8f3b7687d277a6dabc" title="write-only">AVIO_FLAG_WRITE</a>);
        <span class="keywordflow">if</span> (ret &lt; 0) {
            <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a class="code" href="group__lavu__log__constants.html#gaffe151ff4cd8a24b2e77ac8d9616c85c" title="Something went wrong and cannot losslessly be recovered.">AV_LOG_ERROR</a>, <span class="stringliteral">&quot;Could not open output file &#39;%s&#39;&quot;</span>, filename);
            <span class="keywordflow">return</span> ret;
        }
    }

    <span class="comment">/* init muxer, write output file header */</span>
    ret = <a name="a60"></a><a class="code" href="group__lavf__encoding.html#ga78d4e734fecb1d2385536e6dd5b7b9f5" title="Allocate the stream private data and write the stream header to an output media file.">avformat_write_header</a>(ofmt_ctx, NULL);
    <span class="keywordflow">if</span> (ret &lt; 0) {
        <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a class="code" href="group__lavu__log__constants.html#gaffe151ff4cd8a24b2e77ac8d9616c85c" title="Something went wrong and cannot losslessly be recovered.">AV_LOG_ERROR</a>, <span class="stringliteral">&quot;Error occurred when opening output file\n&quot;</span>);
        <span class="keywordflow">return</span> ret;
    }

    <span class="keywordflow">return</span> 0;
}

<span class="keyword">static</span> <span class="keywordtype">int</span> <a name="a61"></a><a class="code" href="transcoding_8c.html#a54ad76df48ef886861a2f12bc7a9e7e4">init_filter</a>(<a class="code" href="structFilteringContext.html">FilteringContext</a>* fctx, <a class="code" href="structAVCodecContext.html" title="main external API structure.">AVCodecContext</a> *dec_ctx,
        <a class="code" href="structAVCodecContext.html" title="main external API structure.">AVCodecContext</a> *enc_ctx, <span class="keyword">const</span> <span class="keywordtype">char</span> *filter_spec)
{
    <span class="keywordtype">char</span> args[512];
    <span class="keywordtype">int</span> ret = 0;
    <a name="_a62"></a><a class="code" href="structAVFilter.html" title="Filter definition.">AVFilter</a> *buffersrc = NULL;
    <a class="code" href="structAVFilter.html" title="Filter definition.">AVFilter</a> *buffersink = NULL;
    <a class="code" href="structAVFilterContext.html" title="An instance of a filter.">AVFilterContext</a> *<a name="a63"></a><a class="code" href="filtering__audio_8c.html#a8dce1714a267758c056947f105f66a82">buffersrc_ctx</a> = NULL;
    <a class="code" href="structAVFilterContext.html" title="An instance of a filter.">AVFilterContext</a> *<a name="a64"></a><a class="code" href="filtering__audio_8c.html#a5a75197a9aaa609af34cfc0d199acbda">buffersink_ctx</a> = NULL;
    <a name="_a65"></a><a class="code" href="structAVFilterInOut.html" title="A linked-list of the inputs/outputs of the filter chain.">AVFilterInOut</a> *outputs = <a name="a66"></a><a class="code" href="group__lavfi.html#ga6e1c2931e15eb4283c59c6ccc8b83919" title="Allocate a single AVFilterInOut entry.">avfilter_inout_alloc</a>();
    <a class="code" href="structAVFilterInOut.html" title="A linked-list of the inputs/outputs of the filter chain.">AVFilterInOut</a> *inputs  = <a class="code" href="group__lavfi.html#ga6e1c2931e15eb4283c59c6ccc8b83919" title="Allocate a single AVFilterInOut entry.">avfilter_inout_alloc</a>();
    <a class="code" href="structAVFilterGraph.html">AVFilterGraph</a> *<a name="a67"></a><a class="code" href="filtering__audio_8c.html#a36c24d3c84d08e2f5a69e7368c211412">filter_graph</a> = <a name="a68"></a><a class="code" href="group__lavfi.html#ga6c778454b86f845805ffd814b4ce51d4" title="Allocate a filter graph.">avfilter_graph_alloc</a>();

    <span class="keywordflow">if</span> (!outputs || !inputs || !filter_graph) {
        ret = <a name="a69"></a><a class="code" href="group__lavu__error.html#gae4bb6f165973d09584e0ec0f335f69ca">AVERROR</a>(ENOMEM);
        <span class="keywordflow">goto</span> end;
    }

    <span class="keywordflow">if</span> (dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#a3f99ca3115c44e6d7772c9384faf15e6">codec_type</a> == <a class="code" href="group__lavu__misc.html#gga9a84bba4713dfced21a1a56163be1f48ac1a46f59be5c6c2d3412ab172d6b8cf5">AVMEDIA_TYPE_VIDEO</a>) {
        buffersrc = <a name="a70"></a><a class="code" href="group__lavfi.html#gadd774ec49e50edf00158248e1bfe4ae6" title="Get a filter definition matching the given name.">avfilter_get_by_name</a>(<span class="stringliteral">&quot;buffer&quot;</span>);
        buffersink = <a class="code" href="group__lavfi.html#gadd774ec49e50edf00158248e1bfe4ae6" title="Get a filter definition matching the given name.">avfilter_get_by_name</a>(<span class="stringliteral">&quot;buffersink&quot;</span>);
        <span class="keywordflow">if</span> (!buffersrc || !buffersink) {
            <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a class="code" href="group__lavu__log__constants.html#gaffe151ff4cd8a24b2e77ac8d9616c85c" title="Something went wrong and cannot losslessly be recovered.">AV_LOG_ERROR</a>, <span class="stringliteral">&quot;filtering source or sink element not found\n&quot;</span>);
            ret = <a class="code" href="group__lavu__error.html#ga4ebaa288c7684a26a591c501208910e4" title="Unknown error, typically from an external library.">AVERROR_UNKNOWN</a>;
            <span class="keywordflow">goto</span> end;
        }

        snprintf(args, <span class="keyword">sizeof</span>(args),
                <span class="stringliteral">&quot;video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:pixel_aspect=%d/%d&quot;</span>,
                dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#a0d8f46461754e8abea0847dcbc41b956" title="picture width / height.">width</a>, dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#a0449afd803eb107bd4dbc8b5ea22e363">height</a>, dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#a0425c77b3d06d71e5db88b1d7e1b37f2" title="Pixel format, see AV_PIX_FMT_xxx.">pix_fmt</a>,
                dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#ab7bfeb9fa5840aac090e2b0bd0ef7589" title="This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...">time_base</a>.<a name="a71"></a><a class="code" href="structAVRational.html#ae9a98c10a301c5e937095105b6f0fdb9" title="numerator">num</a>, dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#ab7bfeb9fa5840aac090e2b0bd0ef7589" title="This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...">time_base</a>.<a name="a72"></a><a class="code" href="structAVRational.html#aee46bdac67d965ac0a4204e753f910c3" title="denominator">den</a>,
                dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#a5252d34fbce300228d4dbda19a8c3293" title="sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...">sample_aspect_ratio</a>.<a class="code" href="structAVRational.html#ae9a98c10a301c5e937095105b6f0fdb9" title="numerator">num</a>,
                dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#a5252d34fbce300228d4dbda19a8c3293" title="sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...">sample_aspect_ratio</a>.<a class="code" href="structAVRational.html#aee46bdac67d965ac0a4204e753f910c3" title="denominator">den</a>);

        ret = <a name="a73"></a><a class="code" href="group__lavfi.html#gac0788a9ab6966dba9318b5d5c7524fea" title="Create and add a filter instance into an existing graph.">avfilter_graph_create_filter</a>(&amp;buffersrc_ctx, buffersrc, <span class="stringliteral">&quot;in&quot;</span>,
                args, NULL, filter_graph);
        <span class="keywordflow">if</span> (ret &lt; 0) {
            <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a class="code" href="group__lavu__log__constants.html#gaffe151ff4cd8a24b2e77ac8d9616c85c" title="Something went wrong and cannot losslessly be recovered.">AV_LOG_ERROR</a>, <span class="stringliteral">&quot;Cannot create buffer source\n&quot;</span>);
            <span class="keywordflow">goto</span> end;
        }

        ret = <a class="code" href="group__lavfi.html#gac0788a9ab6966dba9318b5d5c7524fea" title="Create and add a filter instance into an existing graph.">avfilter_graph_create_filter</a>(&amp;buffersink_ctx, buffersink, <span class="stringliteral">&quot;out&quot;</span>,
                NULL, NULL, filter_graph);
        <span class="keywordflow">if</span> (ret &lt; 0) {
            <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a class="code" href="group__lavu__log__constants.html#gaffe151ff4cd8a24b2e77ac8d9616c85c" title="Something went wrong and cannot losslessly be recovered.">AV_LOG_ERROR</a>, <span class="stringliteral">&quot;Cannot create buffer sink\n&quot;</span>);
            <span class="keywordflow">goto</span> end;
        }

        ret = <a name="a74"></a><a class="code" href="group__opt__set__funcs.html#ga6c32155fd8a96bed2f8cf5ebc030dadf">av_opt_set_bin</a>(buffersink_ctx, <span class="stringliteral">&quot;pix_fmts&quot;</span>,
                (uint8_t*)&amp;enc_ctx-&gt;<a class="code" href="structAVCodecContext.html#a0425c77b3d06d71e5db88b1d7e1b37f2" title="Pixel format, see AV_PIX_FMT_xxx.">pix_fmt</a>, <span class="keyword">sizeof</span>(enc_ctx-&gt;<a class="code" href="structAVCodecContext.html#a0425c77b3d06d71e5db88b1d7e1b37f2" title="Pixel format, see AV_PIX_FMT_xxx.">pix_fmt</a>),
                <a name="a75"></a><a class="code" href="group__avoptions.html#ga25801ba4fc9b5313eb33ec84e082dd72" title="Search in possible children of the given object first.">AV_OPT_SEARCH_CHILDREN</a>);
        <span class="keywordflow">if</span> (ret &lt; 0) {
            <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a class="code" href="group__lavu__log__constants.html#gaffe151ff4cd8a24b2e77ac8d9616c85c" title="Something went wrong and cannot losslessly be recovered.">AV_LOG_ERROR</a>, <span class="stringliteral">&quot;Cannot set output pixel format\n&quot;</span>);
            <span class="keywordflow">goto</span> end;
        }
    } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#a3f99ca3115c44e6d7772c9384faf15e6">codec_type</a> == <a class="code" href="group__lavu__misc.html#gga9a84bba4713dfced21a1a56163be1f48a7b4e33b8f30ac94d34ce8d9f7c33927a">AVMEDIA_TYPE_AUDIO</a>) {
        buffersrc = <a class="code" href="group__lavfi.html#gadd774ec49e50edf00158248e1bfe4ae6" title="Get a filter definition matching the given name.">avfilter_get_by_name</a>(<span class="stringliteral">&quot;abuffer&quot;</span>);
        buffersink = <a class="code" href="group__lavfi.html#gadd774ec49e50edf00158248e1bfe4ae6" title="Get a filter definition matching the given name.">avfilter_get_by_name</a>(<span class="stringliteral">&quot;abuffersink&quot;</span>);
        <span class="keywordflow">if</span> (!buffersrc || !buffersink) {
            <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a class="code" href="group__lavu__log__constants.html#gaffe151ff4cd8a24b2e77ac8d9616c85c" title="Something went wrong and cannot losslessly be recovered.">AV_LOG_ERROR</a>, <span class="stringliteral">&quot;filtering source or sink element not found\n&quot;</span>);
            ret = <a class="code" href="group__lavu__error.html#ga4ebaa288c7684a26a591c501208910e4" title="Unknown error, typically from an external library.">AVERROR_UNKNOWN</a>;
            <span class="keywordflow">goto</span> end;
        }

        <span class="keywordflow">if</span> (!dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#aeb08c575a79eb84fc4155dda88f46c06" title="Audio channel layout.">channel_layout</a>)
            dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#aeb08c575a79eb84fc4155dda88f46c06" title="Audio channel layout.">channel_layout</a> =
                <a name="a76"></a><a class="code" href="group__channel__mask__c.html#gacb84f3e93a583e1f84a5283162a606a2" title="Return default channel layout for a given number of channels.">av_get_default_channel_layout</a>(dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#ac1e6c2cd1269caa7570575725c682a49" title="number of audio channels">channels</a>);
        snprintf(args, <span class="keyword">sizeof</span>(args),
                <span class="stringliteral">&quot;time_base=%d/%d:sample_rate=%d:sample_fmt=%s:channel_layout=0x%&quot;</span>PRIx64,
                dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#ab7bfeb9fa5840aac090e2b0bd0ef7589" title="This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...">time_base</a>.<a class="code" href="structAVRational.html#ae9a98c10a301c5e937095105b6f0fdb9" title="numerator">num</a>, dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#ab7bfeb9fa5840aac090e2b0bd0ef7589" title="This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...">time_base</a>.<a class="code" href="structAVRational.html#aee46bdac67d965ac0a4204e753f910c3" title="denominator">den</a>, dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#a8ff0b000c463361e234af48d03aadfc0" title="samples per second">sample_rate</a>,
                <a name="a77"></a><a class="code" href="group__lavu__sampfmts.html#ga31b9d149b2de9821a65f4f5612970838" title="Return the name of sample_fmt, or NULL if sample_fmt is not recognized.">av_get_sample_fmt_name</a>(dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#a1bdba69ea111e2a9d03fdaa7a46a4c45" title="audio sample format">sample_fmt</a>),
                dec_ctx-&gt;<a class="code" href="structAVCodecContext.html#aeb08c575a79eb84fc4155dda88f46c06" title="Audio channel layout.">channel_layout</a>);
        ret = <a class="code" href="group__lavfi.html#gac0788a9ab6966dba9318b5d5c7524fea" title="Create and add a filter instance into an existing graph.">avfilter_graph_create_filter</a>(&amp;buffersrc_ctx, buffersrc, <span class="stringliteral">&quot;in&quot;</span>,
                args, NULL, filter_graph);
        <span class="keywordflow">if</span> (ret &lt; 0) {
            <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a class="code" href="group__lavu__log__constants.html#gaffe151ff4cd8a24b2e77ac8d9616c85c" title="Something went wrong and cannot losslessly be recovered.">AV_LOG_ERROR</a>, <span class="stringliteral">&quot;Cannot create audio buffer source\n&quot;</span>);
            <span class="keywordflow">goto</span> end;
        }

        ret = <a class="code" href="group__lavfi.html#gac0788a9ab6966dba9318b5d5c7524fea" title="Create and add a filter instance into an existing graph.">avfilter_graph_create_filter</a>(&amp;buffersink_ctx, buffersink, <span class="stringliteral">&quot;out&quot;</span>,
                NULL, NULL, filter_graph);
        <span class="keywordflow">if</span> (ret &lt; 0) {
            <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a class="code" href="group__lavu__log__constants.html#gaffe151ff4cd8a24b2e77ac8d9616c85c" title="Something went wrong and cannot losslessly be recovered.">AV_LOG_ERROR</a>, <span class="stringliteral">&quot;Cannot create audio buffer sink\n&quot;</span>);
            <span class="keywordflow">goto</span> end;
        }

        ret = <a class="code" href="group__opt__set__funcs.html#ga6c32155fd8a96bed2f8cf5ebc030dadf">av_opt_set_bin</a>(buffersink_ctx, <span class="stringliteral">&quot;sample_fmts&quot;</span>,
                (uint8_t*)&amp;enc_ctx-&gt;<a class="code" href="structAVCodecContext.html#a1bdba69ea111e2a9d03fdaa7a46a4c45" title="audio sample format">sample_fmt</a>, <span class="keyword">sizeof</span>(enc_ctx-&gt;<a class="code" href="structAVCodecContext.html#a1bdba69ea111e2a9d03fdaa7a46a4c45" title="audio sample format">sample_fmt</a>),
                <a class="code" href="group__avoptions.html#ga25801ba4fc9b5313eb33ec84e082dd72" title="Search in possible children of the given object first.">AV_OPT_SEARCH_CHILDREN</a>);
        <span class="keywordflow">if</span> (ret &lt; 0) {
            <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a class="code" href="group__lavu__log__constants.html#gaffe151ff4cd8a24b2e77ac8d9616c85c" title="Something went wrong and cannot losslessly be recovered.">AV_LOG_ERROR</a>, <span class="stringliteral">&quot;Cannot set output sample format\n&quot;</span>);
            <span class="keywordflow">goto</span> end;
        }

        ret = <a class="code" href="group__opt__set__funcs.html#ga6c32155fd8a96bed2f8cf5ebc030dadf">av_opt_set_bin</a>(buffersink_ctx, <span class="stringliteral">&quot;channel_layouts&quot;</span>,
                (uint8_t*)&amp;enc_ctx-&gt;<a class="code" href="structAVCodecContext.html#aeb08c575a79eb84fc4155dda88f46c06" title="Audio channel layout.">channel_layout</a>,
                <span class="keyword">sizeof</span>(enc_ctx-&gt;<a class="code" href="structAVCodecContext.html#aeb08c575a79eb84fc4155dda88f46c06" title="Audio channel layout.">channel_layout</a>), <a class="code" href="group__avoptions.html#ga25801ba4fc9b5313eb33ec84e082dd72" title="Search in possible children of the given object first.">AV_OPT_SEARCH_CHILDREN</a>);
        <span class="keywordflow">if</span> (ret &lt; 0) {
            <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a class="code" href="group__lavu__log__constants.html#gaffe151ff4cd8a24b2e77ac8d9616c85c" title="Something went wrong and cannot losslessly be recovered.">AV_LOG_ERROR</a>, <span class="stringliteral">&quot;Cannot set output channel layout\n&quot;</span>);
            <span class="keywordflow">goto</span> end;
        }

        ret = <a class="code" href="group__opt__set__funcs.html#ga6c32155fd8a96bed2f8cf5ebc030dadf">av_opt_set_bin</a>(buffersink_ctx, <span class="stringliteral">&quot;sample_rates&quot;</span>,
                (uint8_t*)&amp;enc_ctx-&gt;<a class="code" href="structAVCodecContext.html#a8ff0b000c463361e234af48d03aadfc0" title="samples per second">sample_rate</a>, <span class="keyword">sizeof</span>(enc_ctx-&gt;<a class="code" href="structAVCodecContext.html#a8ff0b000c463361e234af48d03aadfc0" title="samples per second">sample_rate</a>),
                <a class="code" href="group__avoptions.html#ga25801ba4fc9b5313eb33ec84e082dd72" title="Search in possible children of the given object first.">AV_OPT_SEARCH_CHILDREN</a>);
        <span class="keywordflow">if</span> (ret &lt; 0) {
            <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a class="code" href="group__lavu__log__constants.html#gaffe151ff4cd8a24b2e77ac8d9616c85c" title="Something went wrong and cannot losslessly be recovered.">AV_LOG_ERROR</a>, <span class="stringliteral">&quot;Cannot set output sample rate\n&quot;</span>);
            <span class="keywordflow">goto</span> end;
        }
    } <span class="keywordflow">else</span> {
        ret = <a class="code" href="group__lavu__error.html#ga4ebaa288c7684a26a591c501208910e4" title="Unknown error, typically from an external library.">AVERROR_UNKNOWN</a>;
        <span class="keywordflow">goto</span> end;
    }

    <span class="comment">/* Endpoints for the filter graph. */</span>
    outputs-&gt;<a name="a78"></a><a class="code" href="structAVFilterInOut.html#a88afecac258f51aab7e9a9db9e7a4d58" title="unique name for this input/output in the list">name</a>       = <a name="a79"></a><a class="code" href="group__lavu__mem.html#ga7c352f4cff02184f005323691375fea9" title="Duplicate the string s.">av_strdup</a>(<span class="stringliteral">&quot;in&quot;</span>);
    outputs-&gt;<a name="a80"></a><a class="code" href="structAVFilterInOut.html#a3227857d0b955b639f4950d13e4e6f40" title="filter context associated to this input/output">filter_ctx</a> = <a class="code" href="filtering__audio_8c.html#a8dce1714a267758c056947f105f66a82">buffersrc_ctx</a>;
    outputs-&gt;<a name="a81"></a><a class="code" href="structAVFilterInOut.html#a386ff90d40aa22f5612dd5eca734ed48" title="index of the filt_ctx pad to use for linking">pad_idx</a>    = 0;
    outputs-&gt;<a name="a82"></a><a class="code" href="structAVFilterInOut.html#af8c8cf9ffb650974d19e791f5bb7cf33" title="next input/input in the list, NULL if this is the last">next</a>       = NULL;

    inputs-&gt;<a class="code" href="structAVFilterInOut.html#a88afecac258f51aab7e9a9db9e7a4d58" title="unique name for this input/output in the list">name</a>       = <a class="code" href="group__lavu__mem.html#ga7c352f4cff02184f005323691375fea9" title="Duplicate the string s.">av_strdup</a>(<span class="stringliteral">&quot;out&quot;</span>);
    inputs-&gt;<a class="code" href="structAVFilterInOut.html#a3227857d0b955b639f4950d13e4e6f40" title="filter context associated to this input/output">filter_ctx</a> = <a class="code" href="filtering__audio_8c.html#a5a75197a9aaa609af34cfc0d199acbda">buffersink_ctx</a>;
    inputs-&gt;<a class="code" href="structAVFilterInOut.html#a386ff90d40aa22f5612dd5eca734ed48" title="index of the filt_ctx pad to use for linking">pad_idx</a>    = 0;
    inputs-&gt;<a class="code" href="structAVFilterInOut.html#af8c8cf9ffb650974d19e791f5bb7cf33" title="next input/input in the list, NULL if this is the last">next</a>       = NULL;

    <span class="keywordflow">if</span> (!outputs-&gt;<a class="code" href="structAVFilterInOut.html#a88afecac258f51aab7e9a9db9e7a4d58" title="unique name for this input/output in the list">name</a> || !inputs-&gt;<a class="code" href="structAVFilterInOut.html#a88afecac258f51aab7e9a9db9e7a4d58" title="unique name for this input/output in the list">name</a>) {
        ret = <a class="code" href="group__lavu__error.html#gae4bb6f165973d09584e0ec0f335f69ca">AVERROR</a>(ENOMEM);
        <span class="keywordflow">goto</span> end;
    }

    <span class="keywordflow">if</span> ((ret = <a name="a83"></a><a class="code" href="group__lavfi.html#ga34f4ff420bd58da6747a3ff1fbedd001" title="Add a graph described by a string to a graph.">avfilter_graph_parse_ptr</a>(filter_graph, filter_spec,
                    &amp;inputs, &amp;outputs, NULL)) &lt; 0)
        <span class="keywordflow">goto</span> end;

    <span class="keywordflow">if</span> ((ret = <a name="a84"></a><a class="code" href="group__lavfi.html#ga1896c46b7bc6ff1bdb1a4815faa9ad07" title="Check validity and configure all the links and formats in the graph.">avfilter_graph_config</a>(filter_graph, NULL)) &lt; 0)
        <span class="keywordflow">goto</span> end;

    <span class="comment">/* Fill FilteringContext */</span>
    fctx-&gt;<a class="code" href="structFilteringContext.html#a25c500d3728df3a9f904e6d86cf55f11">buffersrc_ctx</a> = <a class="code" href="filtering__audio_8c.html#a8dce1714a267758c056947f105f66a82">buffersrc_ctx</a>;
    fctx-&gt;<a class="code" href="structFilteringContext.html#a4476c9e6fb492172c909ae4a47c47233">buffersink_ctx</a> = <a class="code" href="filtering__audio_8c.html#a5a75197a9aaa609af34cfc0d199acbda">buffersink_ctx</a>;
    fctx-&gt;<a class="code" href="structFilteringContext.html#aaf35e44d4e6100095b1db444e2d316cd">filter_graph</a> = <a class="code" href="filtering__audio_8c.html#a36c24d3c84d08e2f5a69e7368c211412">filter_graph</a>;

end:
    <a name="a85"></a><a class="code" href="group__lavfi.html#ga294500a9856260eb1552354fd9d9a6c4" title="Free the supplied list of AVFilterInOut and set *inout to NULL.">avfilter_inout_free</a>(&amp;inputs);
    <a class="code" href="group__lavfi.html#ga294500a9856260eb1552354fd9d9a6c4" title="Free the supplied list of AVFilterInOut and set *inout to NULL.">avfilter_inout_free</a>(&amp;outputs);

    <span class="keywordflow">return</span> ret;
}

<span class="keyword">static</span> <span class="keywordtype">int</span> <a name="a86"></a><a class="code" href="filtering__audio_8c.html#ac25a104c80c6a7d21fb06a438a6965ba">init_filters</a>(<span class="keywordtype">void</span>)
{
    <span class="keyword">const</span> <span class="keywordtype">char</span> *filter_spec;
    <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i;
    <span class="keywordtype">int</span> ret;
    filter_ctx = <a name="a87"></a><a class="code" href="group__lavu__mem.html#gab62b093b46dce5fe4e3e1d58bdb255da">av_malloc_array</a>(ifmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#a0b748d924898b08b89ff4974afd17285" title="Number of elements in AVFormatContext.streams.">nb_streams</a>, <span class="keyword">sizeof</span>(*filter_ctx));
    <span class="keywordflow">if</span> (!filter_ctx)
        <span class="keywordflow">return</span> <a class="code" href="group__lavu__error.html#gae4bb6f165973d09584e0ec0f335f69ca">AVERROR</a>(ENOMEM);

    <span class="keywordflow">for</span> (i = 0; i &lt; ifmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#a0b748d924898b08b89ff4974afd17285" title="Number of elements in AVFormatContext.streams.">nb_streams</a>; i++) {
        filter_ctx[i].<a class="code" href="structFilteringContext.html#a25c500d3728df3a9f904e6d86cf55f11">buffersrc_ctx</a>  = NULL;
        filter_ctx[i].<a class="code" href="structFilteringContext.html#a4476c9e6fb492172c909ae4a47c47233">buffersink_ctx</a> = NULL;
        filter_ctx[i].<a class="code" href="structFilteringContext.html#aaf35e44d4e6100095b1db444e2d316cd">filter_graph</a>   = NULL;
        <span class="keywordflow">if</span> (!(ifmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[i]-&gt;<a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>-&gt;<a class="code" href="structAVCodecContext.html#a3f99ca3115c44e6d7772c9384faf15e6">codec_type</a> == <a class="code" href="group__lavu__misc.html#gga9a84bba4713dfced21a1a56163be1f48a7b4e33b8f30ac94d34ce8d9f7c33927a">AVMEDIA_TYPE_AUDIO</a>
                || ifmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[i]-&gt;<a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>-&gt;<a class="code" href="structAVCodecContext.html#a3f99ca3115c44e6d7772c9384faf15e6">codec_type</a> == <a class="code" href="group__lavu__misc.html#gga9a84bba4713dfced21a1a56163be1f48ac1a46f59be5c6c2d3412ab172d6b8cf5">AVMEDIA_TYPE_VIDEO</a>))
            <span class="keywordflow">continue</span>;


        <span class="keywordflow">if</span> (ifmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[i]-&gt;<a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>-&gt;<a class="code" href="structAVCodecContext.html#a3f99ca3115c44e6d7772c9384faf15e6">codec_type</a> == <a class="code" href="group__lavu__misc.html#gga9a84bba4713dfced21a1a56163be1f48ac1a46f59be5c6c2d3412ab172d6b8cf5">AVMEDIA_TYPE_VIDEO</a>)
            filter_spec = <span class="stringliteral">&quot;null&quot;</span>; <span class="comment">/* passthrough (dummy) filter for video */</span>
        <span class="keywordflow">else</span>
            filter_spec = <span class="stringliteral">&quot;anull&quot;</span>; <span class="comment">/* passthrough (dummy) filter for audio */</span>
        ret = <a class="code" href="transcoding_8c.html#a54ad76df48ef886861a2f12bc7a9e7e4">init_filter</a>(&amp;filter_ctx[i], ifmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[i]-&gt;<a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>,
                ofmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[i]-&gt;<a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>, filter_spec);
        <span class="keywordflow">if</span> (ret)
            <span class="keywordflow">return</span> ret;
    }
    <span class="keywordflow">return</span> 0;
}

<span class="keyword">static</span> <span class="keywordtype">int</span> <a name="a88"></a><a class="code" href="transcoding_8c.html#afb371e273a9d2e9cc0539a6453913533">encode_write_frame</a>(<a name="_a89"></a><a class="code" href="structAVFrame.html" title="This structure describes decoded (raw) audio or video data.">AVFrame</a> *filt_frame, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> stream_index, <span class="keywordtype">int</span> *got_frame) {
    <span class="keywordtype">int</span> ret;
    <span class="keywordtype">int</span> got_frame_local;
    <a name="_a90"></a><a class="code" href="structAVPacket.html" title="This structure stores compressed data.">AVPacket</a> enc_pkt;
    int (*enc_func)(<a class="code" href="structAVCodecContext.html" title="main external API structure.">AVCodecContext</a> *, <a class="code" href="structAVPacket.html" title="This structure stores compressed data.">AVPacket</a> *, <span class="keyword">const</span> <a class="code" href="structAVFrame.html" title="This structure describes decoded (raw) audio or video data.">AVFrame</a> *, <span class="keywordtype">int</span> *) =
        (ifmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[stream_index]-&gt;<a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>-&gt;<a class="code" href="structAVCodecContext.html#a3f99ca3115c44e6d7772c9384faf15e6">codec_type</a> ==
         <a class="code" href="group__lavu__misc.html#gga9a84bba4713dfced21a1a56163be1f48ac1a46f59be5c6c2d3412ab172d6b8cf5">AVMEDIA_TYPE_VIDEO</a>) ? <a name="a91"></a><a class="code" href="group__lavc__encoding.html#gaa2dc9e9ea2567ebb2801a08153c7306b" title="Encode a frame of video.">avcodec_encode_video2</a> : <a name="a92"></a><a class="code" href="group__lavc__encoding.html#ga93a49fbd0973b216dcb8a8c5dffe1d82" title="Encode a frame of audio.">avcodec_encode_audio2</a>;

    <span class="keywordflow">if</span> (!got_frame)
        got_frame = &amp;got_frame_local;

    <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a name="a93"></a><a class="code" href="group__lavu__log__constants.html#gad172eacfed8653e454c6fdcbe53baab3" title="Standard information.">AV_LOG_INFO</a>, <span class="stringliteral">&quot;Encoding frame\n&quot;</span>);
    <span class="comment">/* encode filtered frame */</span>
    enc_pkt.<a name="a94"></a><a class="code" href="structAVPacket.html#aaf4fe58dfcc7c232c1f2268b539d8367">data</a> = NULL;
    enc_pkt.<a name="a95"></a><a class="code" href="structAVPacket.html#a4d1ea19f63eb107111fd650ca514d1f4">size</a> = 0;
    <a name="a96"></a><a class="code" href="group__lavc__packet.html#gac9cb9756175b96e7441575803757fb73" title="Initialize optional fields of a packet with default values.">av_init_packet</a>(&amp;enc_pkt);
    ret = enc_func(ofmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[stream_index]-&gt;<a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>, &amp;enc_pkt,
            filt_frame, got_frame);
    <a name="a97"></a><a class="code" href="group__lavu__frame.html#ga979d73f3228814aee56aeca0636e37cc" title="Free the frame and any dynamically allocated objects in it, e.g.">av_frame_free</a>(&amp;filt_frame);
    <span class="keywordflow">if</span> (ret &lt; 0)
        <span class="keywordflow">return</span> ret;
    <span class="keywordflow">if</span> (!(*got_frame))
        <span class="keywordflow">return</span> 0;

    <span class="comment">/* prepare packet for muxing */</span>
    enc_pkt.<a name="a98"></a><a class="code" href="structAVPacket.html#a0d1cb9b5a32b00fb6edc81ea3aae2a49">stream_index</a> = stream_index;
    <a name="a99"></a><a class="code" href="group__lavc__packet.html#gae5c86e4d93f6e7aa62ef2c60763ea67e" title="Convert valid timing fields (timestamps / durations) in a packet from one timebase to another...">av_packet_rescale_ts</a>(&amp;enc_pkt,
                         ofmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[stream_index]-&gt;<a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>-&gt;<a class="code" href="structAVCodecContext.html#ab7bfeb9fa5840aac090e2b0bd0ef7589" title="This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...">time_base</a>,
                         ofmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[stream_index]-&gt;<a name="a100"></a><a class="code" href="structAVStream.html#a9db755451f14e2bf590d4b85d82b32e6" title="This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...">time_base</a>);

    <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a name="a101"></a><a class="code" href="group__lavu__log__constants.html#ga5b7221c3afd06848486776bd834a58a5" title="Stuff which is only useful for libav* developers.">AV_LOG_DEBUG</a>, <span class="stringliteral">&quot;Muxing frame\n&quot;</span>);
    <span class="comment">/* mux encoded frame */</span>
    ret = <a name="a102"></a><a class="code" href="group__lavf__encoding.html#ga37352ed2c63493c38219d935e71db6c1" title="Write a packet to an output media file ensuring correct interleaving.">av_interleaved_write_frame</a>(ofmt_ctx, &amp;enc_pkt);
    <span class="keywordflow">return</span> ret;
}

<span class="keyword">static</span> <span class="keywordtype">int</span> <a name="a103"></a><a class="code" href="transcoding_8c.html#a255192428438daf73b9f8060c0815712">filter_encode_write_frame</a>(AVFrame *<a name="a104"></a><a class="code" href="demuxing__decoding_8c.html#ad7d33d579a8d4241a5e643e39287a209">frame</a>, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> stream_index)
{
    <span class="keywordtype">int</span> ret;
    AVFrame *filt_frame;

    <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a class="code" href="group__lavu__log__constants.html#gad172eacfed8653e454c6fdcbe53baab3" title="Standard information.">AV_LOG_INFO</a>, <span class="stringliteral">&quot;Pushing decoded frame to filters\n&quot;</span>);
    <span class="comment">/* push the decoded frame into the filtergraph */</span>
    ret = <a name="a105"></a><a class="code" href="group__lavfi__buffersrc.html#ga54133fc5421777515032c593bc00f191" title="Add a frame to the buffer source.">av_buffersrc_add_frame_flags</a>(filter_ctx[stream_index].buffersrc_ctx,
            frame, 0);
    <span class="keywordflow">if</span> (ret &lt; 0) {
        <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a class="code" href="group__lavu__log__constants.html#gaffe151ff4cd8a24b2e77ac8d9616c85c" title="Something went wrong and cannot losslessly be recovered.">AV_LOG_ERROR</a>, <span class="stringliteral">&quot;Error while feeding the filtergraph\n&quot;</span>);
        <span class="keywordflow">return</span> ret;
    }

    <span class="comment">/* pull filtered frames from the filtergraph */</span>
    <span class="keywordflow">while</span> (1) {
        filt_frame = <a name="a106"></a><a class="code" href="group__lavu__frame.html#gac700017c5270c79c1e1befdeeb008b2f" title="Allocate an AVFrame and set its fields to default values.">av_frame_alloc</a>();
        <span class="keywordflow">if</span> (!filt_frame) {
            ret = <a class="code" href="group__lavu__error.html#gae4bb6f165973d09584e0ec0f335f69ca">AVERROR</a>(ENOMEM);
            <span class="keywordflow">break</span>;
        }
        <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a class="code" href="group__lavu__log__constants.html#gad172eacfed8653e454c6fdcbe53baab3" title="Standard information.">AV_LOG_INFO</a>, <span class="stringliteral">&quot;Pulling filtered frame from filters\n&quot;</span>);
        ret = <a name="a107"></a><a class="code" href="group__lavfi__buffersink.html#ga653228f4cbca427c654d844a5fc59cfa" title="Get a frame with filtered data from sink and put it in frame.">av_buffersink_get_frame</a>(filter_ctx[stream_index].buffersink_ctx,
                filt_frame);
        <span class="keywordflow">if</span> (ret &lt; 0) {
            <span class="comment">/* if no more frames for output - returns AVERROR(EAGAIN)</span>
<span class="comment">             * if flushed and no more frames for output - returns AVERROR_EOF</span>
<span class="comment">             * rewrite retcode to 0 to show it as normal procedure completion</span>
<span class="comment">             */</span>
            <span class="keywordflow">if</span> (ret == <a class="code" href="group__lavu__error.html#gae4bb6f165973d09584e0ec0f335f69ca">AVERROR</a>(EAGAIN) || ret == <a name="a108"></a><a class="code" href="group__lavu__error.html#gab4faa0afdf35076914824200331defff" title="End of file.">AVERROR_EOF</a>)
                ret = 0;
            <a class="code" href="group__lavu__frame.html#ga979d73f3228814aee56aeca0636e37cc" title="Free the frame and any dynamically allocated objects in it, e.g.">av_frame_free</a>(&amp;filt_frame);
            <span class="keywordflow">break</span>;
        }

        filt_frame-&gt;<a name="a109"></a><a class="code" href="structAVFrame.html#af9920fc3fbfa347b8943ae461b50d18b" title="Picture type of the frame.">pict_type</a> = <a name="a110"></a><a class="code" href="group__lavu__picture.html#ggae6cbcab1f70d8e476757f1c1f5a0a78ea33183189d771e3325ccdd36fa980b6f6" title="Undefined.">AV_PICTURE_TYPE_NONE</a>;
        ret = <a class="code" href="transcoding_8c.html#afb371e273a9d2e9cc0539a6453913533">encode_write_frame</a>(filt_frame, stream_index, NULL);
        <span class="keywordflow">if</span> (ret &lt; 0)
            <span class="keywordflow">break</span>;
    }

    <span class="keywordflow">return</span> ret;
}

<span class="keyword">static</span> <span class="keywordtype">int</span> <a name="a111"></a><a class="code" href="transcoding_8c.html#ad55ba3d9c6ebe490eb8766a91b627d3e">flush_encoder</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> stream_index)
{
    <span class="keywordtype">int</span> ret;
    <span class="keywordtype">int</span> got_frame;

    <span class="keywordflow">if</span> (!(ofmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[stream_index]-&gt;<a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>-&gt;<a name="a112"></a><a class="code" href="structAVCodecContext.html#ab00398f08f8622c3e6c0f1a12eb99808">codec</a>-&gt;<a name="a113"></a><a class="code" href="structAVCodec.html#af51f7ff3dac8b730f46b9713e49a2518" title="Codec capabilities.">capabilities</a> &amp;
                <a name="a114"></a><a class="code" href="group__lavc__core.html#gad81abca6e6ea7e0ac25f328e7425698f" title="Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...">CODEC_CAP_DELAY</a>))
        <span class="keywordflow">return</span> 0;

    <span class="keywordflow">while</span> (1) {
        <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a class="code" href="group__lavu__log__constants.html#gad172eacfed8653e454c6fdcbe53baab3" title="Standard information.">AV_LOG_INFO</a>, <span class="stringliteral">&quot;Flushing stream #%u encoder\n&quot;</span>, stream_index);
        ret = <a class="code" href="transcoding_8c.html#afb371e273a9d2e9cc0539a6453913533">encode_write_frame</a>(NULL, stream_index, &amp;got_frame);
        <span class="keywordflow">if</span> (ret &lt; 0)
            <span class="keywordflow">break</span>;
        <span class="keywordflow">if</span> (!got_frame)
            <span class="keywordflow">return</span> 0;
    }
    <span class="keywordflow">return</span> ret;
}

<span class="keywordtype">int</span> <a name="a115"></a><a class="code" href="avio__list__dir_8c.html#a0ddf1224851353fc92bfbff6f499fa97">main</a>(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)
{
    <span class="keywordtype">int</span> ret;
    AVPacket packet = { .data = NULL, .size = 0 };
    AVFrame *frame = NULL;
    <span class="keyword">enum</span> <a class="code" href="group__lavu__misc.html#ga9a84bba4713dfced21a1a56163be1f48">AVMediaType</a> type;
    <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> stream_index;
    <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i;
    <span class="keywordtype">int</span> got_frame;
    int (*dec_func)(<a class="code" href="structAVCodecContext.html" title="main external API structure.">AVCodecContext</a> *, AVFrame *, <span class="keywordtype">int</span> *, <span class="keyword">const</span> AVPacket *);

    <span class="keywordflow">if</span> (argc != 3) {
        <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a class="code" href="group__lavu__log__constants.html#gaffe151ff4cd8a24b2e77ac8d9616c85c" title="Something went wrong and cannot losslessly be recovered.">AV_LOG_ERROR</a>, <span class="stringliteral">&quot;Usage: %s &lt;input file&gt; &lt;output file&gt;\n&quot;</span>, argv[0]);
        <span class="keywordflow">return</span> 1;
    }

    <a name="a116"></a><a class="code" href="group__lavf__core.html#ga917265caec45ef5a0646356ed1a507e3" title="Initialize libavformat and register all the muxers, demuxers and protocols.">av_register_all</a>();
    <a name="a117"></a><a class="code" href="group__lavfi.html#ga2bf8f0a6e2599faf4bf97b04a5a25149" title="Initialize the filter system.">avfilter_register_all</a>();

    <span class="keywordflow">if</span> ((ret = <a class="code" href="filtering__audio_8c.html#abd04bf1a933d4d2698482f4949c61fed">open_input_file</a>(argv[1])) &lt; 0)
        <span class="keywordflow">goto</span> end;
    <span class="keywordflow">if</span> ((ret = <a class="code" href="transcode__aac_8c.html#a617f4760254c119fc7caa222f3fcbd21" title="Open an output file and the required encoder.">open_output_file</a>(argv[2])) &lt; 0)
        <span class="keywordflow">goto</span> end;
    <span class="keywordflow">if</span> ((ret = <a class="code" href="filtering__audio_8c.html#ac25a104c80c6a7d21fb06a438a6965ba">init_filters</a>()) &lt; 0)
        <span class="keywordflow">goto</span> end;

    <span class="comment">/* read all packets */</span>
    <span class="keywordflow">while</span> (1) {
        <span class="keywordflow">if</span> ((ret = <a name="a118"></a><a class="code" href="group__lavf__decoding.html#ga4fdb3084415a82e3810de6ee60e46a61" title="Return the next frame of a stream.">av_read_frame</a>(ifmt_ctx, &amp;packet)) &lt; 0)
            <span class="keywordflow">break</span>;
        stream_index = packet.<a class="code" href="structAVPacket.html#a0d1cb9b5a32b00fb6edc81ea3aae2a49">stream_index</a>;
        type = ifmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[packet.<a class="code" href="structAVPacket.html#a0d1cb9b5a32b00fb6edc81ea3aae2a49">stream_index</a>]-&gt;<a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>-&gt;<a class="code" href="structAVCodecContext.html#a3f99ca3115c44e6d7772c9384faf15e6">codec_type</a>;
        <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a class="code" href="group__lavu__log__constants.html#ga5b7221c3afd06848486776bd834a58a5" title="Stuff which is only useful for libav* developers.">AV_LOG_DEBUG</a>, <span class="stringliteral">&quot;Demuxer gave frame of stream_index %u\n&quot;</span>,
                stream_index);

        <span class="keywordflow">if</span> (filter_ctx[stream_index].filter_graph) {
            <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a class="code" href="group__lavu__log__constants.html#ga5b7221c3afd06848486776bd834a58a5" title="Stuff which is only useful for libav* developers.">AV_LOG_DEBUG</a>, <span class="stringliteral">&quot;Going to reencode&amp;filter the frame\n&quot;</span>);
            frame = <a class="code" href="group__lavu__frame.html#gac700017c5270c79c1e1befdeeb008b2f" title="Allocate an AVFrame and set its fields to default values.">av_frame_alloc</a>();
            <span class="keywordflow">if</span> (!frame) {
                ret = <a class="code" href="group__lavu__error.html#gae4bb6f165973d09584e0ec0f335f69ca">AVERROR</a>(ENOMEM);
                <span class="keywordflow">break</span>;
            }
            <a class="code" href="group__lavc__packet.html#gae5c86e4d93f6e7aa62ef2c60763ea67e" title="Convert valid timing fields (timestamps / durations) in a packet from one timebase to another...">av_packet_rescale_ts</a>(&amp;packet,
                                 ifmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[stream_index]-&gt;<a class="code" href="structAVStream.html#a9db755451f14e2bf590d4b85d82b32e6" title="This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...">time_base</a>,
                                 ifmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[stream_index]-&gt;<a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>-&gt;<a class="code" href="structAVCodecContext.html#ab7bfeb9fa5840aac090e2b0bd0ef7589" title="This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...">time_base</a>);
            dec_func = (type == <a class="code" href="group__lavu__misc.html#gga9a84bba4713dfced21a1a56163be1f48ac1a46f59be5c6c2d3412ab172d6b8cf5">AVMEDIA_TYPE_VIDEO</a>) ? <a name="a119"></a><a class="code" href="group__lavc__decoding.html#ga99ee61b6dcffb7817a275d39da58cc74" title="Decode the video frame of size avpkt-&gt;size from avpkt-&gt;data into picture.">avcodec_decode_video2</a> :
                <a name="a120"></a><a class="code" href="group__lavc__decoding.html#ga834bb1b062fbcc2de4cf7fb93f154a3e" title="Decode the audio frame of size avpkt-&gt;size from avpkt-&gt;data into frame.">avcodec_decode_audio4</a>;
            ret = dec_func(ifmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[stream_index]-&gt;<a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>, frame,
                    &amp;got_frame, &amp;packet);
            <span class="keywordflow">if</span> (ret &lt; 0) {
                <a class="code" href="group__lavu__frame.html#ga979d73f3228814aee56aeca0636e37cc" title="Free the frame and any dynamically allocated objects in it, e.g.">av_frame_free</a>(&amp;frame);
                <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a class="code" href="group__lavu__log__constants.html#gaffe151ff4cd8a24b2e77ac8d9616c85c" title="Something went wrong and cannot losslessly be recovered.">AV_LOG_ERROR</a>, <span class="stringliteral">&quot;Decoding failed\n&quot;</span>);
                <span class="keywordflow">break</span>;
            }

            <span class="keywordflow">if</span> (got_frame) {
                frame-&gt;<a name="a121"></a><a class="code" href="structAVFrame.html#a0452833e3ab6ddd7acbf82817a7818a4" title="Presentation timestamp in time_base units (time when frame should be shown to user).">pts</a> = <a name="a122"></a><a class="code" href="group__lavu__frame.html#gacb9d9082c10e625e51a68caceabd4458" title="Accessors for some AVFrame fields.">av_frame_get_best_effort_timestamp</a>(frame);
                ret = <a class="code" href="transcoding_8c.html#a255192428438daf73b9f8060c0815712">filter_encode_write_frame</a>(frame, stream_index);
                <a class="code" href="group__lavu__frame.html#ga979d73f3228814aee56aeca0636e37cc" title="Free the frame and any dynamically allocated objects in it, e.g.">av_frame_free</a>(&amp;frame);
                <span class="keywordflow">if</span> (ret &lt; 0)
                    <span class="keywordflow">goto</span> end;
            } <span class="keywordflow">else</span> {
                <a class="code" href="group__lavu__frame.html#ga979d73f3228814aee56aeca0636e37cc" title="Free the frame and any dynamically allocated objects in it, e.g.">av_frame_free</a>(&amp;frame);
            }
        } <span class="keywordflow">else</span> {
            <span class="comment">/* remux this frame without reencoding */</span>
            <a class="code" href="group__lavc__packet.html#gae5c86e4d93f6e7aa62ef2c60763ea67e" title="Convert valid timing fields (timestamps / durations) in a packet from one timebase to another...">av_packet_rescale_ts</a>(&amp;packet,
                                 ifmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[stream_index]-&gt;<a class="code" href="structAVStream.html#a9db755451f14e2bf590d4b85d82b32e6" title="This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...">time_base</a>,
                                 ofmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[stream_index]-&gt;<a class="code" href="structAVStream.html#a9db755451f14e2bf590d4b85d82b32e6" title="This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...">time_base</a>);

            ret = <a class="code" href="group__lavf__encoding.html#ga37352ed2c63493c38219d935e71db6c1" title="Write a packet to an output media file ensuring correct interleaving.">av_interleaved_write_frame</a>(ofmt_ctx, &amp;packet);
            <span class="keywordflow">if</span> (ret &lt; 0)
                <span class="keywordflow">goto</span> end;
        }
        <a name="a123"></a><a class="code" href="group__lavc__packet.html#gae65881462e78f98b268f34661d921ee0" title="Free a packet.">av_free_packet</a>(&amp;packet);
    }

    <span class="comment">/* flush filters and encoders */</span>
    <span class="keywordflow">for</span> (i = 0; i &lt; ifmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#a0b748d924898b08b89ff4974afd17285" title="Number of elements in AVFormatContext.streams.">nb_streams</a>; i++) {
        <span class="comment">/* flush filter */</span>
        <span class="keywordflow">if</span> (!filter_ctx[i].filter_graph)
            <span class="keywordflow">continue</span>;
        ret = <a class="code" href="transcoding_8c.html#a255192428438daf73b9f8060c0815712">filter_encode_write_frame</a>(NULL, i);
        <span class="keywordflow">if</span> (ret &lt; 0) {
            <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a class="code" href="group__lavu__log__constants.html#gaffe151ff4cd8a24b2e77ac8d9616c85c" title="Something went wrong and cannot losslessly be recovered.">AV_LOG_ERROR</a>, <span class="stringliteral">&quot;Flushing filter failed\n&quot;</span>);
            <span class="keywordflow">goto</span> end;
        }

        <span class="comment">/* flush encoder */</span>
        ret = <a class="code" href="transcoding_8c.html#ad55ba3d9c6ebe490eb8766a91b627d3e">flush_encoder</a>(i);
        <span class="keywordflow">if</span> (ret &lt; 0) {
            <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a class="code" href="group__lavu__log__constants.html#gaffe151ff4cd8a24b2e77ac8d9616c85c" title="Something went wrong and cannot losslessly be recovered.">AV_LOG_ERROR</a>, <span class="stringliteral">&quot;Flushing encoder failed\n&quot;</span>);
            <span class="keywordflow">goto</span> end;
        }
    }

    <a name="a124"></a><a class="code" href="group__lavf__encoding.html#ga7f14007e7dc8f481f054b21614dfec13" title="Write the stream trailer to an output media file and free the file private data.">av_write_trailer</a>(ofmt_ctx);
end:
    <a class="code" href="group__lavc__packet.html#gae65881462e78f98b268f34661d921ee0" title="Free a packet.">av_free_packet</a>(&amp;packet);
    <a class="code" href="group__lavu__frame.html#ga979d73f3228814aee56aeca0636e37cc" title="Free the frame and any dynamically allocated objects in it, e.g.">av_frame_free</a>(&amp;frame);
    <span class="keywordflow">for</span> (i = 0; i &lt; ifmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#a0b748d924898b08b89ff4974afd17285" title="Number of elements in AVFormatContext.streams.">nb_streams</a>; i++) {
        <a name="a125"></a><a class="code" href="group__lavc__core.html#gaf4daa92361efb3523ef5afeb0b54077f" title="Close a given AVCodecContext and free all the data associated with it (but not the AVCodecContext its...">avcodec_close</a>(ifmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[i]-&gt;<a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>);
        <span class="keywordflow">if</span> (ofmt_ctx &amp;&amp; ofmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#a0b748d924898b08b89ff4974afd17285" title="Number of elements in AVFormatContext.streams.">nb_streams</a> &gt; i &amp;&amp; ofmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[i] &amp;&amp; ofmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[i]-&gt;<a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>)
            <a class="code" href="group__lavc__core.html#gaf4daa92361efb3523ef5afeb0b54077f" title="Close a given AVCodecContext and free all the data associated with it (but not the AVCodecContext its...">avcodec_close</a>(ofmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[i]-&gt;<a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>);
        <span class="keywordflow">if</span> (filter_ctx &amp;&amp; filter_ctx[i].filter_graph)
            <a name="a126"></a><a class="code" href="group__lavfi.html#ga871684449dac05050df238a18d0d493b" title="Free a graph, destroy its links, and set *graph to NULL.">avfilter_graph_free</a>(&amp;filter_ctx[i].filter_graph);
    }
    <a name="a127"></a><a class="code" href="group__lavu__mem.html#ga0c9096f498624c525aa2315b8a20c411" title="Free a memory block which has been allocated with av_malloc(z)() or av_realloc().">av_free</a>(filter_ctx);
    <a name="a128"></a><a class="code" href="group__lavf__decoding.html#gae804b99aec044690162b8b9b110236a4" title="Close an opened input AVFormatContext.">avformat_close_input</a>(&amp;ifmt_ctx);
    <span class="keywordflow">if</span> (ofmt_ctx &amp;&amp; !(ofmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#a20d80ac07e38ff5c268d15aaf2798b98" title="The output container format.">oformat</a>-&gt;<a class="code" href="structAVOutputFormat.html#aad55a00e728a020c1dcfaaf695320445" title="can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_RAWPICTURE, AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS, AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, AVFMT_ALLOW_FLUSH, AVFMT_TS_NONSTRICT">flags</a> &amp; <a class="code" href="avformat_8h.html#a752cce390d480521919aa5d8be24ac0b" title="Demuxer will use avio_open, no opened file should be provided by the caller.">AVFMT_NOFILE</a>))
        <a name="a129"></a><a class="code" href="avio_8h.html#ae118a1f37f1e48617609ead9910aac15" title="Close the resource accessed by the AVIOContext *s, free it and set the pointer pointing to it to NULL...">avio_closep</a>(&amp;ofmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#a1e7324262b6b78522e52064daaa7bc87" title="I/O context.">pb</a>);
    <a name="a130"></a><a class="code" href="group__lavf__core.html#gac2990b13b68e831a408fce8e1d0d6445" title="Free an AVFormatContext and all its streams.">avformat_free_context</a>(ofmt_ctx);

    <span class="keywordflow">if</span> (ret &lt; 0)
        <a class="code" href="group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae" title="Send the specified message to the log if the level is less than or equal to the current av_log_level...">av_log</a>(NULL, <a class="code" href="group__lavu__log__constants.html#gaffe151ff4cd8a24b2e77ac8d9616c85c" title="Something went wrong and cannot losslessly be recovered.">AV_LOG_ERROR</a>, <span class="stringliteral">&quot;Error occurred: %s\n&quot;</span>, <a name="a131"></a><a class="code" href="group__lavu__error.html#gac4f6e109c242c81aeee21868d3f35e12" title="Convenience macro, the return value should be used only directly in function arguments but never stan...">av_err2str</a>(ret));

    <span class="keywordflow">return</span> ret ? 1 : 0;
}
</pre></div> </div><!-- contents -->
</div><!-- contents -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.6.1
</small></address>

</body>
</html>