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 / group__lavf__decoding.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: Demuxing</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="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Demuxing</div>  </div>
<div class="ingroups"><a class="el" href="group__libavf.html">I/O and Muxing/Demuxing Library</a></div></div><!--header-->
<div class="contents">

<p>Demuxers read a media file and split it into chunks of data (<em>packets</em>).  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structAVInputFormat.html">AVInputFormat</a></td></tr>
<tr><td colspan="2"><h2><a name="func-members"></a>
Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="structAVInputFormat.html">AVInputFormat</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__lavf__decoding.html#ga7d2f532c6653c2419b17956712fdf3da">av_find_input_format</a> (const char *short_name)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Find <a class="el" href="structAVInputFormat.html">AVInputFormat</a> based on the short name of the input format.  <a href="#ga7d2f532c6653c2419b17956712fdf3da"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="structAVInputFormat.html">AVInputFormat</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__lavf__decoding.html#gad8a1268228fff3aeae0aeaa99a767a24">av_probe_input_format</a> (<a class="el" href="structAVProbeData.html">AVProbeData</a> *pd, int is_opened)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Guess the file format.  <a href="#gad8a1268228fff3aeae0aeaa99a767a24"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="structAVInputFormat.html">AVInputFormat</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__lavf__decoding.html#gae8b938f6e7c3741dd27a6c171e72f33d">av_probe_input_format2</a> (<a class="el" href="structAVProbeData.html">AVProbeData</a> *pd, int is_opened, int *score_max)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Guess the file format.  <a href="#gae8b938f6e7c3741dd27a6c171e72f33d"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="structAVInputFormat.html">AVInputFormat</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__lavf__decoding.html#ga7e4318244afd6c5fe55cec75d27258b2">av_probe_input_format3</a> (<a class="el" href="structAVProbeData.html">AVProbeData</a> *pd, int is_opened, int *score_ret)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Guess the file format.  <a href="#ga7e4318244afd6c5fe55cec75d27258b2"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__lavf__decoding.html#ga69e44bd9ade0160a8cd6196aa37505ea">av_probe_input_buffer2</a> (<a class="el" href="structAVIOContext.html">AVIOContext</a> *pb, <a class="el" href="structAVInputFormat.html">AVInputFormat</a> **fmt, const char *filename, void *logctx, unsigned int offset, unsigned int max_probe_size)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Probe a bytestream to determine the input format.  <a href="#ga69e44bd9ade0160a8cd6196aa37505ea"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__lavf__decoding.html#ga5ef11a57aa4ed1d55703b66d59afbd0b">av_probe_input_buffer</a> (<a class="el" href="structAVIOContext.html">AVIOContext</a> *pb, <a class="el" href="structAVInputFormat.html">AVInputFormat</a> **fmt, const char *filename, void *logctx, unsigned int offset, unsigned int max_probe_size)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Like <a class="el" href="group__lavf__decoding.html#ga69e44bd9ade0160a8cd6196aa37505ea" title="Probe a bytestream to determine the input format.">av_probe_input_buffer2()</a> but returns 0 on success.  <a href="#ga5ef11a57aa4ed1d55703b66d59afbd0b"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__lavf__decoding.html#ga10a404346c646e4ab58f4ed798baca32">avformat_open_input</a> (<a class="el" href="structAVFormatContext.html">AVFormatContext</a> **ps, const char *filename, <a class="el" href="structAVInputFormat.html">AVInputFormat</a> *fmt, <a class="el" href="group__lavu__dict.html#ga1d7cc0833bee918994a600556410315f">AVDictionary</a> **options)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Open an input stream and read the header.  <a href="#ga10a404346c646e4ab58f4ed798baca32"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="attributes_8h.html#aa6d076561d3a9eea4729ee632652de02">attribute_deprecated</a> int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__lavf__decoding.html#ga71091e146791c4d181635485447c2830">av_demuxer_open</a> (<a class="el" href="structAVFormatContext.html">AVFormatContext</a> *ic)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__lavf__decoding.html#gad42172e27cddafb81096939783b157bb">avformat_find_stream_info</a> (<a class="el" href="structAVFormatContext.html">AVFormatContext</a> *ic, <a class="el" href="group__lavu__dict.html#ga1d7cc0833bee918994a600556410315f">AVDictionary</a> **options)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Read packets of a media file to get stream information.  <a href="#gad42172e27cddafb81096939783b157bb"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="structAVProgram.html">AVProgram</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__lavf__decoding.html#ga9edb9ac206ed05dc5baa9d168f31de48">av_find_program_from_stream</a> (<a class="el" href="structAVFormatContext.html">AVFormatContext</a> *ic, <a class="el" href="structAVProgram.html">AVProgram</a> *last, int s)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Find the programs which belong to a given stream.  <a href="#ga9edb9ac206ed05dc5baa9d168f31de48"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__lavf__decoding.html#gaa6fa468c922ff5c60a6021dcac09aff9">av_find_best_stream</a> (<a class="el" href="structAVFormatContext.html">AVFormatContext</a> *ic, enum <a class="el" href="group__lavu__misc.html#ga9a84bba4713dfced21a1a56163be1f48">AVMediaType</a> type, int wanted_stream_nb, int related_stream, <a class="el" href="structAVCodec.html">AVCodec</a> **decoder_ret, int flags)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Find the "best" stream in the file.  <a href="#gaa6fa468c922ff5c60a6021dcac09aff9"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__lavf__decoding.html#ga4fdb3084415a82e3810de6ee60e46a61">av_read_frame</a> (<a class="el" href="structAVFormatContext.html">AVFormatContext</a> *s, <a class="el" href="structAVPacket.html">AVPacket</a> *<a class="el" href="extract__mvs_8c.html#a3d4c6562f0b27cf0cacbbea5c038c090">pkt</a>)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the next frame of a stream.  <a href="#ga4fdb3084415a82e3810de6ee60e46a61"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__lavf__decoding.html#gaa23f7619d8d4ea0857065d9979c75ac8">av_seek_frame</a> (<a class="el" href="structAVFormatContext.html">AVFormatContext</a> *s, int stream_index, int64_t timestamp, int flags)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Seek to the keyframe at timestamp.  <a href="#gaa23f7619d8d4ea0857065d9979c75ac8"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__lavf__decoding.html#ga3b40fc8d2fda6992ae6ea2567d71ba30">avformat_seek_file</a> (<a class="el" href="structAVFormatContext.html">AVFormatContext</a> *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Seek to timestamp ts.  <a href="#ga3b40fc8d2fda6992ae6ea2567d71ba30"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__lavf__decoding.html#gaa03a82c5fd4fe3af312d229ca94cd6f3">avformat_flush</a> (<a class="el" href="structAVFormatContext.html">AVFormatContext</a> *s)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Discard all internally buffered data.  <a href="#gaa03a82c5fd4fe3af312d229ca94cd6f3"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__lavf__decoding.html#ga7494bb63a59e79e9fe88eb1682d4d7b3">av_read_play</a> (<a class="el" href="structAVFormatContext.html">AVFormatContext</a> *s)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Start playing a network-based stream (e.g.  <a href="#ga7494bb63a59e79e9fe88eb1682d4d7b3"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__lavf__decoding.html#ga27db687592d99f25ccf81a3b3ee8da9c">av_read_pause</a> (<a class="el" href="structAVFormatContext.html">AVFormatContext</a> *s)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Pause a network-based stream (e.g.  <a href="#ga27db687592d99f25ccf81a3b3ee8da9c"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__lavf__decoding.html#gae804b99aec044690162b8b9b110236a4">avformat_close_input</a> (<a class="el" href="structAVFormatContext.html">AVFormatContext</a> **s)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Close an opened input <a class="el" href="structAVFormatContext.html" title="Format I/O context.">AVFormatContext</a>.  <a href="#gae804b99aec044690162b8b9b110236a4"></a><br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<p>Demuxers read a media file and split it into chunks of data (<em>packets</em>). </p>
<p>A <a class="el" href="structAVPacket.html">packet</a> contains one or more encoded frames which belongs to a single elementary stream. In the lavf API this process is represented by the <a class="el" href="group__lavf__decoding.html#ga10a404346c646e4ab58f4ed798baca32" title="Open an input stream and read the header.">avformat_open_input()</a> function for opening a file, <a class="el" href="group__lavf__decoding.html#ga4fdb3084415a82e3810de6ee60e46a61" title="Return the next frame of a stream.">av_read_frame()</a> for reading a single packet and finally <a class="el" href="group__lavf__decoding.html#gae804b99aec044690162b8b9b110236a4" title="Close an opened input AVFormatContext.">avformat_close_input()</a>, which does the cleanup.</p>
<h2><a class="anchor" id="lavf_decoding_open"></a>
Opening a media file</h2>
<p>The minimum information required to open a file is its URL or filename, which is passed to <a class="el" href="group__lavf__decoding.html#ga10a404346c646e4ab58f4ed798baca32" title="Open an input stream and read the header.">avformat_open_input()</a>, as in the following code: </p>
<div class="fragment"><pre class="fragment"> <span class="keyword">const</span> <span class="keywordtype">char</span>    *url = <span class="stringliteral">&quot;in.mp3&quot;</span>;
 <a class="code" href="structAVFormatContext.html" title="Format I/O context.">AVFormatContext</a> *s = NULL;
 <span class="keywordtype">int</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;s, url, NULL, NULL);
 <span class="keywordflow">if</span> (ret &lt; 0)
     abort();
</pre></div><p> The above code attempts to allocate an <a class="el" href="structAVFormatContext.html" title="Format I/O context.">AVFormatContext</a>, open the specified file (autodetecting the format) and read the header, exporting the information stored there into s. Some formats do not have a header or do not store enough information there, so it is recommended that you call the <a class="el" href="group__lavf__decoding.html#gad42172e27cddafb81096939783b157bb" title="Read packets of a media file to get stream information.">avformat_find_stream_info()</a> function which tries to read and decode a few frames to find missing information.</p>
<p>In some cases you might want to preallocate an <a class="el" href="structAVFormatContext.html" title="Format I/O context.">AVFormatContext</a> yourself with <a class="el" href="group__lavf__core.html#gac7a91abf2f59648d995894711f070f62" title="Allocate an AVFormatContext.">avformat_alloc_context()</a> and do some tweaking on it before passing it to <a class="el" href="group__lavf__decoding.html#ga10a404346c646e4ab58f4ed798baca32" title="Open an input stream and read the header.">avformat_open_input()</a>. One such case is when you want to use custom functions for reading input data instead of lavf internal I/O layer. To do that, create your own <a class="el" href="structAVIOContext.html" title="Bytestream IO Context.">AVIOContext</a> with <a class="el" href="avio_8h.html#a853f5149136a27ffba3207d8520172a5" title="Allocate and initialize an AVIOContext for buffered I/O.">avio_alloc_context()</a>, passing your reading callbacks to it. Then set the <em>pb</em> field of your <a class="el" href="structAVFormatContext.html" title="Format I/O context.">AVFormatContext</a> to newly created <a class="el" href="structAVIOContext.html" title="Bytestream IO Context.">AVIOContext</a>.</p>
<p>Since the format of the opened file is in general not known until after <a class="el" href="group__lavf__decoding.html#ga10a404346c646e4ab58f4ed798baca32" title="Open an input stream and read the header.">avformat_open_input()</a> has returned, it is not possible to set demuxer private options on a preallocated context. Instead, the options should be passed to <a class="el" href="group__lavf__decoding.html#ga10a404346c646e4ab58f4ed798baca32" title="Open an input stream and read the header.">avformat_open_input()</a> wrapped in an AVDictionary: </p>
<div class="fragment"><pre class="fragment"> <a class="code" href="group__lavu__dict.html#ga1d7cc0833bee918994a600556410315f">AVDictionary</a> *options = NULL;
 <a class="code" href="group__lavu__dict.html#ga8d9c2de72b310cef8e6a28c9cd3acbbe" title="Set the given entry in *pm, overwriting an existing entry.">av_dict_set</a>(&amp;options, <span class="stringliteral">&quot;video_size&quot;</span>, <span class="stringliteral">&quot;640x480&quot;</span>, 0);
 <a class="code" href="group__lavu__dict.html#ga8d9c2de72b310cef8e6a28c9cd3acbbe" title="Set the given entry in *pm, overwriting an existing entry.">av_dict_set</a>(&amp;options, <span class="stringliteral">&quot;pixel_format&quot;</span>, <span class="stringliteral">&quot;rgb24&quot;</span>, 0);

 <span class="keywordflow">if</span> (<a class="code" href="group__lavf__decoding.html#ga10a404346c646e4ab58f4ed798baca32" title="Open an input stream and read the header.">avformat_open_input</a>(&amp;s, url, NULL, &amp;options) &lt; 0)
     abort();
 <a class="code" href="group__lavu__dict.html#ga1bafd682b1fbb90e48a4cc3814b820f7" title="Free all the memory allocated for an AVDictionary struct and all keys and values.">av_dict_free</a>(&amp;options);
</pre></div><p> This code passes the private options 'video_size' and 'pixel_format' to the demuxer. They would be necessary for e.g. the rawvideo demuxer, since it cannot know how to interpret raw video data otherwise. If the format turns out to be something different than raw video, those options will not be recognized by the demuxer and therefore will not be applied. Such unrecognized options are then returned in the options dictionary (recognized options are consumed). The calling program can handle such unrecognized options as it wishes, e.g. </p>
<div class="fragment"><pre class="fragment"> <a class="code" href="structAVDictionaryEntry.html">AVDictionaryEntry</a> *e;
 <span class="keywordflow">if</span> (e = <a class="code" href="group__lavu__dict.html#gae67f143237b2cb2936c9b147aa6dfde3" title="Get a dictionary entry with matching key.">av_dict_get</a>(options, <span class="stringliteral">&quot;&quot;</span>, NULL, <a class="code" href="group__lavu__dict.html#ga341bbd1ea599dfb0510f419e5272fecc" title="Return first entry in a dictionary whose first part corresponds to the search key, ignoring the suffix of the found key string.">AV_DICT_IGNORE_SUFFIX</a>)) {
     fprintf(stderr, <span class="stringliteral">&quot;Option %s not recognized by the demuxer.\n&quot;</span>, e-&gt;<a class="code" href="structAVDictionaryEntry.html#a38fc80176f8f839282bb61c03392e194">key</a>);
     abort();
 }
</pre></div><p>After you have finished reading the file, you must close it with <a class="el" href="group__lavf__decoding.html#gae804b99aec044690162b8b9b110236a4" title="Close an opened input AVFormatContext.">avformat_close_input()</a>. It will free everything associated with the file.</p>
<h2><a class="anchor" id="lavf_decoding_read"></a>
Reading from an opened file</h2>
<p>Reading data from an opened <a class="el" href="structAVFormatContext.html" title="Format I/O context.">AVFormatContext</a> is done by repeatedly calling <a class="el" href="group__lavf__decoding.html#ga4fdb3084415a82e3810de6ee60e46a61" title="Return the next frame of a stream.">av_read_frame()</a> on it. Each call, if successful, will return an <a class="el" href="structAVPacket.html" title="This structure stores compressed data.">AVPacket</a> containing encoded data for one <a class="el" href="structAVStream.html" title="Stream structure.">AVStream</a>, identified by <a class="el" href="structAVPacket.html#a0d1cb9b5a32b00fb6edc81ea3aae2a49">AVPacket.stream_index</a>. This packet may be passed straight into the libavcodec decoding functions <a class="el" 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 class="el" 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> or <a class="el" href="group__lavc__decoding.html#ga47db1b7f294b9f92684401b9c66a7c4b" title="Decode a subtitle message.">avcodec_decode_subtitle2()</a> if the caller wishes to decode the data.</p>
<p><a class="el" href="structAVPacket.html#a73bde0a37f3b1efc839f11295bfbf42a" title="Presentation timestamp in AVStream-&gt;time_base units; the time at which the decompressed packet will b...">AVPacket.pts</a>, <a class="el" href="structAVPacket.html#a85dbbd306b44b02390cd91c45e6a0f76" title="Decompression timestamp in AVStream-&gt;time_base units; the time at which the packet is decompressed...">AVPacket.dts</a> and <a class="el" href="structAVPacket.html#af151ba1967c37038088883cd544eeacd" title="Duration of this packet in AVStream-&gt;time_base units, 0 if unknown.">AVPacket.duration</a> timing information will be set if known. They may also be unset (i.e. AV_NOPTS_VALUE for pts/dts, 0 for duration) if the stream does not provide them. The timing information will be in <a class="el" href="structAVStream.html#a9db755451f14e2bf590d4b85d82b32e6" title="This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...">AVStream.time_base</a> units, i.e. it has to be multiplied by the timebase to convert them to seconds.</p>
<p>If <a class="el" href="structAVPacket.html#a3bf81872813551fe9343dd0e09993e38" title="A reference to the reference-counted buffer where the packet data is stored.">AVPacket.buf</a> is set on the returned packet, then the packet is allocated dynamically and the user may keep it indefinitely. Otherwise, if <a class="el" href="structAVPacket.html#a3bf81872813551fe9343dd0e09993e38" title="A reference to the reference-counted buffer where the packet data is stored.">AVPacket.buf</a> is NULL, the packet data is backed by a static storage somewhere inside the demuxer and the packet is only valid until the next <a class="el" href="group__lavf__decoding.html#ga4fdb3084415a82e3810de6ee60e46a61" title="Return the next frame of a stream.">av_read_frame()</a> call or closing the file. If the caller requires a longer lifetime, <a class="el" href="group__lavc__packet.html#ga04c83bc8a685960564a169f3a050b915">av_dup_packet()</a> will make an <a class="el" href="group__lavu__mem.html#ga9722446c5e310ffedfaac9489864796d" title="Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...">av_malloc()</a>ed copy of it. In both cases, the packet must be freed with <a class="el" href="group__lavc__packet.html#gae65881462e78f98b268f34661d921ee0" title="Free a packet.">av_free_packet()</a> when it is no longer needed.</p>
<h2><a class="anchor" id="lavf_decoding_seek"></a>
Seeking</h2>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="ga7d2f532c6653c2419b17956712fdf3da"></a><!-- doxytag: member="avformat.h::av_find_input_format" ref="ga7d2f532c6653c2419b17956712fdf3da" args="(const char *short_name)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structAVInputFormat.html">AVInputFormat</a>* <a class="el" href="group__lavf__decoding.html#ga7d2f532c6653c2419b17956712fdf3da">av_find_input_format</a> </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>short_name</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Find <a class="el" href="structAVInputFormat.html">AVInputFormat</a> based on the short name of the input format. </p>

</div>
</div>
<a class="anchor" id="gad8a1268228fff3aeae0aeaa99a767a24"></a><!-- doxytag: member="avformat.h::av_probe_input_format" ref="gad8a1268228fff3aeae0aeaa99a767a24" args="(AVProbeData *pd, int is_opened)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structAVInputFormat.html">AVInputFormat</a>* <a class="el" href="group__lavf__decoding.html#gad8a1268228fff3aeae0aeaa99a767a24">av_probe_input_format</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structAVProbeData.html">AVProbeData</a> *&#160;</td>
          <td class="paramname"><em>pd</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>is_opened</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Guess the file format. </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">pd</td><td>data to be probed </td></tr>
    <tr><td class="paramname">is_opened</td><td>Whether the file is already opened; determines whether demuxers with or without AVFMT_NOFILE are probed. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="gae8b938f6e7c3741dd27a6c171e72f33d"></a><!-- doxytag: member="avformat.h::av_probe_input_format2" ref="gae8b938f6e7c3741dd27a6c171e72f33d" args="(AVProbeData *pd, int is_opened, int *score_max)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structAVInputFormat.html">AVInputFormat</a>* <a class="el" href="group__lavf__decoding.html#gae8b938f6e7c3741dd27a6c171e72f33d">av_probe_input_format2</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structAVProbeData.html">AVProbeData</a> *&#160;</td>
          <td class="paramname"><em>pd</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>is_opened</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>score_max</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Guess the file format. </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">pd</td><td>data to be probed </td></tr>
    <tr><td class="paramname">is_opened</td><td>Whether the file is already opened; determines whether demuxers with or without AVFMT_NOFILE are probed. </td></tr>
    <tr><td class="paramname">score_max</td><td>A probe score larger that this is required to accept a detection, the variable is set to the actual detection score afterwards. If the score is &lt;= AVPROBE_SCORE_MAX / 4 it is recommended to retry with a larger probe buffer. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga7e4318244afd6c5fe55cec75d27258b2"></a><!-- doxytag: member="avformat.h::av_probe_input_format3" ref="ga7e4318244afd6c5fe55cec75d27258b2" args="(AVProbeData *pd, int is_opened, int *score_ret)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structAVInputFormat.html">AVInputFormat</a>* <a class="el" href="group__lavf__decoding.html#ga7e4318244afd6c5fe55cec75d27258b2">av_probe_input_format3</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structAVProbeData.html">AVProbeData</a> *&#160;</td>
          <td class="paramname"><em>pd</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>is_opened</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>score_ret</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Guess the file format. </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">is_opened</td><td>Whether the file is already opened; determines whether demuxers with or without AVFMT_NOFILE are probed. </td></tr>
    <tr><td class="paramname">score_ret</td><td>The score of the best detection. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga69e44bd9ade0160a8cd6196aa37505ea"></a><!-- doxytag: member="avformat.h::av_probe_input_buffer2" ref="ga69e44bd9ade0160a8cd6196aa37505ea" args="(AVIOContext *pb, AVInputFormat **fmt, const char *filename, void *logctx, unsigned int offset, unsigned int max_probe_size)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int <a class="el" href="group__lavf__decoding.html#ga69e44bd9ade0160a8cd6196aa37505ea">av_probe_input_buffer2</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structAVIOContext.html">AVIOContext</a> *&#160;</td>
          <td class="paramname"><em>pb</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structAVInputFormat.html">AVInputFormat</a> **&#160;</td>
          <td class="paramname"><em>fmt</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>filename</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>logctx</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned int&#160;</td>
          <td class="paramname"><em>offset</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned int&#160;</td>
          <td class="paramname"><em>max_probe_size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Probe a bytestream to determine the input format. </p>
<p>Each time a probe returns with a score that is too low, the probe buffer size is increased and another attempt is made. When the maximum probe size is reached, the input format with the highest score is returned.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">pb</td><td>the bytestream to probe </td></tr>
    <tr><td class="paramname">fmt</td><td>the input format is put here </td></tr>
    <tr><td class="paramname">filename</td><td>the filename of the stream </td></tr>
    <tr><td class="paramname">logctx</td><td>the log context </td></tr>
    <tr><td class="paramname">offset</td><td>the offset within the bytestream to probe from </td></tr>
    <tr><td class="paramname">max_probe_size</td><td>the maximum probe buffer size (zero for default) </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>the score in case of success, a negative value corresponding to an the maximal score is AVPROBE_SCORE_MAX AVERROR code otherwise </dd></dl>

</div>
</div>
<a class="anchor" id="ga5ef11a57aa4ed1d55703b66d59afbd0b"></a><!-- doxytag: member="avformat.h::av_probe_input_buffer" ref="ga5ef11a57aa4ed1d55703b66d59afbd0b" args="(AVIOContext *pb, AVInputFormat **fmt, const char *filename, void *logctx, unsigned int offset, unsigned int max_probe_size)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int <a class="el" href="group__lavf__decoding.html#ga5ef11a57aa4ed1d55703b66d59afbd0b">av_probe_input_buffer</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structAVIOContext.html">AVIOContext</a> *&#160;</td>
          <td class="paramname"><em>pb</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structAVInputFormat.html">AVInputFormat</a> **&#160;</td>
          <td class="paramname"><em>fmt</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>filename</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>logctx</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned int&#160;</td>
          <td class="paramname"><em>offset</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned int&#160;</td>
          <td class="paramname"><em>max_probe_size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Like <a class="el" href="group__lavf__decoding.html#ga69e44bd9ade0160a8cd6196aa37505ea" title="Probe a bytestream to determine the input format.">av_probe_input_buffer2()</a> but returns 0 on success. </p>

</div>
</div>
<a class="anchor" id="ga10a404346c646e4ab58f4ed798baca32"></a><!-- doxytag: member="avformat.h::avformat_open_input" ref="ga10a404346c646e4ab58f4ed798baca32" args="(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int <a class="el" href="group__lavf__decoding.html#ga10a404346c646e4ab58f4ed798baca32">avformat_open_input</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structAVFormatContext.html">AVFormatContext</a> **&#160;</td>
          <td class="paramname"><em>ps</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>filename</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structAVInputFormat.html">AVInputFormat</a> *&#160;</td>
          <td class="paramname"><em>fmt</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__lavu__dict.html#ga1d7cc0833bee918994a600556410315f">AVDictionary</a> **&#160;</td>
          <td class="paramname"><em>options</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Open an input stream and read the header. </p>
<p>The codecs are not opened. The stream must be closed with <a class="el" href="group__lavf__decoding.html#gae804b99aec044690162b8b9b110236a4" title="Close an opened input AVFormatContext.">avformat_close_input()</a>.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">ps</td><td>Pointer to user-supplied <a class="el" href="structAVFormatContext.html" title="Format I/O context.">AVFormatContext</a> (allocated by avformat_alloc_context). May be a pointer to NULL, in which case an <a class="el" href="structAVFormatContext.html" title="Format I/O context.">AVFormatContext</a> is allocated by this function and written into ps. Note that a user-supplied <a class="el" href="structAVFormatContext.html" title="Format I/O context.">AVFormatContext</a> will be freed on failure. </td></tr>
    <tr><td class="paramname">filename</td><td>Name of the stream to open. </td></tr>
    <tr><td class="paramname">fmt</td><td>If non-NULL, this parameter forces a specific input format. Otherwise the format is autodetected. </td></tr>
    <tr><td class="paramname">options</td><td>A dictionary filled with <a class="el" href="structAVFormatContext.html" title="Format I/O context.">AVFormatContext</a> and demuxer-private options. On return this parameter will be destroyed and replaced with a dict containing options that were not found. May be NULL.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>0 on success, a negative AVERROR on failure.</dd></dl>
<dl class="note"><dt><b>Note:</b></dt><dd>If you want to use custom IO, preallocate the format context and set its pb field. </dd></dl>
<dl><dt><b>Examples: </b></dt><dd><a class="el" href="avio_reading_8c-example.html#a16">avio_reading.c</a>, <a class="el" href="demuxing_decoding_8c-example.html#a76">demuxing_decoding.c</a>, <a class="el" href="filtering_audio_8c-example.html#a14">filtering_audio.c</a>, <a class="el" href="filtering_video_8c-example.html#a15">filtering_video.c</a>, <a class="el" href="metadata_8c-example.html#a5">metadata.c</a>, <a class="el" href="remuxing_8c-example.html#a19">remuxing.c</a>, <a class="el" href="transcode_aac_8c-example.html#a6">transcode_aac.c</a>, and <a class="el" href="transcoding_8c-example.html#a11">transcoding.c</a>.</dd>
</dl>
<p>Referenced by <a class="el" href="avio__reading_8c_source.html#l00057">main()</a>, and <a class="el" href="filtering__audio_8c_source.html#l00051">open_input_file()</a>.</p>

</div>
</div>
<a class="anchor" id="ga71091e146791c4d181635485447c2830"></a><!-- doxytag: member="avformat.h::av_demuxer_open" ref="ga71091e146791c4d181635485447c2830" args="(AVFormatContext *ic)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="attributes_8h.html#aa6d076561d3a9eea4729ee632652de02">attribute_deprecated</a> int <a class="el" href="group__lavf__decoding.html#ga71091e146791c4d181635485447c2830">av_demuxer_open</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structAVFormatContext.html">AVFormatContext</a> *&#160;</td>
          <td class="paramname"><em>ic</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

</div>
</div>
<a class="anchor" id="gad42172e27cddafb81096939783b157bb"></a><!-- doxytag: member="avformat.h::avformat_find_stream_info" ref="gad42172e27cddafb81096939783b157bb" args="(AVFormatContext *ic, AVDictionary **options)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int <a class="el" href="group__lavf__decoding.html#gad42172e27cddafb81096939783b157bb">avformat_find_stream_info</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structAVFormatContext.html">AVFormatContext</a> *&#160;</td>
          <td class="paramname"><em>ic</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__lavu__dict.html#ga1d7cc0833bee918994a600556410315f">AVDictionary</a> **&#160;</td>
          <td class="paramname"><em>options</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Read packets of a media file to get stream information. </p>
<p>This is useful for file formats with no headers such as MPEG. This function also computes the real framerate in case of MPEG-2 repeat frame mode. The logical file position is not changed by this function; examined packets may be buffered for later processing.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">ic</td><td>media file handle </td></tr>
    <tr><td class="paramname">options</td><td>If non-NULL, an ic.nb_streams long array of pointers to dictionaries, where i-th member contains options for codec corresponding to i-th stream. On return each dictionary will be filled with options that were not found. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>&gt;=0 if OK, AVERROR_xxx on error</dd></dl>
<dl class="note"><dt><b>Note:</b></dt><dd>this function isn't guaranteed to open all the codecs, so options being non-empty at return is a perfectly normal behavior.</dd></dl>
<dl class="todo"><dt><b><a class="el" href="todo.html#_todo000001">Todo:</a></b></dt><dd>Let the user decide somehow what information is needed so that we do not waste time getting stuff the user does not need. </dd></dl>
<dl><dt><b>Examples: </b></dt><dd><a class="el" href="avio_reading_8c-example.html#a17">avio_reading.c</a>, <a class="el" href="demuxing_decoding_8c-example.html#a77">demuxing_decoding.c</a>, <a class="el" href="filtering_audio_8c-example.html#a17">filtering_audio.c</a>, <a class="el" href="filtering_video_8c-example.html#a18">filtering_video.c</a>, <a class="el" href="remuxing_8c-example.html#a20">remuxing.c</a>, <a class="el" href="transcode_aac_8c-example.html#a7">transcode_aac.c</a>, and <a class="el" href="transcoding_8c-example.html#a14">transcoding.c</a>.</dd>
</dl>
<p>Referenced by <a class="el" href="avio__reading_8c_source.html#l00057">main()</a>, and <a class="el" href="filtering__audio_8c_source.html#l00051">open_input_file()</a>.</p>

</div>
</div>
<a class="anchor" id="ga9edb9ac206ed05dc5baa9d168f31de48"></a><!-- doxytag: member="avformat.h::av_find_program_from_stream" ref="ga9edb9ac206ed05dc5baa9d168f31de48" args="(AVFormatContext *ic, AVProgram *last, int s)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structAVProgram.html">AVProgram</a>* <a class="el" href="group__lavf__decoding.html#ga9edb9ac206ed05dc5baa9d168f31de48">av_find_program_from_stream</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structAVFormatContext.html">AVFormatContext</a> *&#160;</td>
          <td class="paramname"><em>ic</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structAVProgram.html">AVProgram</a> *&#160;</td>
          <td class="paramname"><em>last</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>s</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Find the programs which belong to a given stream. </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">ic</td><td>media file handle </td></tr>
    <tr><td class="paramname">last</td><td>the last found program, the search will start after this program, or from the beginning if it is NULL </td></tr>
    <tr><td class="paramname">s</td><td>stream index </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>the next program which belongs to s, NULL if no program is found or the last program is not among the programs of ic. </dd></dl>

</div>
</div>
<a class="anchor" id="gaa6fa468c922ff5c60a6021dcac09aff9"></a><!-- doxytag: member="avformat.h::av_find_best_stream" ref="gaa6fa468c922ff5c60a6021dcac09aff9" args="(AVFormatContext *ic, enum AVMediaType type, int wanted_stream_nb, int related_stream, AVCodec **decoder_ret, int flags)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int <a class="el" href="group__lavf__decoding.html#gaa6fa468c922ff5c60a6021dcac09aff9">av_find_best_stream</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structAVFormatContext.html">AVFormatContext</a> *&#160;</td>
          <td class="paramname"><em>ic</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">enum <a class="el" href="group__lavu__misc.html#ga9a84bba4713dfced21a1a56163be1f48">AVMediaType</a>&#160;</td>
          <td class="paramname"><em>type</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>wanted_stream_nb</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>related_stream</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structAVCodec.html">AVCodec</a> **&#160;</td>
          <td class="paramname"><em>decoder_ret</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>flags</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Find the "best" stream in the file. </p>
<p>The best stream is determined according to various heuristics as the most likely to be what the user expects. If the decoder parameter is non-NULL, av_find_best_stream will find the default decoder for the stream's codec; streams for which no decoder can be found are ignored.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">ic</td><td>media file handle </td></tr>
    <tr><td class="paramname">type</td><td>stream type: video, audio, subtitles, etc. </td></tr>
    <tr><td class="paramname">wanted_stream_nb</td><td>user-requested stream number, or -1 for automatic selection </td></tr>
    <tr><td class="paramname">related_stream</td><td>try to find a stream related (eg. in the same program) to this one, or -1 if none </td></tr>
    <tr><td class="paramname">decoder_ret</td><td>if non-NULL, returns the decoder for the selected stream </td></tr>
    <tr><td class="paramname">flags</td><td>flags; none are currently defined </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>the non-negative stream number in case of success, AVERROR_STREAM_NOT_FOUND if no stream with the requested type could be found, AVERROR_DECODER_NOT_FOUND if streams were found but no decoder </dd></dl>
<dl class="note"><dt><b>Note:</b></dt><dd>If av_find_best_stream returns successfully and decoder_ret is not NULL, then *decoder_ret is guaranteed to be set to a valid <a class="el" href="structAVCodec.html" title="AVCodec.">AVCodec</a>. </dd></dl>
<dl><dt><b>Examples: </b></dt><dd><a class="el" href="demuxing_decoding_8c-example.html#a56">demuxing_decoding.c</a>, <a class="el" href="filtering_audio_8c-example.html#a18">filtering_audio.c</a>, and <a class="el" href="filtering_video_8c-example.html#a19">filtering_video.c</a>.</dd>
</dl>
<p>Referenced by <a class="el" href="demuxing__decoding_8c_source.html#l00156">open_codec_context()</a>, and <a class="el" href="filtering__audio_8c_source.html#l00051">open_input_file()</a>.</p>

</div>
</div>
<a class="anchor" id="ga4fdb3084415a82e3810de6ee60e46a61"></a><!-- doxytag: member="avformat.h::av_read_frame" ref="ga4fdb3084415a82e3810de6ee60e46a61" args="(AVFormatContext *s, AVPacket *pkt)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int <a class="el" href="group__lavf__decoding.html#ga4fdb3084415a82e3810de6ee60e46a61">av_read_frame</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structAVFormatContext.html">AVFormatContext</a> *&#160;</td>
          <td class="paramname"><em>s</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structAVPacket.html">AVPacket</a> *&#160;</td>
          <td class="paramname"><em>pkt</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Return the next frame of a stream. </p>
<p>This function returns what is stored in the file, and does not validate that what is there are valid frames for the decoder. It will split what is stored in the file into frames and return one for each call. It will not omit invalid data between valid frames so as to give the decoder the maximum information possible for decoding.</p>
<p>If pkt-&gt;buf is NULL, then the packet is valid until the next <a class="el" href="group__lavf__decoding.html#ga4fdb3084415a82e3810de6ee60e46a61" title="Return the next frame of a stream.">av_read_frame()</a> or until <a class="el" href="group__lavf__decoding.html#gae804b99aec044690162b8b9b110236a4" title="Close an opened input AVFormatContext.">avformat_close_input()</a>. Otherwise the packet is valid indefinitely. In both cases the packet must be freed with av_free_packet when it is no longer needed. For video, the packet contains exactly one frame. For audio, it contains an integer number of frames if each frame has a known fixed size (e.g. PCM or ADPCM data). If the audio frames have a variable size (e.g. MPEG audio), then it contains one frame.</p>
<p>pkt-&gt;pts, pkt-&gt;dts and pkt-&gt;duration are always set to correct values in <a class="el" href="structAVStream.html#a9db755451f14e2bf590d4b85d82b32e6" title="This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...">AVStream.time_base</a> units (and guessed if the format cannot provide them). pkt-&gt;pts can be AV_NOPTS_VALUE if the video format has B-frames, so it is better to rely on pkt-&gt;dts if you do not decompress the payload.</p>
<dl class="return"><dt><b>Returns:</b></dt><dd>0 if OK, &lt; 0 on error or end of file </dd></dl>
<dl><dt><b>Examples: </b></dt><dd><a class="el" href="demuxing_decoding_8c-example.html#a88">demuxing_decoding.c</a>, <a class="el" href="filtering_audio_8c-example.html#a75">filtering_audio.c</a>, <a class="el" href="filtering_video_8c-example.html#a68">filtering_video.c</a>, <a class="el" href="remuxing_8c-example.html#a39">remuxing.c</a>, <a class="el" href="transcode_aac_8c-example.html#a59">transcode_aac.c</a>, and <a class="el" href="transcoding_8c-example.html#a118">transcoding.c</a>.</dd>
</dl>
<p>Referenced by <a class="el" href="transcode__aac_8c_source.html#l00303">decode_audio_frame()</a>, and <a class="el" href="demuxing__decoding_8c_source.html#l00226">main()</a>.</p>

</div>
</div>
<a class="anchor" id="gaa23f7619d8d4ea0857065d9979c75ac8"></a><!-- doxytag: member="avformat.h::av_seek_frame" ref="gaa23f7619d8d4ea0857065d9979c75ac8" args="(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int <a class="el" href="group__lavf__decoding.html#gaa23f7619d8d4ea0857065d9979c75ac8">av_seek_frame</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structAVFormatContext.html">AVFormatContext</a> *&#160;</td>
          <td class="paramname"><em>s</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>stream_index</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int64_t&#160;</td>
          <td class="paramname"><em>timestamp</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>flags</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Seek to the keyframe at timestamp. </p>
<p>'timestamp' in 'stream_index'.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">s</td><td>media file handle </td></tr>
    <tr><td class="paramname">stream_index</td><td>If stream_index is (-1), a default stream is selected, and timestamp is automatically converted from AV_TIME_BASE units to the stream specific time_base. </td></tr>
    <tr><td class="paramname">timestamp</td><td>Timestamp in <a class="el" href="structAVStream.html#a9db755451f14e2bf590d4b85d82b32e6" title="This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...">AVStream.time_base</a> units or, if no stream is specified, in AV_TIME_BASE units. </td></tr>
    <tr><td class="paramname">flags</td><td>flags which select direction and seeking mode </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>&gt;= 0 on success </dd></dl>

</div>
</div>
<a class="anchor" id="ga3b40fc8d2fda6992ae6ea2567d71ba30"></a><!-- doxytag: member="avformat.h::avformat_seek_file" ref="ga3b40fc8d2fda6992ae6ea2567d71ba30" args="(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int <a class="el" href="group__lavf__decoding.html#ga3b40fc8d2fda6992ae6ea2567d71ba30">avformat_seek_file</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structAVFormatContext.html">AVFormatContext</a> *&#160;</td>
          <td class="paramname"><em>s</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>stream_index</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int64_t&#160;</td>
          <td class="paramname"><em>min_ts</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int64_t&#160;</td>
          <td class="paramname"><em>ts</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int64_t&#160;</td>
          <td class="paramname"><em>max_ts</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>flags</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Seek to timestamp ts. </p>
<p>Seeking will be done so that the point from which all active streams can be presented successfully will be closest to ts and within min/max_ts. Active streams are all streams that have <a class="el" href="structAVStream.html#a492fcecc45dbbd8da51edd0124e9dd30" title="Selects which packets can be discarded at will and do not need to be demuxed.">AVStream.discard</a> &lt; AVDISCARD_ALL.</p>
<p>If flags contain AVSEEK_FLAG_BYTE, then all timestamps are in bytes and are the file position (this may not be supported by all demuxers). If flags contain AVSEEK_FLAG_FRAME, then all timestamps are in frames in the stream with stream_index (this may not be supported by all demuxers). Otherwise all timestamps are in units of the stream selected by stream_index or if stream_index is -1, in AV_TIME_BASE units. If flags contain AVSEEK_FLAG_ANY, then non-keyframes are treated as keyframes (this may not be supported by all demuxers). If flags contain AVSEEK_FLAG_BACKWARD, it is ignored.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">s</td><td>media file handle </td></tr>
    <tr><td class="paramname">stream_index</td><td>index of the stream which is used as time base reference </td></tr>
    <tr><td class="paramname">min_ts</td><td>smallest acceptable timestamp </td></tr>
    <tr><td class="paramname">ts</td><td>target timestamp </td></tr>
    <tr><td class="paramname">max_ts</td><td>largest acceptable timestamp </td></tr>
    <tr><td class="paramname">flags</td><td>flags </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>&gt;=0 on success, error code otherwise</dd></dl>
<dl class="note"><dt><b>Note:</b></dt><dd>This is part of the new seek API which is still under construction. Thus do not use this yet. It may change at any time, do not expect ABI compatibility yet! </dd></dl>

</div>
</div>
<a class="anchor" id="gaa03a82c5fd4fe3af312d229ca94cd6f3"></a><!-- doxytag: member="avformat.h::avformat_flush" ref="gaa03a82c5fd4fe3af312d229ca94cd6f3" args="(AVFormatContext *s)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int <a class="el" href="group__lavf__decoding.html#gaa03a82c5fd4fe3af312d229ca94cd6f3">avformat_flush</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structAVFormatContext.html">AVFormatContext</a> *&#160;</td>
          <td class="paramname"><em>s</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Discard all internally buffered data. </p>
<p>This can be useful when dealing with discontinuities in the byte stream. Generally works only with formats that can resync. This includes headerless formats like MPEG-TS/TS but should also work with NUT, Ogg and in a limited way AVI for example.</p>
<p>The set of streams, the detected duration, stream parameters and codecs do not change when calling this function. If you want a complete reset, it's better to open a new <a class="el" href="structAVFormatContext.html" title="Format I/O context.">AVFormatContext</a>.</p>
<p>This does not flush the <a class="el" href="structAVIOContext.html" title="Bytestream IO Context.">AVIOContext</a> (s-&gt;pb). If necessary, call avio_flush(s-&gt;pb) before calling this function.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">s</td><td>media file handle </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>&gt;=0 on success, error code otherwise </dd></dl>

</div>
</div>
<a class="anchor" id="ga7494bb63a59e79e9fe88eb1682d4d7b3"></a><!-- doxytag: member="avformat.h::av_read_play" ref="ga7494bb63a59e79e9fe88eb1682d4d7b3" args="(AVFormatContext *s)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int <a class="el" href="group__lavf__decoding.html#ga7494bb63a59e79e9fe88eb1682d4d7b3">av_read_play</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structAVFormatContext.html">AVFormatContext</a> *&#160;</td>
          <td class="paramname"><em>s</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Start playing a network-based stream (e.g. </p>
<p>RTSP stream) at the current position. </p>

</div>
</div>
<a class="anchor" id="ga27db687592d99f25ccf81a3b3ee8da9c"></a><!-- doxytag: member="avformat.h::av_read_pause" ref="ga27db687592d99f25ccf81a3b3ee8da9c" args="(AVFormatContext *s)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int <a class="el" href="group__lavf__decoding.html#ga27db687592d99f25ccf81a3b3ee8da9c">av_read_pause</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structAVFormatContext.html">AVFormatContext</a> *&#160;</td>
          <td class="paramname"><em>s</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Pause a network-based stream (e.g. </p>
<p>RTSP stream).</p>
<p>Use <a class="el" href="group__lavf__decoding.html#ga7494bb63a59e79e9fe88eb1682d4d7b3" title="Start playing a network-based stream (e.g.">av_read_play()</a> to resume it. </p>

</div>
</div>
<a class="anchor" id="gae804b99aec044690162b8b9b110236a4"></a><!-- doxytag: member="avformat.h::avformat_close_input" ref="gae804b99aec044690162b8b9b110236a4" args="(AVFormatContext **s)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="group__lavf__decoding.html#gae804b99aec044690162b8b9b110236a4">avformat_close_input</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structAVFormatContext.html">AVFormatContext</a> **&#160;</td>
          <td class="paramname"><em>s</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Close an opened input <a class="el" href="structAVFormatContext.html" title="Format I/O context.">AVFormatContext</a>. </p>
<p>Free it and all its contents and set *s to NULL. </p>
<dl><dt><b>Examples: </b></dt><dd><a class="el" href="avio_reading_8c-example.html#a19">avio_reading.c</a>, <a class="el" href="demuxing_decoding_8c-example.html#a96">demuxing_decoding.c</a>, <a class="el" href="filtering_audio_8c-example.html#a86">filtering_audio.c</a>, <a class="el" href="filtering_video_8c-example.html#a82">filtering_video.c</a>, <a class="el" href="metadata_8c-example.html#a11">metadata.c</a>, <a class="el" href="remuxing_8c-example.html#a48">remuxing.c</a>, <a class="el" href="transcode_aac_8c-example.html#a8">transcode_aac.c</a>, and <a class="el" href="transcoding_8c-example.html#a128">transcoding.c</a>.</dd>
</dl>
<p>Referenced by <a class="el" href="avio__reading_8c_source.html#l00057">main()</a>, and <a class="el" href="transcode__aac_8c_source.html#l00061">open_input_file()</a>.</p>

</div>
</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>