I am currently recording the screen using the below command on Windows 10 system,
ffmpeg.exe -loglevel quiet -f gdigrab -framerate 30 -i desktop -vf mpdecimate,setpts=N/FRAME_RATE/TB -vcodec libx264 -pix_fmt yuv420p -preset slow -crf 0 -threads 0 nodups.mkv
If I record a video for 5 mins, where 4 minutes out of it is idle. The final video obtained is only 1 minute. I want to know the system time corresponding to a specific frame from this 1 minute video.
I tried making use of the command to obtain the frame information from this 1 minute video for 40th frame like : ffmpeg -i nodups.mkv -vf select='eq(n,40)',showinfo -f null -
This outputs me
[Parsed_showinfo_1 @ 000002455fce5dc0] n: 0 pts: 1333 pts_time:1.333 pos: 158601 fmt:yuv420p sar:0/1 s:1600x900 i:P iskey:0 type:P checksum:885ECCE2 plane_checksum:[7D89AD8E DC745BDC 0E23C369] mean:[158 128 128] stdev:[101.7 4.5 4.0
Is there a way to obtain the system time when this frame was captured using FFMPEG ? Any inputs will help.
Use
ffmpeg.exe -f gdigrab -framerate 30 -i desktop -filter_complex settb=1/1000,setpts=RTCTIME/1000-1500000000000,mpdecimate,split[out][ts];[out]setpts=N/FRAME_RATE/TB[out] -map [out] -vcodec libx264 -pix_fmt yuv420p -preset fast -crf 0 -threads 0 nodups.mkv -map [ts] -f mkvtimestamp_v2 nodups.txt -vsync 0
FFmpeg supports a data format called mkvtimestamp_v2 which stores timestamps as text in millisecond precision. So, in the command above, the input timestamps are first converted to millisecond precision with settb, then setpts is used to assign the wallclock time to each frame. But because the text format has a limited precision, we need to reduce the timestamp. That's done by subtracting 15e11. The after the mpdecimate, we split the result, sending one copy for encoding and one for metadata output.
nodups.txt will look like this
# timecode format v2
42721944800
42721944867
42721944933
42721945200
...
For frame no. X, select the Xth entry, add 15e11 (1500000000000) and then convert to a human timestamp from e.g. https://www.epochconverter.com/