Get Video Keyframe Interval (ffprobe)



Published: 2017-07-19 12:15:31 +0000
Categories: BASH,

Language

BASH

Description

The command will output where keyframes exist within the input video. Useful to know when trying to segment for HLS etc, or troubleshoot playback issues

Snippet

# Print Timestamps
ffprobe -show_frames -select_streams v:0 -print_format csv $VIDEO_FILE 2> /dev/null | awk -F ',' '{ if ($4 > 0) print $6; }'

# Calculate the durations between keyframes and their distribution
ffprobe -show_frames -select_streams v:0 -print_format csv $VIDEO_FILE 2> /dev/null \
    | awk -F ',' '{ if ($4 > 0) print $6; }' \
    | awk 'NR>1{print $1-p} {p=$1}'\
    | sort | uniq -c

# Getting Keyframe positions by frame number
ffprobe -show_frames -select_streams v:0 -print_format csv $VIDEO_FILE 2> /dev/null | awk -F ',' '{ if ($4 > 0) print NR; }'

# Calculating the Keyframe interval by framecount
ffprobe -show_frames -select_streams v:0 -print_format csv $VIDEO_FILE 2> /dev/null \
    | awk -F ',' '{ if ($4 > 0) print NR; }'  \
    | awk 'NR>1{print $1-p} {p=$1}'\
    | sort | uniq -c

# Getting the average framerate
ffprobe -v 0 -of compact=p=0 -select_streams 0 -show_entries stream=r_frame_rate $VIDEO_FILE | grep -o -P "[0-9,/]+" | bc

Keywords

ffprobe, media, framerate, i-frame, keyframe, interval, statistics,

Latest Posts

Urldecode string (LUA)
FFMPEG Convert YUV444p to YUV420p (BASH)
Forcing FFMPEG to honour segment length in HLS Stream Creator (BASH)
Force CURL to place request to a specific IP (BASH)
Set a variable only if it is undefined (Javascript)
Ignore query string with Nginx caching proxy (NGinx)
Get breakdown of UK and non-UK votes for a Parliamentary Petition (Python)
Decompress Mozilla Firefox jsonlz4 bookmark backup files (Python)
Setting Git author details for a single repo (Git)
Checking Virtual Machine Resource Allocations with Libvirt (BASH)

Copyright © 2019 Ben Tasker | Sitemap | Privacy Policy
Available at snippets.bentasker.co.uk and snippets.6zdgh5a5e6zpchdz.onion