Created
June 5, 2024 04:32
-
-
Save shouya/664762d5fcdd9c66c64f1f6adc290f87 to your computer and use it in GitHub Desktop.
Print group of pictures (GoP) structure of a video file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script prints the gops structure of the video file in terms of frames between keyframes. | |
# | |
# Usage: $0 [--full] <video file> | |
# | |
full() { | |
ffprobe -hide_banner -loglevel error -show_frames "$@" | \ | |
grep -oP 'pict_type=\K.' | \ | |
awk '/I/ {if(a)printf " (%d)\nI", a; a=1} /[PB]/ {a++; printf $0}' | |
} | |
simple() { | |
ffprobe -hide_banner -loglevel error -show_frames "$@" | \ | |
grep -oP 'pict_type=\K.' | \ | |
awk '/I/ {if(a)print a; a=1} /[PB]/ {a++} END {print a}' | |
} | |
if [[ "$1" == "--full" ]]; then | |
shift | |
full "$@" | |
else | |
simple "$@" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment