<font face="arial, helvetica, sans-serif">Hi, </font><div><font face="arial, helvetica, sans-serif">I've made myself one LibAvUtils class with this two functions implemented like this:</font></div><div><pre style="margin-top:0px;margin-bottom:0px">
<font face="arial, helvetica, sans-serif"><span style="color:#800080"><br></span></font></pre><pre style="margin-top:0px;margin-bottom:0px"><font face="arial, helvetica, sans-serif"><span style="color:#800080">int64_t</span><span style="color:#c0c0c0"> </span><span style="color:#800080">LibAvUtils</span>::frameNumberToPts(<span style="color:#800080">uint</span><span style="color:#c0c0c0"> </span>uiFrameNum,<span style="color:#c0c0c0"> </span><span style="color:#808000">float</span><span style="color:#c0c0c0"> </span>fFps)</font></pre>
<pre style="margin-top:0px;margin-bottom:0px"><font face="arial, helvetica, sans-serif">{</font></pre>
<pre style="margin-top:0px;margin-bottom:0px"><font face="arial, helvetica, sans-serif"><span style="color:#c0c0c0"> </span><span style="color:#808000">if</span><span style="color:#c0c0c0"> </span>(fFps<span style="color:#c0c0c0"> </span><=<span style="color:#c0c0c0"> </span><span style="color:#000080">0</span>)<span style="color:#c0c0c0"> </span><span style="color:#808000">return</span><span style="color:#c0c0c0"> </span><span style="color:#000080">0</span>;</font></pre>
<pre style="margin-top:0px;margin-bottom:0px"><font face="arial, helvetica, sans-serif"><span style="color:#c0c0c0"> </span><span style="color:#808000">return</span><span style="color:#c0c0c0"> </span>(<span style="color:#800080">int64_t</span>)uiFrameNum<span style="color:#c0c0c0"> </span>*<span style="color:#c0c0c0"> </span>(<span style="color:#800080">int64_t</span>)(((<span style="color:#808000">float</span>)AV_TIME_BASE)<span style="color:#c0c0c0"> </span>/<span style="color:#c0c0c0"> </span>fFps);</font></pre>
<pre style="margin-top:0px;margin-bottom:0px"><font face="arial, helvetica, sans-serif">}</font></pre>
<pre style="margin-top:0px;margin-bottom:0px"></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#008000"><font face="arial, helvetica, sans-serif">//-----------------------------------------------------------------------------</font></span></pre>
<pre style="margin-top:0px;margin-bottom:0px"></pre>
<pre style="margin-top:0px;margin-bottom:0px"><font face="arial, helvetica, sans-serif"><span style="color:#800080">uint</span><span style="color:#c0c0c0"> </span><span style="color:#800080">LibAvUtils</span>::ptsToFrameNumber(<span style="color:#800080">int64_t</span><span style="color:#c0c0c0"> </span>iPts,<span style="color:#c0c0c0"> </span><span style="color:#808000">float</span><span style="color:#c0c0c0"> </span>fFps)</font></pre>
<pre style="margin-top:0px;margin-bottom:0px"><font face="arial, helvetica, sans-serif">{</font></pre>
<pre style="margin-top:0px;margin-bottom:0px"><font face="arial, helvetica, sans-serif"><span style="color:#c0c0c0"> </span><span style="color:#808000">if</span><span style="color:#c0c0c0"> </span>(fFps<span style="color:#c0c0c0"> </span><=<span style="color:#c0c0c0"> </span><span style="color:#000080">0</span>)<span style="color:#c0c0c0"> </span><span style="color:#808000">return</span><span style="color:#c0c0c0"> </span><span style="color:#000080">0</span>;</font></pre>
<pre style="margin-top:0px;margin-bottom:0px"><font face="arial, helvetica, sans-serif"><span style="color:#c0c0c0"> </span><span style="color:#808000">return</span><span style="color:#c0c0c0"> </span>(<span style="color:#800080">uint</span>)(iPts<span style="color:#c0c0c0"> </span>/<span style="color:#c0c0c0"> </span>(((<span style="color:#808000">float</span>)AV_TIME_BASE)<span style="color:#c0c0c0"> </span>/<span style="color:#c0c0c0"> </span>fFps));</font></pre>
<pre style="margin-top:0px;margin-bottom:0px"><font face="arial, helvetica, sans-serif">}</font></pre><pre style="margin-top:0px;margin-bottom:0px"><font face="arial, helvetica, sans-serif"><br></font></pre><pre style="margin-top:0px;margin-bottom:0px">
You will have to get a good calculation of the FPS by using the time_base from each stream, as they will probably have different units.</pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px">
pts = Presentation Time Stamp or the moment this frame (or first sample of the chunk if it is an audio packet) must be presented.</pre><pre style="margin-top:0px;margin-bottom:0px">dts = Decoding Time Stamp or the moment this frame must be decoded (have a look to Key,P and B frames and you will understand it better)</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px">In some audiostreams, these parameters are not filled enterily, so you'd better use the dts.</pre><pre style="margin-top:0px;margin-bottom:0px">
Any way, I think you should study Dranger's tutorial: <a href="http://dranger.com/ffmpeg/tutorial01.html">http://dranger.com/ffmpeg/tutorial01.html</a>
</pre><div><br></div><div><br></div><div><br></div><br><div class="gmail_quote">On Fri, Jun 29, 2012 at 12:11 PM, Kalileo <span dir="ltr"><<a href="mailto:kalileo@universalx.net" target="_blank">kalileo@universalx.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br>
On Jun 29, 2012, at 15:00 , Jonas Elofsson wrote:<br>
<br>
> Hi,<br>
><br>
> Thanks. I guess this means "pts"?<br>
><br>
> I have no time to check again at the moment, but I did some tests with this as well.<br>
><br>
> The video I tested with reported 25 frames per second and the timebase 1/25. Shouldn't this give me the pts 1,2,3,4... etc for each frame?<br>
<br>
</div>No.<br>
<div class="im"><br>
> Instead i got (if my memory serves me right) 1200, 2400 etc (step of 1200 for each frame). Is there some documentation describing the FFMpeg timebase system?<br>
<br>
</div>Have a look at the famous Dranger player example, there is a nice explanation how its is calculated.<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" target="_blank">http://ffmpeg.org/mailman/listinfo/libav-user</a><br>
</div></div></blockquote></div><br></div>