Skip to content

Instantly share code, notes, and snippets.

@colemar
Last active January 10, 2023 17:59
Show Gist options
  • Save colemar/f6500b1fd57bae6cff89844ffde778cc to your computer and use it in GitHub Desktop.
Save colemar/f6500b1fd57bae6cff89844ffde778cc to your computer and use it in GitHub Desktop.
Print key frame numbers and intervals with ffprobe
ffprobe in.mkv -v error -select_streams v:0 -show_frames -skip_frame nokey -print_format csv | gawk -F, "/^frame/{print $22,$22-n;n=$22}"
ffprobe in.mkv -v error -select_streams v:0 -show_frames -skip_frame nokey -show_entries frame=pts_time -print_format csv | gawk -F, "/^frame/{printf \"%.0f %.0f\n\",$2*23.976,($2-n)*23.976;n=$2}"
ffprobe in.mkv -v error -select_streams v:0 -show_entries packet=pts_time,flags -print_format csv | gawk -F, "$3~\"^K\"{printf \"%.0f %.0f\n\",$2*23.976,($2-n)*23.976;n=$2}"
@colemar
Copy link
Author

colemar commented Jan 10, 2023

Quoting is Windows-like.

  1. Some video streams have $22 (coded_picture_number) always 0: use line 2 or 3 instead of line 1.
  2. 23.976 fps
  3. this seems faster than line 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment