Answers.Body: <p>FFmpeg will, by default, remove the starting offset. To preserve it, add <code>-copyts</code>. </p>
  
  <p>The description of <code>-vsync 0</code> isn't accurate and was written 8+ years ago: <em>Each frame is passed with its timestamp from the demuxer to the muxer.</em>. Video sync takes effect only once the frame has exited the decoder(+filtergraph) pipeline. But you should keep it to avoid dropping/duplicating frames.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-08T18:32:08.083Z
Answers.Text: yes, this works great, thanks for the hint! I just didn't understand whether I should use `-vsync 0` or not in my command line.
Answers.UserDisplayName: Georgi Stoyanov
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-08T16:49:32.923Z
Answers.LastActivityDate: 2018-11-08T16:49:32.923Z
Answers.UserDisplayName: Gyan
Body: <p>I want to extract the video frames and get the PTS timestamp for each one of them. I have an input MPEG-2 TS file and I prefer to use some open source tool like ffmpeg or something similar. The problem is that when I am using <code>-vf showinfo</code> option it shows me a restamped PTS. This is the command I am using: </p>
  
  <pre><code>ffmpeg -hide_banner -i input.ts -vf showinfo -vsync 0 -start_number 0 fr%05d.jpg &amp;&gt; log.txt
  </code></pre>
  
  <p>So here my result is something similar to:</p>
  
  <pre><code>[Parsed_showinfo_0 @ 0x5629810a2000] n: 435 pts:1593000 pts_time:17.7    pos: 55729780 fmt:yuv420p sar:1/1 s:1920x1080 i:T iskey:0 type:B checksum:27AB3255 plane_checksum:[B27F2CE8 F1689963 59E56BFB] mean:[142 127 129] stdev:[36.5 2.8 4.1]
  [Parsed_showinfo_0 @ 0x5629810a2000] n: 436 pts:1596600 pts_time:17.74   pos: 55690112 fmt:yuv420p sar:1/1 s:1920x1080 i:T iskey:0 type:B checksum:94AD9CBE plane_checksum:[FB0C9721 C477122C 2AA6F362] mean:[142 127 129] stdev:[36.5 2.8 4.1]
  </code></pre>
  
  <p>While when I execute the ffprobe command:</p>
  
  <pre><code>$ ffprobe -i input.ts -show_frames -select_streams v:0 -print_format flat | grep pkt_pts=
  
  frames.frame.435.pkt_pts=4205067450
  frames.frame.436.pkt_pts=4205071050
  </code></pre>
  
  <p>And I need to find out the pkt_pts timestamp on the extracted files possibly with only one command. On top of that, I was checking the SCTE-35 and there I had an offset with 150 frames between the insert intervals. For example according to the PKT_PTS the start and stop frames are 1650 and 2550 which are signaled over SCTE-35 but the actual frames are 1500 2400 when I look only on the extracted frames. </p>
  
Tags: <ffmpeg><mpeg>
Title: How to decode the PTS timestamps and extract the video frames
UserDisplayName: Georgi Stoyanov
ThreadText: # How to decode the PTS timestamps and extract the video frames
  
  (Asked by: username_0 on 2018-11-08)
  
  I want to extract the video frames and get the PTS timestamp for each one of them. I have an input MPEG-2 TS file and I prefer to use some open source tool like ffmpeg or something similar. The problem is that when I am using `-vf showinfo` option it shows me a restamped PTS. This is the command I am using:
  
  ```
  ffmpeg -hide_banner -i input.ts -vf showinfo -vsync 0 -start_number 0 fr%05d.jpg &> log.txt
  
  ```
  
  So here my result is something similar to:
  
  ```
  [Parsed_showinfo_0 @ 0x5629810a2000] n: 435 pts:1593000 pts_time:17.7    pos: 55729780 fmt:yuv420p sar:1/1 s:1920x1080 i:T iskey:0 type:B checksum:27AB3255 plane_checksum:[B27F2CE8 F1689963 59E56BFB] mean:[142 127 129] stdev:[36.5 2.8 4.1]
  [Parsed_showinfo_0 @ 0x5629810a2000] n: 436 pts:1596600 pts_time:17.74   pos: 55690112 fmt:yuv420p sar:1/1 s:1920x1080 i:T iskey:0 type:B checksum:94AD9CBE plane_checksum:[FB0C9721 C477122C 2AA6F362] mean:[142 127 129] stdev:[36.5 2.8 4.1]
  
  ```
  
  While when I execute the ffprobe command:
  
  ```
  $ ffprobe -i input.ts -show_frames -select_streams v:0 -print_format flat | grep pkt_pts=
  
  frames.frame.435.pkt_pts=4205067450
  frames.frame.436.pkt_pts=4205071050
  
  ```
  
  And I need to find out the pkt\_pts timestamp on the extracted files possibly with only one command. On top of that, I was checking the SCTE-35 and there I had an offset with 150 frames between the insert intervals. For example according to the PKT\_PTS the start and stop frames are 1650 and 2550 which are signaled over SCTE-35 but the actual frames are 1500 2400 when I look only on the extracted frames.
  
  **Tags:** ffmpeg, mpeg
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-11-08. Score: 6 | Accepted answer
  
  FFmpeg will, by default, remove the starting offset. To preserve it, add `-copyts`.
  
  The description of `-vsync 0` isn't accurate and was written 8+ years ago: *Each frame is passed with its timestamp from the demuxer to the muxer.*. Video sync takes effect only once the frame has exited the decoder(+filtergraph) pipeline. But you should keep it to avoid dropping/duplicating frames.
  
  > **Comments:**
  > **username_0**: yes, this works great, thanks for the hint! I just didn't understand whether I should use `-vsync 0` or not in my command line.  
  
  ---
  
  