6

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.

1 Answer 1

6

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.

1
  • 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. Commented Nov 8, 2018 at 18:32

Your Answer

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 or ask your own question.