• Stack Overflow Public questions & answers
  • Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers
  • Talent Build your employer brand
  • Advertising Reach developers & technologists worldwide
  • Labs The future of collective knowledge sharing
  • About the company

Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Get early access and see previews of new features.

ffmpeg.c what are pts and dts ? what does this code block do in ffmpeg.c?

  • In simple terms what are pts and dts values?
  • Why are they important while transcoding [decode-encode] videos ?

What does this code bit do in ffmpeg.c , what is its purpose?

akira's user avatar

3 Answers 3

Those are the decoding time stamp (DTS) and presentation time stamp (PTS). You can find an explanation here inside a tutorial .

So let's say we had a movie, and the frames were displayed like: I B B P. Now, we need to know the information in P before we can display either B frame. Because of this, the frames might be stored like this: I P B B. This is why we have a decoding timestamp and a presentation timestamp on each frame. The decoding timestamp tells us when we need to decode something, and the presentation time stamp tells us when we need to display something. So, in this case, our stream might look like this: PTS: 1 4 2 3 DTS: 1 2 3 4 Stream: I P B B Generally the PTS and DTS will only differ when the stream we are playing has B frames in it.

slhck's user avatar

  • 16 @nirvanaswap that is actually explained fairly well here en.wikipedia.org/wiki/Video_compression_picture_types –  Bart May 20, 2016 at 7:36
  • 2 I still don't understand. The stream has to be displayed as I B B P, But since P ought to come before B, we store it as I P B B. Hence we decode it in the order of 1 2 3 4, that makes sense. But shouldn't we present it in the order of 1 3 4 2? Why is it 1 4 2 3? When we have consecutive B frames, do these B frames take advantage of the I and P frames alone, or do they use the B frames next to each other too? –  nirvanaswap May 20, 2016 at 18:31
  • 5 No, you're displaying in IBBP order. But because the first B relies on the I before it and the B after it, and subsequently the second B frame relies on the final P frame, to be able to display the first B frame you'll already need the information of the P frame. And that's why the stream is IPBB. –  Bart May 20, 2016 at 18:36
  • 4 @neevek Should; ffmpeg complains when it doesn't, eg “ Non-monotonous DTS in output stream ” (in this case they used -c copy ). –  arielCo Jul 24, 2020 at 15:08
  • 7 Note for confused readers like me: I, P, and B are not arbitrary frame names they stand for Intra-coded frame, Predicted frame, Bi-directional predicted frame, respectively. –  ahmetknk Apr 5, 2022 at 23:37

I found it clearer to find information in the answer page rather than a link.

The presentation time (PTS) is the correct one. The frames can be stored out-of-order in the file, and the data may need to be read or written out-of-order to be reconstructed. The DTS time stores this other codec-related ordering.

The pasted code snippet retrieves the PTS of a frame and calculates its duration so as to compute the PTS of the next one.

fuzzyTew's user avatar

B frames are predicted from I and P frames. B frames usually have more errors compared to I and P and hence are not recommended for prediction, though they might be closer in time. There are algorithms in which B is used for prediction but it is from a past B frame and not future B frames.

So in a sequence of I P B1 B2, Decode order is I P B1 B2 and Display order is I B1 B2 P. P is predicted from I, B1 from both I and P, B2 again from I and P.

Obsidian's user avatar

Your Answer

Reminder: Answers generated by artificial intelligence tools are not allowed on Stack Overflow. Learn more

Sign up or log in

Post as a guest.

Required, but never shown

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy .

Not the answer you're looking for? Browse other questions tagged c ffmpeg or ask your own question .

  • Featured on Meta
  • The 2024 Developer Survey Is Live
  • The return of Staging Ground to Stack Overflow
  • The [tax] tag is being burninated
  • Policy: Generative AI (e.g., ChatGPT) is banned

Hot Network Questions

  • Best way to halve 12V battery voltage for 6V device, while still being able to measure the battery level?
  • Divergence of light rays - parallel approximation
  • Converting NEMA 10-30 to 14-30 using ground from adjacent 15 amp receptacle
  • Has ever a country by its own volition refused to join United Nations, or those which havent joined it's because they aren't recognized as such by UN?
  • Using a transistor to digitally press a button
  • Could a 200m diameter asteroid be put into a graveyard orbit and not be noticed by people on the ground?
  • Which program is used in this shot of the movie "The Wrong Woman"
  • Why does the proposed Lunar Crater Radio Telescope suggest an optimal latitude of 20 degrees North?
  • What should I get paid for if I can't work due to circumstances outside of my control?
  • An application of the (100/e)% rule applied to postdocs: moving on from an academic career, perhaps
  • Advice on DIY Adjusting Rheem Water Heater Thermostat
  • I'm looking for a series where there was a civilization in the Mediterranean basin, which got destroyed by the Atlantic breaking in
  • Added an element in forest
  • What is the meaning of the 'ride out the clock'?
  • Who are the mathematicians interested in the history of mathematics?
  • How to Adjust Comparator Output Voltage for Circuit to Work at 3.3V Instead of 5V?
  • A wrong(?) solution to a problem in Turkish university acceptance exam (AYT) made me find something interesting
  • Why do we say "he doesn't know him from Adam"?
  • Projective space as Grassmannian
  • Markov Chains with Changing Number of States
  • Are there any jobs that are forbidden by law to convicted felons?
  • A phrase that means you are indifferent towards the things you are familiar with?
  • How to make Bash remove quotes after parameter expansion?
  • Who owns the moon?

presentation time stamp

Select a language:

Request Services Quote Parts Ordering Request Sales Contact Request Technical Support Need help on product selection? Chat with Sales Available 6:00 AM – 5:00 PM PST

I need calibration for...

Tektronix, Keithley, and Any Brand of Equipment

Tektronix & Keithley Equipment

Any Brand of Equipment

Any Brand of Equipment

Available 6:00 AM – 5:00 PM (PST) Business Days

Contact us with comments, questions, or feedback

Download Manuals, Datasheets, Software and more:

Have feedback? We'd love to hear your thoughts.

Whether positive or negative, your feedback helps us continually improve the Tek.com experience. Let us know if you're having trouble or if we're doing an outstanding job.

Tell us what you think

What is a presentation time stamp (PTS) in MPEG?

a) The time at which a presentation unit is to be available to the viewer, including when the packet should arrive and its destination.

b) A time stamp for vision and sound integrated into PES, transmitted at least every 0.7 sec.

This FAQ Applies to:

No product series

FAQ ID 53241

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Extracting frame timestamp (PTS) and seting it as a file name

I have a video file that lasts 9.3s and was recorded at FPS=10. I would like to use FFMPEG in order to extract frames from this video at arbitrary FPS (e.g. FPS=3). Example command:

But, I need to know which frame from original video FFMPEG has extracted. What I mean by that is, I would like to include in file name a timestamp (e.g. image_00_00:00:00.1.jpg , where 00 is index generated by FFMPEG and 00:00:00.1 is timestamp from which frame was extracted.).

I want to be able to SEEK to that specific timestamp and extract the same frame FFMPEG has generated for me.

By using following command I am able to draw timestamp (pts) on each frame. But, what I need is that timestamp inside filename and I dont know how to get it.

  • video-editing

3 Answers 3

ffmpeg docs suggests this to timestamp ALL frames- ffmpeg -i input.mp4 -f image2 -frame_pts true %d.jpg

If you check out https://ffmpeg.org/ffmpeg-all.html and search for "expand the filename with pts"

but I dont think its the true Presentation Time Stamp, rather its an index.

SuperNoobieAU4000's user avatar

According to the following post , we may use the following command for setting the file to Time Stamps in milliseconds:

ffmpeg -vsync 0 -i video.mkv -r 1000 -f image2 -frame_pts 1 %d.jpg

  • -vsync 0 - Each frame is passed with its timestamp from the demuxer to the muxer.
  • -r 1000 - set the framerate to the output to 1000Hz, for converting the index to milliseconds.
  • -frame_pts 1 - Use current frame pts for filename.

For setting the file name as if the framerate is 3Hz, we have to know the original video framerate.

For example, if the original framerate is 25fps, use the following command:

ffmpeg -vsync 0 -i video.mkv -r 1000*25/3 -f image2 -frame_pts 1 %d.jpg

There is also an option to use setpts filter:

ffmpeg -vsync 0 -i video.mkv -vf "setpts=N*333.333" -f image2 -frame_pts 1 -enc_time_base -1 %d.jpg

The above command sets the filename to count in steps of 333.

Rotem's user avatar

According to the post How can l use ffmpeg to extract frames with a certain fps and scaling this could work:

harrymc's user avatar

You must log in to answer this question.

Hot network questions.

  • Is it rational for heterosexuals to be proud that they were born heterosexual?
  • How often does systemd journal collect/read logs from sources
  • A phrase that means you are indifferent towards the things you are familiar with?
  • An application of the (100/e)% rule applied to postdocs: moving on from an academic career, perhaps
  • I'm looking for a series where there was a civilization in the Mediterranean basin, which got destroyed by the Atlantic breaking in
  • Does it make sense for giants to use clubs or swords when fighting non-giants?
  • Find characters common among all strings
  • How does the Cube of Force interact with teleportation?
  • Regarding upper numbering of ramification groups
  • Divergence of light rays - parallel approximation
  • Invoking Solana Programs
  • Added an element in forest
  • A question about syntactic function of the clause
  • Can LLMs have intention?
  • Mistake in Proof "Every unique factorization domain is a principal ideal domain"
  • Why is the Mean Value Theorem called "Gauss's"?
  • How to remind myself of important matters in the heat of running the game?
  • Do we know how the SpaceX Starship stack handles engine shutdowns?
  • Can 近く modify an adjective to mean "almost adjective"?
  • Am I seeing double? What kind of helicopter is this, and how many blades does it actually have?
  • Where do UBUNTU_CODENAME and / or VERSION_CODENAME come from?
  • What is the frequentist's Bayesian prior for a coin with unknown bias
  • How to refer to a library in an interface?
  • Best way to halve 12V battery voltage for 6V device, while still being able to measure the battery level?

presentation time stamp

Get the Reddit app

/r/videography is a community for both amateurs and professionals working in video, cinema, and television production.

How do you get an exact timestamp of a frame in an mp4 file?

Say you have a video, and you want to calculate the amount of time between events A and B, with the least amount of margin for error possible (I'm talking <10ms; recording videos with high FPS is no issue, neither is changing the video file format).

Based on my questionably accurate research from the last couple hours, 50 FPS does not necessarily mean the amount of time between frames is exactly 20ms; it's more of an average. I'm wondering if, somewhere in an mp4 file, you can find an exact timestamp, to the millisecond, that each frame occurs, and how I would go about finding out what that is.

How to Insert the Current Date/Time in Microsoft PowerPoint

A date can complement your presentation and your handouts. Often neglected, but easily done. We show you how to add a custom date and time in PowerPoint.

Good presentations need little touches. With screen real estate at a premium when it comes to Microsoft PowerPoint presentations, you also need to justify design with functionality.

One of the little touches you can add to your presentation to impress your audience is the display of time and date on a PowerPoint slideshow. It's an essential option if you are using handouts too. Thankfully, this is very easy to accomplish and will make your presentation complete.

Without counting the seconds, let's dive straight into the method.

Add the Current Time and Date to a PowerPoint Slide

First, open your PowerPoint document and get to the View tab on the Ribbon. Choose the Normal view. Select the first slide of the slideshow.

presentation time stamp

Next, click on the Insert tab and go to the Text group. Click on the little Date and Time icon, which gives you options to insert the current date and time into the PowerPoint document.

presentation time stamp

Clicking on the Date and Time icon opens up the Header and Footer dialog box. Using the two tabs (as in the screenshot) we can add the date and time values to our main slides. Likewise, we can add the same details to Notes and Handouts , which we usually print out and give to the audience as reference material.

Insert time and date

The next few steps are pretty simple—choose the date and time format from the drop-down. Selecting a Fixed time acts as a marker that lets you know when the slide was created. It is obviously constant. The Update automatically selection displays a dynamic time that takes the current time from the system clock. The options are the same for the Notes and Handouts tab. (Preferably, don't show the date and time on the title slide).

Remember: Each time you open or print the presentation, PowerPoint will update the date and time. PowerPoint does not continuously update automatically, but only at the start of the slideshow.

Finally, select Apply to All and you are done.

Related: Every Microsoft PowerPoint Keyboard Shortcut for Windows Worth Knowing

Add the Current Time and Date According to the Language

Another useful addition is using date and time formats according to the culture of the audience you are showing the presentation to. Do this if you work in a global company or present to a specific audience. To permanently set your preferred format, implement the following settings.

First, choose File > Options > Language . The Options dialog gives you a lineup of additional languages to edit your document.

Expand the drop-down for Add additional editing languages and select the language(s) of your choice which you want to use for the date and time. Click on Add . Press OK to confirm and exit the PowerPoint file.

Language menu in PowerPoint

Reopen the presentation and position your cursor where you wish to insert the date. Take the usual route of selecting the Insert tab and then clicking on the Date and Time button.

If you are using something like a text box to insert your date and time, you will get a dialog box like this:

Insert time and date

If you are adding the date and time as a footer, then the usual box appears. In both cases, select the date and time format, and pick the language from the drop-down. After you OK the changes, the date and time is entered in the language of the country chosen.

Related: How to Add a Watermark in PowerPoint

Date Your PowerPoint Presentations

Using the date and time with your PowerPoint slides is a simple final step to follow before you give or distribute a presentation.

In case of big events with limited time for each presentation, this will help you manage your time better and make sure you respect the set schedule.

  • USA office +1 (323) 644-4063

Timestamp validation in Transport Stream

 June 14, 2023

Transport stream (TS) is the prevailing media data streaming format in IPTV, DVB/ATSC, and OTT digital TV networks. To generate and playback transport streams, the PTS, DTS, PCR timestamps are utilized. Timestamp validation secures streams from asynchrony between video, audio and other media data. The article focuses on the TS generation process, gives a detailed description of timestamps and methodology of timestamp validation, and includes instructions and screenshots on using a tool that assists with transport stream analysis.

I Multiplexing, or generating a TS

The process can be described as follows.

1. A sequence of compressed video frames, audio samples, closed captions, and teletext pages is encapsulated into PES (Packetized Elementary Stream) packets.

  • PES packets have a variable length that depends on the unit size of the encapsulated data.
  • Each PES packet has at least one timestamp, a PTS (Presentation Time Stamp) and possibly a DTS (Decoding Time Stamp).
  • The PTS indicates the point in time when the corresponding elementary stream (ES), such as a video frame, audio sample, teletext page, or closed caption, should be played back.
  • The DTS (Decoding Time Stamp) indicates the point in time when the video frame should be decoded.
  • The DTS is specified if its value is different from the PTS.

2. Each PES, in turn, is fragmented into TS (transport stream) packets of a fixed size, 188 bytes 1 .

  • If PTS and DTS are time values, there must be a continuous timescale (clock) that contains these values. Such a timescale is formed by PCR (Program Clock Reference) timestamps. They are specified in TS packet headers.

3. Overhead data is also added to the stream, including PSI/SI (Program Specific Information/System Information) tables, SCTE-35, and other data transmitted as part of the TS. Thus, a Transport Stream is a sequence of TS packets (Fig. 1).

presentation time stamp

Fig. 1 – Structure of a Transport Stream

Multiplexers, DVB/ATSC modulators, and OTT packetizers use PTS to synchronize video, audio, and other types of ES. PCR stamps are used for synchronizing the clock between the transmitter and receiver sides. Erroneous or inaccurate timestamps will cause loss of synchronization, delays, and broadcast and playback issues. Timestamp validation is therefore critical for providing high-quality experience. This article focuses on detailed analysis of timestamp validation methodology.

II Validating TS against ETSI TR 101-290

This is a technical specification for the DVB digital TV standard. The standard defines three priorities; timestamp errors are assigned the second priority. The article will explore the errors covered by this standard. A similar specification exists for ATCS. Its approach to timestamp validation differs in that ATCS has more than one threshold value for each error, with the base threshold values identical to those of ETSI TR 101-290. The same approach is employed for validating TS in IPTV and OTT networks. To analyze a captured stream, Elecard Stream Analyzer is used. The application  verifies the stream and displays the errors it detects in a TR 101-290 window. Stream Analyzer helps to ensure the captured stream doesn't contain the following errors (Fig. 2):

presentation time stamp

Fig. 2 – ETSI TR 101-290 errors

PCR Repetition error: detected when the delta between two consecutive PCR values exceeds 40 ms. This error was removed from the specification because experts decided that a threshold value of 40 ms was too strict a requirement and exceeding it did not cause noticeable problems.  PCR discontinuity indicator error: detected when the delta between two consecutive PCR values exceeds 100 ms.  PCR accuracy: indicates PCR positioning accuracy in the selected program via the difference between the expected and actual PCR values. When this difference exceeds a threshold of 500 ns, an error is detected. The more accurate the PCR positioning, the smoother the broadcast. PTS error: occurs when the PTS timestamp repetition period exceeds 700 ms 2 . Consider a video stream with a frame rate of 25, meaning 25 frames are displayed per second. At this rate, the display duration of one frame, or the delta between two consecutive PTS timestamps, is 40 ms. In accordance with the specification, an error is detected when the PTS delta exceeds 700 ms. Although deltas of 41 ms to 700 ms are not considered errors, such prolonged timings indicate absence of data – or, in other words, broadcast gaps. An ETSI TR 101-290 validation is sufficient in most cases but not complete, therefore we proceed to a second stage.

III Visual analysis of timestamp dynamics

Stream Analyzer can display a plot of any integer parameter. To generate a PTS or DTS plot, set the PES checkbox next to the stream of interest in the Explorer window. A list of PES packets is displayed in the central window. Select any packet, then right-click the PTS value in the Property window and choose Add to graphic control. A plot appears in the Graphics window. The steps for generating a PCR plot are similar, but unlike PTS/DTS, PCR timestamps are stored in TS packets. PTS and DTS have 90 kHz resolution. The maximum value is 2 33 – 1, after which a rollover occurs. The values should monotonically increase with each consecutive PES packet. This is true for video frames in a display sequence. In the process of compression, the encoder can reorder frames and create two sequences:

  • a stream sequence, in which the frames were compressed and packed into a stream;
  • a display sequence, in which the frames are presented.

Similar to PTS/DTS, PCR values should monotonically increase. A reference timestamp dynamics plot looks like a straight line (Fig. 3).

presentation time stamp

Fig. 3 – PTS, DTS, and PCR dynamics

Any deviations indicate multiplexing problems, which can be caused by errors in the input stream or incorrect transcoder/multiplexer settings (Fig. 4).

presentation time stamp

Fig. 4 – Non-uniformly increasing PTS timestamps

Consider the OTT case. The player plays back HLS TS chunks sequentially. Each HLS chunk is generated by fragmenting a single TS into multiple separate files. But OTT is just one type of distribution. Therefore, a plot of several sequentially connected HLS chunks should look like a straight line that increases monotonically, with no discontinuities.

IV The absence of errors with regard to ETSI TR 101-290 and linear timing plots do not guarantee a problem-free stream.

Timestamp sequencing needs to be additionally checked. We use the Time Dynamics tool for that:

1. Open the Time Dynamics window, select the PTS only mode and specify Video PID as Base and Audio PID as the Complementary option. The plot shows that total variation between the Video and Audio timestamps is 3 seconds (Fig. 5).

presentation time stamp

Fig. 5 – Variation of Video/Audio PTS timestamps

The greater the PTS variation, the larger the buffer that is needed for data synchronization. The working range is up to 1 second. Exceeding the threshold can lead to these consequences: 

  • an additional delay may occur;
  • the multiplexer, modulator, or packetizer may be unable to generate a valid TS, which will be evident from a jagged broadcast plot and numerous errors in the log;
  • set-top boxes and players may very likely fail to playback the resulting stream correctly, causing a jerky or freezing picture as well as loss of video to audio synchronization.

It is important to note that the plot should not show an upward or downward trend in the delta, because that would indicate a gradual divergence of timestamps, which will definitely lead to the problems mentioned above.

2. Select the PTS only mode, Video PID , and PTS/DTS Dynamics . The plot shows the difference between two consecutive video PTS values. A similar plot can be generated for audio PTS.  This plot visualizes the second-priority PTS error with a threshold of 700 ms (Fig. 6).

presentation time stamp

Fig. 6 – PTS timestamp deltas for Video PID

3. Select the PTS/DTS mode, Video PID , and PTS/DTS Dynamics . The plot shows the difference between PTS and DTS. Under normal conditions, the plot looks like a constant, but slight fluctuations in the upper region are possible. An upward or downward trend indicates the spread of timestamps. Negative deltas correspond to the case in which the DTS value is greater than the PTS, it should not be this way. Both options might lead to synchronization loss on the streaming and receiving sides. (Fig. 7).

presentation time stamp

Fig. 7 – PTS/DTS timestamp deltas for Video PID

4. PCR Dynamics shows the delta between two consecutive PCR values. The threshold values are 40 ms and 100 ms. When these are exceeded, the 2nd-priority PCR Repetition error and PCR discontinuity indicator error are detected, respectively (Fig. 8).

presentation time stamp

Fig. 8 – PCR timestamp deltas for Video PID

5. Select Video PID or Audio PID and PTS/PCR Dynamics. The plot shows the variation between PTS and PCR timestamps for the same point in time. The working range is up to 1 second. In Fig. 9, the delta is 3 seconds, indicating potential problems discussed in point 1 above.

presentation time stamp

Fig. 9 – PTS/PCR timestamp variation for Video PID

6. The Offset/PCR Dynamics plot shows the deltas between the positions of TS packets containing PCR timestamps and indicates how uniformly PCR values are distributed in the stream (Fig. 10). The plot is normally a constant. In practice, upward and downward fluctuations around a certain average value are possible. However, the plot should not show a distinct upward or downward slope (trend).

presentation time stamp

Fig. 10 – Variation of PCR timestamps in the stream

7. PCR Accuracy visualizes the deviation of PCR values from the expected ones for the selected program (Fig. 11). The allowed deviation is ±500 ns, otherwise the second-priority PCR accuracy error is detected. PCR positioning accuracy determines the bitrate of the whole program, therefore DVB/ATSC modulators are extremely sensitive to this error.

presentation time stamp

Fig. 11 – PCR accuracy plot

In this guide, we have explored the main aspects of generation of TS, usage of PTS, DTS, PCR timestamps and their validation. This information will assist you at setting up, maintaining, and troubleshooting IPTV, DVB/ATSC, and OTT digital TV networks.

To analyze timestamps in a captured file, you can use the Stream Analyzer tool included in Elecard StreamEye Studio.  

Request StreamEye Studio Demo

1  A possible implementation using Reed–Solomon codes is not considered in this article.

2  The "Still pictures" case is not considered in this article.

Alexander Kruglov

DTS - Decode Time Stamp

The Decode Time Stamp (DTS) indicates the time at which an access unit should be instantaneously removed from the receiver buffer and decoded.  It differs from the Presentation Time Stamp (PTS) only when picture reordering is used for B pictures .  If DTS is used, PTS must also be provided in the bit stream.

PTS (or DTS) is entered in the bitstream at intervals not exceeding 700 mS.  ATSC further constrains PTS (or DTS) to be inserted at the beginning of each access unit.

Previous: PTS - Presentation Time Stamp

Next: Multiplexed Programs

Up to Timing and Buffer Control

presentation time stamp

Presentation Time Calculator

Characters (including spaces) Characters (without spaces) Words
0 0 0
PT Time 0 sec

PT Time Controller

보다 정확하게 측정하고 싶다면, Customize를 이용하세요.

1. If you scroll right or left, it will calculate PT time according to corresponding speed. 2. You can consider your speech speed and the interval of your PPT pages .

140 WPM (Words Per Minute)

        Slow speech and long verval pause
Slow speech or long verval pause
Average
Fast speech or short verbal pause
Fast speech and short verbal pause

* 매우 천천히 설명하는 발표는 330 CPM까지도 내려갑니다.

1. Read your script for 20 seconds using below stopwatch. 2. Enter the script as much as you just read and it will calculate PT time about total script. 3. If you have PPT, enter the number of PPT pages, the interval of PPT pages and the time to view materials.

2021.03.18. Modified