<div dir="ltr">Hi there,<div><br></div><div>I'm trying to learn and also to write a <a href="https://github.com/leandromoreira/ffmpeg-libav-tutorial#learn-ffmpeg-libav-the-hard-way">tutorial</a> about my adventure of learning FFmpeg libav (this amazing library, congrats lol).</div><div><br></div><div>The first part was only to decode some frames and save them into grayscale images but I'm planning to write more about transcoding, remuxing and etc.</div><div><br></div><div>And one of the fundamental parts is how a player will play the video in sync with audio no matter how CPU is loaded or if the system clock is drifting. I can't understand it but I do accept links suggestion to read =), anyway...</div><div><br></div><div><b>What I think I know:</b></div><div><br></div><div>Let's say we have a video with 25 fps and that we're decoding to play 4 frames of it.</div><div><br></div><div>PTS 0 1 2 3 (when it needs to be present, order)</div><div>DTS 0 3 1 1(when it needs to be decoded) (can be different due to B frames and their need to know the future beforehand) </div><div><br></div><div>PTS_TIME FRAME_N x TIMEBASE (when it needs to be played, a value that we can use in some sorta way into seconds)</div><div><br></div><div>First of all, I assume that this information about when you will play a frame nth is in the container, not on the codec, right?</div><div><br></div><div>Now, we're going to stamp a timestamp on each frame, let's say we <a href="https://stackoverflow.com/questions/43333542/what-is-video-timescale-timebase-or-timestamp-in-ffmpeg/43337235?noredirect=1#comment81441809_43337235">chose our timebase</a> to be 1/75 and our PTS to be increased 3 each frame, therefore we'd have these pts_time about when I should play a given frame.</div><div><br></div><div><pre style="margin-top:0px;margin-bottom:1em;padding:5px;border:0px;font-variant-numeric:inherit;font-stretch:inherit;font-size:13px;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;vertical-align:baseline;width:auto;max-height:600px;overflow:auto;background-color:rgb(239,240,241);word-wrap:normal;color:rgb(36,39,41)"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;vertical-align:baseline;white-space:inherit">Timebase = 1/75; Timescale = 75
 Frame        pts           pts_time
   0          0          0 x 1/75 = 0.00
   1          3          3 x 1/75 = 0.04 
   2          6          6 x 1/75 = 0.08
   3          9          9 x 1/75 = 0.12
   ...</code></pre></div><div><br></div><div><b>What I still don't know:</b></div><div><br></div><div>Why did we choose to increase our PTS by 3 and not 5000? Why we pick 1/75 as timebase and not 1/25? what other values can we use? </div><div><br></div><div>Any help will be much appreciated with examples like this one, with only 4 frames building and be justifying why each value and how it's reliable.</div><div><br></div><div>Thanks a lot.</div><div><br></div><div>----------- </div><div><br></div><div>PS: I already read the "Doing a player with less than 1000 lines" part of PTS and DTS but I could not understand it completely.<br></div></div>