Repository URL to install this package:
Version:
7:2.7.1-1ubuntu2 ▾
|
<!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: remuxing.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
 <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 Page</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="annotated.html"><span>Data 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">remuxing.c</div> </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><pre class="fragment"><span class="comment">/*</span>
<span class="comment"> * Copyright (c) 2013 Stefano Sabatini</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 "Software"), 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 "AS IS", 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"> * libavformat/libavcodec demuxing and muxing API example.</span>
<span class="comment"> *</span>
<span class="comment"> * Remux streams from one container format to another.</span>
<span class="comment"> * @example remuxing.c</span>
<span class="comment"> */</span>
<span class="preprocessor">#include <<a class="code" href="timestamp_8h.html" title="timestamp utils, mostly useful for debugging/logging purposes">libavutil/timestamp.h</a>></span>
<span class="preprocessor">#include <<a class="code" href="avformat_8h.html" title="Main libavformat public API header.">libavformat/avformat.h</a>></span>
<span class="keyword">static</span> <span class="keywordtype">void</span> <a name="a0"></a><a class="code" href="muxing_8c.html#ac7a1319852323152629ce60c4ef04ed5">log_packet</a>(<span class="keyword">const</span> <a name="_a1"></a><a class="code" href="structAVFormatContext.html" title="Format I/O context.">AVFormatContext</a> *<a name="a2"></a><a class="code" href="demuxing__decoding_8c.html#a409462acdf7aebe5bfbe1bcd811efa5d">fmt_ctx</a>, <span class="keyword">const</span> <a name="_a3"></a><a class="code" href="structAVPacket.html" title="This structure stores compressed data.">AVPacket</a> *<a name="a4"></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="_a5"></a><a class="code" href="structAVRational.html" title="rational number numerator/denominator">AVRational</a> *time_base = &fmt_ctx-><a name="a6"></a><a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[pkt-><a name="a7"></a><a class="code" href="structAVPacket.html#a0d1cb9b5a32b00fb6edc81ea3aae2a49">stream_index</a>]-><a name="a8"></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>;
printf(<span class="stringliteral">"%s: pts:%s pts_time:%s dts:%s dts_time:%s duration:%s duration_time:%s stream_index:%d\n"</span>,
tag,
<a name="a9"></a><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-><a name="a10"></a><a class="code" href="structAVPacket.html#a73bde0a37f3b1efc839f11295bfbf42a" title="Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...">pts</a>), <a name="a11"></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-><a class="code" href="structAVPacket.html#a73bde0a37f3b1efc839f11295bfbf42a" title="Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...">pts</a>, time_base),
<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-><a name="a12"></a><a class="code" href="structAVPacket.html#a85dbbd306b44b02390cd91c45e6a0f76" title="Decompression timestamp in AVStream->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-><a class="code" href="structAVPacket.html#a85dbbd306b44b02390cd91c45e6a0f76" title="Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...">dts</a>, time_base),
<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-><a name="a13"></a><a class="code" href="structAVPacket.html#af151ba1967c37038088883cd544eeacd" title="Duration of this packet in AVStream->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-><a class="code" href="structAVPacket.html#af151ba1967c37038088883cd544eeacd" title="Duration of this packet in AVStream->time_base units, 0 if unknown.">duration</a>, time_base),
pkt-><a class="code" href="structAVPacket.html#a0d1cb9b5a32b00fb6edc81ea3aae2a49">stream_index</a>);
}
<span class="keywordtype">int</span> <a name="a14"></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)
{
<a name="_a15"></a><a class="code" href="structAVOutputFormat.html">AVOutputFormat</a> *ofmt = NULL;
<a class="code" href="structAVFormatContext.html" title="Format I/O context.">AVFormatContext</a> *<a name="a16"></a><a class="code" href="transcoding_8c.html#a24170971d926c1359c289f2515dec3d7">ifmt_ctx</a> = NULL, *<a name="a17"></a><a class="code" href="transcoding_8c.html#aad50129a22f90b00b5d5cc7551175093">ofmt_ctx</a> = NULL;
<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> *in_filename, *out_filename;
<span class="keywordtype">int</span> ret, i;
<span class="keywordflow">if</span> (argc < 3) {
printf(<span class="stringliteral">"usage: %s input output\n"</span>
<span class="stringliteral">"API example program to remux a media file with libavformat and libavcodec.\n"</span>
<span class="stringliteral">"The output format is guessed according to the file extension.\n"</span>
<span class="stringliteral">"\n"</span>, argv[0]);
<span class="keywordflow">return</span> 1;
}
in_filename = argv[1];
out_filename = argv[2];
<a name="a18"></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>();
<span class="keywordflow">if</span> ((ret = <a name="a19"></a><a class="code" href="group__lavf__decoding.html#ga10a404346c646e4ab58f4ed798baca32" title="Open an input stream and read the header.">avformat_open_input</a>(&ifmt_ctx, in_filename, 0, 0)) < 0) {
fprintf(stderr, <span class="stringliteral">"Could not open input file '%s'"</span>, in_filename);
<span class="keywordflow">goto</span> end;
}
<span class="keywordflow">if</span> ((ret = <a name="a20"></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, 0)) < 0) {
fprintf(stderr, <span class="stringliteral">"Failed to retrieve input stream information"</span>);
<span class="keywordflow">goto</span> end;
}
<a name="a21"></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, in_filename, 0);
<a name="a22"></a><a class="code" href="avformat_8h.html#a6ddf3d982feb45fa5081420ee911f5d5" title="Allocate an AVFormatContext for an output format.">avformat_alloc_output_context2</a>(&ofmt_ctx, NULL, NULL, out_filename);
<span class="keywordflow">if</span> (!ofmt_ctx) {
fprintf(stderr, <span class="stringliteral">"Could not create output context\n"</span>);
ret = <a name="a23"></a><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;
}
ofmt = ofmt_ctx->oformat;
<span class="keywordflow">for</span> (i = 0; i < ifmt_ctx-><a name="a24"></a><a class="code" href="structAVFormatContext.html#a0b748d924898b08b89ff4974afd17285" title="Number of elements in AVFormatContext.streams.">nb_streams</a>; i++) {
<a name="_a25"></a><a class="code" href="structAVStream.html" title="Stream structure.">AVStream</a> *in_stream = ifmt_ctx-><a class="code" href="structAVFormatContext.html#acfefb6b6cf21e87a0dcbd1a547ba2348" title="A list of all streams in the file.">streams</a>[i];
<a class="code" href="structAVStream.html" title="Stream structure.">AVStream</a> *out_stream = <a name="a26"></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, in_stream-><a name="a27"></a><a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>-><a name="a28"></a><a class="code" href="structAVCodecContext.html#ab00398f08f8622c3e6c0f1a12eb99808">codec</a>);
<span class="keywordflow">if</span> (!out_stream) {
fprintf(stderr, <span class="stringliteral">"Failed allocating output stream\n"</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;
}
ret = <a name="a29"></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>(out_stream-><a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>, in_stream-><a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>);
<span class="keywordflow">if</span> (ret < 0) {
fprintf(stderr, <span class="stringliteral">"Failed to copy context from input to output stream codec context\n"</span>);
<span class="keywordflow">goto</span> end;
}
out_stream-><a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>-><a name="a30"></a><a class="code" href="structAVCodecContext.html#a2c974557671dd459674b170c5e64d79a" title="fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').">codec_tag</a> = 0;
<span class="keywordflow">if</span> (ofmt_ctx->oformat->flags & <a name="a31"></a><a class="code" href="avformat_8h.html#ab203c7b734e9c31b7c37d34f6e2c6aef" title="Format wants global header.">AVFMT_GLOBALHEADER</a>)
out_stream-><a class="code" href="structAVStream.html#a56f20051fb99339cc588cd3a07ab8c96" title="Codec context associated with this stream.">codec</a>-><a name="a32"></a><a class="code" href="structAVCodecContext.html#abb01e291550fa3fb96188af4d494587e" title="CODEC_FLAG_*.">flags</a> |= <a name="a33"></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, out_filename, 1);
<span class="keywordflow">if</span> (!(ofmt-><a name="a34"></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> & <a name="a35"></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="a36"></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>(&ofmt_ctx->pb, out_filename, <a name="a37"></a><a class="code" href="avio_8h.html#a5c9308f296545a8f3b7687d277a6dabc" title="write-only">AVIO_FLAG_WRITE</a>);
<span class="keywordflow">if</span> (ret < 0) {
fprintf(stderr, <span class="stringliteral">"Could not open output file '%s'"</span>, out_filename);
<span class="keywordflow">goto</span> end;
}
}
ret = <a name="a38"></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 < 0) {
fprintf(stderr, <span class="stringliteral">"Error occurred when opening output file\n"</span>);
<span class="keywordflow">goto</span> end;
}
<span class="keywordflow">while</span> (1) {
<a class="code" href="structAVStream.html" title="Stream structure.">AVStream</a> *in_stream, *out_stream;
ret = <a name="a39"></a><a class="code" href="group__lavf__decoding.html#ga4fdb3084415a82e3810de6ee60e46a61" title="Return the next frame of a stream.">av_read_frame</a>(ifmt_ctx, &pkt);
<span class="keywordflow">if</span> (ret < 0)
<span class="keywordflow">break</span>;
in_stream = ifmt_ctx-><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>];
out_stream = ofmt_ctx->streams[pkt.<a class="code" href="structAVPacket.html#a0d1cb9b5a32b00fb6edc81ea3aae2a49">stream_index</a>];
<a class="code" href="muxing_8c.html#ac7a1319852323152629ce60c4ef04ed5">log_packet</a>(ifmt_ctx, &pkt, <span class="stringliteral">"in"</span>);
<span class="comment">/* copy packet */</span>
pkt.<a class="code" href="structAVPacket.html#a73bde0a37f3b1efc839f11295bfbf42a" title="Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...">pts</a> = <a name="a40"></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->time_base units; the time at which the decompressed packet will b...">pts</a>, in_stream-><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-><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="a41"></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 name="a42"></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>);
pkt.<a class="code" href="structAVPacket.html#a85dbbd306b44b02390cd91c45e6a0f76" title="Decompression timestamp in AVStream->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->time_base units; the time at which the packet is decompressed...">dts</a>, in_stream-><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-><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>);
pkt.<a class="code" href="structAVPacket.html#af151ba1967c37038088883cd544eeacd" title="Duration of this packet in AVStream->time_base units, 0 if unknown.">duration</a> = <a name="a43"></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->time_base units, 0 if unknown.">duration</a>, in_stream-><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-><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>);
pkt.<a name="a44"></a><a class="code" href="structAVPacket.html#ab5793d8195cf4789dfb3913b7a693903" title="byte position in stream, -1 if unknown">pos</a> = -1;
<a class="code" href="muxing_8c.html#ac7a1319852323152629ce60c4ef04ed5">log_packet</a>(ofmt_ctx, &pkt, <span class="stringliteral">"out"</span>);
ret = <a name="a45"></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, &pkt);
<span class="keywordflow">if</span> (ret < 0) {
fprintf(stderr, <span class="stringliteral">"Error muxing packet\n"</span>);
<span class="keywordflow">break</span>;
}
<a name="a46"></a><a class="code" href="group__lavc__packet.html#gae65881462e78f98b268f34661d921ee0" title="Free a packet.">av_free_packet</a>(&pkt);
}
<a name="a47"></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 name="a48"></a><a class="code" href="group__lavf__decoding.html#gae804b99aec044690162b8b9b110236a4" title="Close an opened input AVFormatContext.">avformat_close_input</a>(&ifmt_ctx);
<span class="comment">/* close output */</span>
<span class="keywordflow">if</span> (ofmt_ctx && !(ofmt-><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> & <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="a49"></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>(&ofmt_ctx->pb);
<a name="a50"></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 < 0 && ret != <a name="a51"></a><a class="code" href="group__lavu__error.html#gab4faa0afdf35076914824200331defff" title="End of file.">AVERROR_EOF</a>) {
fprintf(stderr, <span class="stringliteral">"Error occurred: %s\n"</span>, <a name="a52"></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> 1;
}
<span class="keywordflow">return</span> 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"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </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  <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>