The most important job of a container is to record when to show each frame. How to compute time from integer ticks and a timebase.
The most important thing a container adds to codec data is time. The codec bitstream alone can't tell you "at how many seconds this frame should be shown." There are two moments at which time matters: the order and time at which data goes into the decoder (DTS) and the time at which it is shown on screen (PTS).
In Chapter 3 you learned that a B-frame can reference frames both before and after it (Inter prediction). To reference a P-frame that comes later, that P-frame has to be decoded first, so the order stored in the file (decoding order) differs from the order seen on screen (display order).
A simplified example for explanation: a video whose display order is I B B P has the decoding order I P B B. In real files the start point is shifted so that DTS falls in a range similar to PTS, so the numbers can look different.
Without B-frames (as in the low-latency settings of Chapter 15), decoding order and display order are the same, so PTS = DTS. So PTS and DTS differing can be taken as a sign that the file has frame reordering.
A container writes time not as fractional seconds but as integer ticks, and separately records how many seconds one tick is as the timebase (for example, 1/90000). The actual time is time (seconds) = ticks × timebase. The reason for using integers is known to be to keep errors from accumulating. The default unit differs by container.
For example, at timebase 1/90000, the frame interval of 30 fps video is 90000 / 30 = 3000 ticks, and for 29.97 fps (30000/1001) it is 90000 × 1001 / 30000 = 3003 ticks. It matters that the two numbers differ. If you assume the wrong frame rate, the timing drifts further off as ticks pile up, and it shows up as subtitles slowly slipping out of sync (Subtitle Sync Fixer).
A TS file or an edited MP4 may have a first-frame PTS that isn't 0. When you compare two videos or measure VMAF, this difference throws off the frame pairing, so align the start to 0 with setpts=PTS-STARTPTS (Chapter 11).
One more thing: the PTS and DTS in MPEG-TS are 33 bits, so at 90 kHz they wrap around to 0 after about 26.5 hours (2^33 ÷ 90000 ≈ 95,444 seconds). In a very long continuous broadcast, the player has to handle this wrap.
PTS is the time to show on screen; DTS is the time to feed the decoder. They differ when B-frames are present.
A fraction (for example, 1/90000) that says how many seconds one integer tick of a timestamp is.
The number of ticks per second used by an MP4 track. It is the reciprocal of the timebase.
The phenomenon where decoding order and display order differ because of B-frames.
With a timebase of 1/90000, what is the display time of a frame whose PTS value is 270000?