Skip to content

Instantly share code, notes, and snippets.

@pabsan-0
Created January 21, 2026 10:58
Show Gist options
  • Select an option

  • Save pabsan-0/bc47673fde632cc7833c491c176acc4a to your computer and use it in GitHub Desktop.

Select an option

Save pabsan-0/bc47673fde632cc7833c491c176acc4a to your computer and use it in GitHub Desktop.
gst-bitrate-parser.awk
#! /usr/bin/env -S awk -f
# ./bitrate_parser.awk
# Highlight parsed values inside GstIdentity chain messages
# Usage:
# gst-launch-1.0 -v foo ! identity silent=false ! bar | ./bitrate_parser.awk
BEGIN {
GREEN = "\033[1;32m"
RESET = "\033[0m"
}
# Print input as usual
{
print
}
# On successfull parse, add a line
/chain/ && /bytes,/ && /duration:/ {
raw = $0
highlighted = raw
bytes = 0
duration = 0.0
# Extract byte count
if (match(raw, /([0-9]+) bytes/, b)) {
bytes = b[1]
}
# Extract duration in seconds
if (match(raw, /duration: 0:00:([0-9.]+)/, d)) {
duration = d[1]
}
if (duration > 0) {
mbps = (bytes * 8) / (duration * 1000000)
} else {
mbps = 0
}
printf "%sParsed: %d bytes / %.4f s = %.2f Mbit per second %s\n", GREEN, bytes, duration, mbps, RESET
printf "%sParsed: %d bytes / %.4f s = %.2f Mbit per second %s\n", GREEN, bytes, duration, mbps, RESET
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment