I am attempting to extract frames with their timestamps from videos using the command line, but I am struggling to relate both the output of the showinfo filter to the actual frames outputted by the command, and the corresponding output file names from the
-frame_pts option. I am extracting 1 frame per second using the following command:
ffmpeg -y -i GOPR3427.MP4 -r 1 -vf showinfo -copyts -s 640x480 -frame_pts 1 \ GOPR3427.MP4-frames/%d.jpg > GOPR3427.MP4-frames/output.txt 2>&1 -hide_banner
This output a series of jpg's from 0 -11, for example, 0.jpg, 1.jpg, 2.jpg etc. According to FFprobe, my video has a duration of 10.581333
My understanding from this superuser answer to the question Extract I-frames to images quickly is that the
-frame_pts sets the numeral portion of the output image filename to represent the timestamp based on the frame rate. So in my example, the frame rate is 50/1 and according to the logic in the answer, I should be able to calculate the
pts_time as follows 3.jpg would be: 3/50 = 0.06
If I check in the output.txt file I can see a line that reads
[Parsed_showinfo_0 @ 0x563d384a5080] n:3 pts:5400 pts_time:0.06 pos:451041 fmt:yuvj420p sar:1/1 s:1920x1080 i:P iskey:0 type:P checksum:D56E24BB plane_checksum:[A1E26C9D C6294D84 DB726A8B] mean:[131 145 104 ] stdev:[27.4 23.2 20.8 ]
This corresponds with the calculation above, however, my output.txt contains 528 parsed line entries like the one above, yet my command outputs only 11 files, using the logic above the file named 11.jpg would be a
pts_time of 0.22, this doesn’t represent 1 x frame every second.
Can anyone help tie this together for me, at the moment I am struggling to understand the outputs here?