2

My input is a ts file. And I'm trying to use FFmpeg to extract the timestamp (PTS) from the specific frame index. I have tried the following command ( I have replaced the [FRAME_INDEX] with 5), but it was nothing happend:

ffmpeg -i 0.ts -vf "select=gte(n\, [FRAME_INDEX])" -show_entries frame=pkt_pts_time -v quiet -of csv="p=0" -stats -y output.txt

I would like to see the simple output something like: pts:15000 or 15000

Does anyone know how to make the right command? Thanks!!

Aven
  • 21

1 Answers1

1

There's a faster method requiring some piping and a slower method needing no pipes.

Let's say you wanted the PTS for the 15th frame (n=14)

#1 faster method

ffprobe -i 0.ts -of csv=p=0 -select_streams v -read_intervals %+#21 -show_entries packet=pts_time | tail -13 | sort -n | head -7 | tail -1

Since the frames may be out of order due to B-frames, get the readings till frame index n+7. Send the line for frame n + 6 frames before & after for numerical sorting, then extract the middle line.

#2 slower method

ffprobe -f lavfi -i "movie=0.ts,select=eq(n\,14)" -v quiet -of csv=p=0 -show_entries packet=pts_time

If the frame is not too deep into the file, just use the slower method.

Gyan
  • 38,955