What you can do is "simulate" the image writing process by filtering with the fps
filter, then using the showinfoffprobe
filter to show the presentation timestamps of the newly generated frames. This means that at 25 fps, the 50th frame (like your 50th image) will have a PTS of 2.00 seconds.
ffmpeg -i input.mp4 -t 10 -filter:v "fps=fps=25, showinfo" -f null -
Will output linesYou do it like this:
[Parsed_showinfo_1 @ 0x7fa4a0f00360] n:50 pts:50 pts_time:2 pos:120440 fmt:yuv420p sar:1/1 s:720x408 i:P iskey:0 type:P checksum:9FBBBDF0 plane_checksum:[B99BD4CA 0768784C 20F270CB] mean:[22 128 128] stdev:[36.6ffprobe 0.0-f 0.2]
You can parse this by using some standard command line tools. Redirect the output from STDERR to STDOUT, filter on the relevant lines, select the eighth column (this is a little… kludgy), then get the value:
ffmpeglavfi -i input"movie=input.mp4 -t 10 -filter:v fps=fps=24,showinfofps=fps=25[out0]" -f null /dev/null 2>&1 | grep pts_time | awk '{print $8}'show_frames |-show_entries cutframe=pkt_pts_time -d:of -f2csv=p=0
Will output:
0
0.04
0.08
0.12
0.16
...
These are the timestamps for each output image. You can actually combine the list of frames and the timestamps:
ls -1 image-*.jpeg > images.txt ffmpegffprobe (the long command from above)-f lavfi -i "movie=input.mp4,fps=fps=25[out0]" -show_frames -show_entries frame=pkt_pts_time -of csv=p=0 > frames.txt paste images.txt frames.txt > combined.txt
Will create a file with:
image-0001.jpeg 0
image-0002.jpeg 0.04
image-0003.jpeg 0.08
image-0004.jpeg 0.12
Note that this may result in extraneous lines if there are too many frames or too many lines of info output. It seems a little inaccurate there.