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 / remuxing_8c_source.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: doc/examples/remuxing.c Source File</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 class="current"><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 id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">doc/examples/remuxing.c</div>  </div>
</div><!--header-->
<div class="contents">
<a href="remuxing_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * Copyright (c) 2013 Stefano Sabatini</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining a copy</span>
<a name="l00005"></a>00005 <span class="comment"> * of this software and associated documentation files (the &quot;Software&quot;), to deal</span>
<a name="l00006"></a>00006 <span class="comment"> * in the Software without restriction, including without limitation the rights</span>
<a name="l00007"></a>00007 <span class="comment"> * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell</span>
<a name="l00008"></a>00008 <span class="comment"> * copies of the Software, and to permit persons to whom the Software is</span>
<a name="l00009"></a>00009 <span class="comment"> * furnished to do so, subject to the following conditions:</span>
<a name="l00010"></a>00010 <span class="comment"> *</span>
<a name="l00011"></a>00011 <span class="comment"> * The above copyright notice and this permission notice shall be included in</span>
<a name="l00012"></a>00012 <span class="comment"> * all copies or substantial portions of the Software.</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR</span>
<a name="l00015"></a>00015 <span class="comment"> * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span>
<a name="l00016"></a>00016 <span class="comment"> * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL</span>
<a name="l00017"></a>00017 <span class="comment"> * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span>
<a name="l00018"></a>00018 <span class="comment"> * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,</span>
<a name="l00019"></a>00019 <span class="comment"> * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN</span>
<a name="l00020"></a>00020 <span class="comment"> * THE SOFTWARE.</span>
<a name="l00021"></a>00021 <span class="comment"> */</span>
<a name="l00022"></a>00022 <span class="comment"></span>
<a name="l00023"></a>00023 <span class="comment">/**</span>
<a name="l00024"></a>00024 <span class="comment"> * @file</span>
<a name="l00025"></a>00025 <span class="comment"> * libavformat/libavcodec demuxing and muxing API example.</span>
<a name="l00026"></a>00026 <span class="comment"> *</span>
<a name="l00027"></a>00027 <span class="comment"> * Remux streams from one container format to another.</span>
<a name="l00028"></a>00028 <span class="comment"> * @example remuxing.c</span>
<a name="l00029"></a>00029 <span class="comment"> */</span>
<a name="l00030"></a>00030 
<a name="l00031"></a>00031 <span class="preprocessor">#include &lt;<a class="code" href="timestamp_8h.html" title="timestamp utils, mostly useful for debugging/logging purposes">libavutil/timestamp.h</a>&gt;</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include &lt;<a class="code" href="avformat_8h.html" title="Main libavformat public API header.">libavformat/avformat.h</a>&gt;</span>
<a name="l00033"></a>00033 
<a name="l00034"></a><a class="code" href="remuxing_8c.html#ae9433a5041497371569e7f9a3c84a6e6">00034</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="remuxing_8c.html#ae9433a5041497371569e7f9a3c84a6e6">log_packet</a>(<span class="keyword">const</span> <a class="code" href="structAVFormatContext.html" title="Format I/O context.">AVFormatContext</a> *<a class="code" href="demuxing__decoding_8c.html#a409462acdf7aebe5bfbe1bcd811efa5d">fmt_ctx</a>, <span class="keyword">const</span> <a class="code" href="structAVPacket.html" title="This structure stores compressed data.">AVPacket</a> *<a class="code" href="demuxing__decoding_8c.html#a3d4c6562f0b27cf0cacbbea5c038c090">pkt</a>, <span class="keyword">const</span> <span class="keywordtype">char</span> *tag)
<a name="l00035"></a>00035 {
<a name="l00036"></a>00036     <a class="code" href="structAVRational.html" title="rational number numerator/denominator">AVRational</a> *time_base = &amp;fmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[pkt-&gt;<a class="code" href="structAVPacket.html#a0d1cb9b5a32b00fb6edc81ea3aae2a49">stream_index</a>]-&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>;
<a name="l00037"></a>00037 
<a name="l00038"></a>00038     printf(<span class="stringliteral">&quot;%s: pts:%s pts_time:%s dts:%s dts_time:%s duration:%s duration_time:%s stream_index:%d\n&quot;</span>,
<a name="l00039"></a>00039            tag,
<a name="l00040"></a>00040            <a class="code" href="timestamp_8h.html#a86d797e907fa454ed5fd34bfb0bcd747" title="Convenience macro, the return value should be used only directly in function arguments but never stan...">av_ts2str</a>(pkt-&gt;<a class="code" href="structAVPacket.html#a73bde0a37f3b1efc839f11295bfbf42a" title="Presentation timestamp in AVStream-&gt;time_base units; the time at which the decompressed packet will b...">pts</a>), <a class="code" href="timestamp_8h.html#ad344b91ede6b86fc0a530611293f42da" title="Convenience macro, the return value should be used only directly in function arguments but never stan...">av_ts2timestr</a>(pkt-&gt;<a class="code" href="structAVPacket.html#a73bde0a37f3b1efc839f11295bfbf42a" title="Presentation timestamp in AVStream-&gt;time_base units; the time at which the decompressed packet will b...">pts</a>, time_base),
<a name="l00041"></a>00041            <a class="code" href="timestamp_8h.html#a86d797e907fa454ed5fd34bfb0bcd747" title="Convenience macro, the return value should be used only directly in function arguments but never stan...">av_ts2str</a>(pkt-&gt;<a class="code" href="structAVPacket.html#a85dbbd306b44b02390cd91c45e6a0f76" title="Decompression timestamp in AVStream-&gt;time_base units; the time at which the packet is decompressed...">dts</a>), <a class="code" href="timestamp_8h.html#ad344b91ede6b86fc0a530611293f42da" title="Convenience macro, the return value should be used only directly in function arguments but never stan...">av_ts2timestr</a>(pkt-&gt;<a class="code" href="structAVPacket.html#a85dbbd306b44b02390cd91c45e6a0f76" title="Decompression timestamp in AVStream-&gt;time_base units; the time at which the packet is decompressed...">dts</a>, time_base),
<a name="l00042"></a>00042            <a class="code" href="timestamp_8h.html#a86d797e907fa454ed5fd34bfb0bcd747" title="Convenience macro, the return value should be used only directly in function arguments but never stan...">av_ts2str</a>(pkt-&gt;<a class="code" href="structAVPacket.html#af151ba1967c37038088883cd544eeacd" title="Duration of this packet in AVStream-&gt;time_base units, 0 if unknown.">duration</a>), <a class="code" href="timestamp_8h.html#ad344b91ede6b86fc0a530611293f42da" title="Convenience macro, the return value should be used only directly in function arguments but never stan...">av_ts2timestr</a>(pkt-&gt;<a class="code" href="structAVPacket.html#af151ba1967c37038088883cd544eeacd" title="Duration of this packet in AVStream-&gt;time_base units, 0 if unknown.">duration</a>, time_base),
<a name="l00043"></a>00043            pkt-&gt;<a class="code" href="structAVPacket.html#a0d1cb9b5a32b00fb6edc81ea3aae2a49">stream_index</a>);
<a name="l00044"></a>00044 }
<a name="l00045"></a>00045 
<a name="l00046"></a><a class="code" href="remuxing_8c.html#a3c04138a5bfe5d72780bb7e82a18e627">00046</a> <span class="keywordtype">int</span> <a class="code" href="avio__list__dir_8c.html#a0ddf1224851353fc92bfbff6f499fa97">main</a>(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)
<a name="l00047"></a>00047 {
<a name="l00048"></a>00048     <a class="code" href="structAVOutputFormat.html">AVOutputFormat</a> *ofmt = NULL;
<a name="l00049"></a>00049     <a class="code" href="structAVFormatContext.html" title="Format I/O context.">AVFormatContext</a> *<a class="code" href="transcoding_8c.html#a24170971d926c1359c289f2515dec3d7">ifmt_ctx</a> = NULL, *<a class="code" href="transcoding_8c.html#aad50129a22f90b00b5d5cc7551175093">ofmt_ctx</a> = NULL;
<a name="l00050"></a>00050     <a class="code" href="structAVPacket.html" title="This structure stores compressed data.">AVPacket</a> <a class="code" href="demuxing__decoding_8c.html#a3d4c6562f0b27cf0cacbbea5c038c090">pkt</a>;
<a name="l00051"></a>00051     <span class="keyword">const</span> <span class="keywordtype">char</span> *in_filename, *out_filename;
<a name="l00052"></a>00052     <span class="keywordtype">int</span> ret, i;
<a name="l00053"></a>00053 
<a name="l00054"></a>00054     <span class="keywordflow">if</span> (argc &lt; 3) {
<a name="l00055"></a>00055         printf(<span class="stringliteral">&quot;usage: %s input output\n&quot;</span>
<a name="l00056"></a>00056                <span class="stringliteral">&quot;API example program to remux a media file with libavformat and libavcodec.\n&quot;</span>
<a name="l00057"></a>00057                <span class="stringliteral">&quot;The output format is guessed according to the file extension.\n&quot;</span>
<a name="l00058"></a>00058                <span class="stringliteral">&quot;\n&quot;</span>, argv[0]);
<a name="l00059"></a>00059         <span class="keywordflow">return</span> 1;
<a name="l00060"></a>00060     }
<a name="l00061"></a>00061 
<a name="l00062"></a>00062     in_filename  = argv[1];
<a name="l00063"></a>00063     out_filename = argv[2];
<a name="l00064"></a>00064 
<a name="l00065"></a>00065     <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="l00066"></a>00066 
<a name="l00067"></a>00067     <span class="keywordflow">if</span> ((ret = <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, in_filename, 0, 0)) &lt; 0) {
<a name="l00068"></a>00068         fprintf(stderr, <span class="stringliteral">&quot;Could not open input file &#39;%s&#39;&quot;</span>, in_filename);
<a name="l00069"></a>00069         <span class="keywordflow">goto</span> end;
<a name="l00070"></a>00070     }
<a name="l00071"></a>00071 
<a name="l00072"></a>00072     <span class="keywordflow">if</span> ((ret = <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, 0)) &lt; 0) {
<a name="l00073"></a>00073         fprintf(stderr, <span class="stringliteral">&quot;Failed to retrieve input stream information&quot;</span>);
<a name="l00074"></a>00074         <span class="keywordflow">goto</span> end;
<a name="l00075"></a>00075     }
<a name="l00076"></a>00076 
<a name="l00077"></a>00077     <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, in_filename, 0);
<a name="l00078"></a>00078 
<a name="l00079"></a>00079     <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, out_filename);
<a name="l00080"></a>00080     <span class="keywordflow">if</span> (!ofmt_ctx) {
<a name="l00081"></a>00081         fprintf(stderr, <span class="stringliteral">&quot;Could not create output context\n&quot;</span>);
<a name="l00082"></a>00082         ret = <a class="code" href="group__lavu__error.html#ga4ebaa288c7684a26a591c501208910e4" title="Unknown error, typically from an external library.">AVERROR_UNKNOWN</a>;
<a name="l00083"></a>00083         <span class="keywordflow">goto</span> end;
<a name="l00084"></a>00084     }
<a name="l00085"></a>00085 
<a name="l00086"></a>00086     ofmt = ofmt_ctx-&gt;oformat;
<a name="l00087"></a>00087 
<a name="l00088"></a>00088     <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="l00089"></a>00089         <a class="code" href="structAVStream.html" title="Stream structure.">AVStream</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];
<a name="l00090"></a>00090         <a class="code" href="structAVStream.html" title="Stream structure.">AVStream</a> *out_stream = <a class="code" href="group__lavf__core.html#gadcb0fd3e507d9b58fe78f61f8ad39827" title="Add a new stream to a media file.">avformat_new_stream</a>(ofmt_ctx, in_stream-&gt;<a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>-&gt;<a class="code" href="structAVCodecContext.html#ab00398f08f8622c3e6c0f1a12eb99808">codec</a>);
<a name="l00091"></a>00091         <span class="keywordflow">if</span> (!out_stream) {
<a name="l00092"></a>00092             fprintf(stderr, <span class="stringliteral">&quot;Failed allocating output stream\n&quot;</span>);
<a name="l00093"></a>00093             ret = <a class="code" href="group__lavu__error.html#ga4ebaa288c7684a26a591c501208910e4" title="Unknown error, typically from an external library.">AVERROR_UNKNOWN</a>;
<a name="l00094"></a>00094             <span class="keywordflow">goto</span> end;
<a name="l00095"></a>00095         }
<a name="l00096"></a>00096 
<a name="l00097"></a>00097         ret = <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>(out_stream-&gt;<a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>, in_stream-&gt;<a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>);
<a name="l00098"></a>00098         <span class="keywordflow">if</span> (ret &lt; 0) {
<a name="l00099"></a>00099             fprintf(stderr, <span class="stringliteral">&quot;Failed to copy context from input to output stream codec context\n&quot;</span>);
<a name="l00100"></a>00100             <span class="keywordflow">goto</span> end;
<a name="l00101"></a>00101         }
<a name="l00102"></a>00102         out_stream-&gt;<a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>-&gt;<a class="code" href="structAVCodecContext.html#a2c974557671dd459674b170c5e64d79a" title="fourcc (LSB first, so &quot;ABCD&quot; -&gt; (&#39;D&#39;&lt;&lt;24) + (&#39;C&#39;&lt;&lt;16) + (&#39;B&#39;&lt;&lt;8) + &#39;A&#39;).">codec_tag</a> = 0;
<a name="l00103"></a>00103         <span class="keywordflow">if</span> (ofmt_ctx-&gt;oformat-&gt;flags &amp; <a class="code" href="avformat_8h.html#ab203c7b734e9c31b7c37d34f6e2c6aef" title="Format wants global header.">AVFMT_GLOBALHEADER</a>)
<a name="l00104"></a>00104             out_stream-&gt;<a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>-&gt;<a class="code" href="structAVCodecContext.html#abb01e291550fa3fb96188af4d494587e" title="CODEC_FLAG_*.">flags</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 name="l00105"></a>00105     }
<a name="l00106"></a>00106     <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, out_filename, 1);
<a name="l00107"></a>00107 
<a name="l00108"></a>00108     <span class="keywordflow">if</span> (!(ofmt-&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="l00109"></a>00109         ret = <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;pb, out_filename, <a class="code" href="avio_8h.html#a5c9308f296545a8f3b7687d277a6dabc" title="write-only">AVIO_FLAG_WRITE</a>);
<a name="l00110"></a>00110         <span class="keywordflow">if</span> (ret &lt; 0) {
<a name="l00111"></a>00111             fprintf(stderr, <span class="stringliteral">&quot;Could not open output file &#39;%s&#39;&quot;</span>, out_filename);
<a name="l00112"></a>00112             <span class="keywordflow">goto</span> end;
<a name="l00113"></a>00113         }
<a name="l00114"></a>00114     }
<a name="l00115"></a>00115 
<a name="l00116"></a>00116     ret = <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);
<a name="l00117"></a>00117     <span class="keywordflow">if</span> (ret &lt; 0) {
<a name="l00118"></a>00118         fprintf(stderr, <span class="stringliteral">&quot;Error occurred when opening output file\n&quot;</span>);
<a name="l00119"></a>00119         <span class="keywordflow">goto</span> end;
<a name="l00120"></a>00120     }
<a name="l00121"></a>00121 
<a name="l00122"></a>00122     <span class="keywordflow">while</span> (1) {
<a name="l00123"></a>00123         <a class="code" href="structAVStream.html" title="Stream structure.">AVStream</a> *in_stream, *out_stream;
<a name="l00124"></a>00124 
<a name="l00125"></a>00125         ret = <a class="code" href="group__lavf__decoding.html#ga4fdb3084415a82e3810de6ee60e46a61" title="Return the next frame of a stream.">av_read_frame</a>(ifmt_ctx, &amp;pkt);
<a name="l00126"></a>00126         <span class="keywordflow">if</span> (ret &lt; 0)
<a name="l00127"></a>00127             <span class="keywordflow">break</span>;
<a name="l00128"></a>00128 
<a name="l00129"></a>00129         in_stream  = ifmt_ctx-&gt;<a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[pkt.<a class="code" href="structAVPacket.html#a0d1cb9b5a32b00fb6edc81ea3aae2a49">stream_index</a>];
<a name="l00130"></a>00130         out_stream = ofmt_ctx-&gt;streams[pkt.<a class="code" href="structAVPacket.html#a0d1cb9b5a32b00fb6edc81ea3aae2a49">stream_index</a>];
<a name="l00131"></a>00131 
<a name="l00132"></a>00132         <a class="code" href="remuxing_8c.html#ae9433a5041497371569e7f9a3c84a6e6">log_packet</a>(ifmt_ctx, &amp;pkt, <span class="stringliteral">&quot;in&quot;</span>);
<a name="l00133"></a>00133 
<a name="l00134"></a>00134         <span class="comment">/* copy packet */</span>
<a name="l00135"></a>00135         pkt.<a class="code" href="structAVPacket.html#a73bde0a37f3b1efc839f11295bfbf42a" title="Presentation timestamp in AVStream-&gt;time_base units; the time at which the decompressed packet will b...">pts</a> = <a class="code" href="group__lavu__math.html#gac167a841d10ac919407e77ae35391cf3" title="Rescale a 64-bit integer by 2 rational numbers with specified rounding.">av_rescale_q_rnd</a>(pkt.<a class="code" href="structAVPacket.html#a73bde0a37f3b1efc839f11295bfbf42a" title="Presentation timestamp in AVStream-&gt;time_base units; the time at which the decompressed packet will b...">pts</a>, in_stream-&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>, out_stream-&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>, <a class="code" href="group__lavu__math.html#gga921d656eaf2c4d6800a734a13af021d0aea95b00154ff83c740b46376dfa06e11" title="Round to nearest and halfway cases away from zero.">AV_ROUND_NEAR_INF</a>|<a class="code" href="group__lavu__math.html#gga921d656eaf2c4d6800a734a13af021d0a7fcb56631d6898b282d6c78ce6c14a43" title="Flag to pass INT64_MIN/MAX through instead of rescaling, this avoids special cases for AV_NOPTS_VALUE...">AV_ROUND_PASS_MINMAX</a>);
<a name="l00136"></a>00136         pkt.<a class="code" href="structAVPacket.html#a85dbbd306b44b02390cd91c45e6a0f76" title="Decompression timestamp in AVStream-&gt;time_base units; the time at which the packet is decompressed...">dts</a> = <a class="code" href="group__lavu__math.html#gac167a841d10ac919407e77ae35391cf3" title="Rescale a 64-bit integer by 2 rational numbers with specified rounding.">av_rescale_q_rnd</a>(pkt.<a class="code" href="structAVPacket.html#a85dbbd306b44b02390cd91c45e6a0f76" title="Decompression timestamp in AVStream-&gt;time_base units; the time at which the packet is decompressed...">dts</a>, in_stream-&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>, out_stream-&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>, <a class="code" href="group__lavu__math.html#gga921d656eaf2c4d6800a734a13af021d0aea95b00154ff83c740b46376dfa06e11" title="Round to nearest and halfway cases away from zero.">AV_ROUND_NEAR_INF</a>|<a class="code" href="group__lavu__math.html#gga921d656eaf2c4d6800a734a13af021d0a7fcb56631d6898b282d6c78ce6c14a43" title="Flag to pass INT64_MIN/MAX through instead of rescaling, this avoids special cases for AV_NOPTS_VALUE...">AV_ROUND_PASS_MINMAX</a>);
<a name="l00137"></a>00137         pkt.<a class="code" href="structAVPacket.html#af151ba1967c37038088883cd544eeacd" title="Duration of this packet in AVStream-&gt;time_base units, 0 if unknown.">duration</a> = <a class="code" href="group__lavu__math.html#gaf02994a8bbeaa91d4757df179cbe567f" title="Rescale a 64-bit integer by 2 rational numbers.">av_rescale_q</a>(pkt.<a class="code" href="structAVPacket.html#af151ba1967c37038088883cd544eeacd" title="Duration of this packet in AVStream-&gt;time_base units, 0 if unknown.">duration</a>, in_stream-&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>, out_stream-&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>);
<a name="l00138"></a>00138         pkt.<a class="code" href="structAVPacket.html#ab5793d8195cf4789dfb3913b7a693903" title="byte position in stream, -1 if unknown">pos</a> = -1;
<a name="l00139"></a>00139         <a class="code" href="remuxing_8c.html#ae9433a5041497371569e7f9a3c84a6e6">log_packet</a>(ofmt_ctx, &amp;pkt, <span class="stringliteral">&quot;out&quot;</span>);
<a name="l00140"></a>00140 
<a name="l00141"></a>00141         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;pkt);
<a name="l00142"></a>00142         <span class="keywordflow">if</span> (ret &lt; 0) {
<a name="l00143"></a>00143             fprintf(stderr, <span class="stringliteral">&quot;Error muxing packet\n&quot;</span>);
<a name="l00144"></a>00144             <span class="keywordflow">break</span>;
<a name="l00145"></a>00145         }
<a name="l00146"></a>00146         <a class="code" href="group__lavc__packet.html#gae65881462e78f98b268f34661d921ee0" title="Free a packet.">av_free_packet</a>(&amp;pkt);
<a name="l00147"></a>00147     }
<a name="l00148"></a>00148 
<a name="l00149"></a>00149     <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);
<a name="l00150"></a>00150 end:
<a name="l00151"></a>00151 
<a name="l00152"></a>00152     <a class="code" href="group__lavf__decoding.html#gae804b99aec044690162b8b9b110236a4" title="Close an opened input AVFormatContext.">avformat_close_input</a>(&amp;ifmt_ctx);
<a name="l00153"></a>00153 
<a name="l00154"></a>00154     <span class="comment">/* close output */</span>
<a name="l00155"></a>00155     <span class="keywordflow">if</span> (ofmt_ctx &amp;&amp; !(ofmt-&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="l00156"></a>00156         <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;pb);
<a name="l00157"></a>00157     <a class="code" href="group__lavf__core.html#gac2990b13b68e831a408fce8e1d0d6445" title="Free an AVFormatContext and all its streams.">avformat_free_context</a>(ofmt_ctx);
<a name="l00158"></a>00158 
<a name="l00159"></a>00159     <span class="keywordflow">if</span> (ret &lt; 0 &amp;&amp; ret != <a class="code" href="group__lavu__error.html#gab4faa0afdf35076914824200331defff" title="End of file.">AVERROR_EOF</a>) {
<a name="l00160"></a>00160         fprintf(stderr, <span class="stringliteral">&quot;Error occurred: %s\n&quot;</span>, <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));
<a name="l00161"></a>00161         <span class="keywordflow">return</span> 1;
<a name="l00162"></a>00162     }
<a name="l00163"></a>00163 
<a name="l00164"></a>00164     <span class="keywordflow">return</span> 0;
<a name="l00165"></a>00165 }
</pre></div></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>