Last active
August 29, 2015 14:08
-
-
Save jessetan/7c0532efce9405bf44eb to your computer and use it in GitHub Desktop.
Visualize video bitrate per frame + motion vectors + blocktype
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 | |
| # Overlays a video with visual debug information: the size (in bytes) of each frame and the type of frame, as well as motion vectors and block types (green P, intra purple/red) | |
| # Uses Courier New.ttf as found on OSX (not tested with other font files) | |
| ffprobe -loglevel warning -show_frames $1 | grep -A 20 media_type=video | grep "pkt_size\|pict_type" | sed 'N;s/\n/ /' | sed 's/[^=]*=\([0-9]*\)[^=]*=\(.\)/\1 \2 /' | awk '{ printf("%s %16d\n", $2, $1) }' > $1.frames-sizes | |
| ffmpeg -loglevel info -vismv pf -debug vis_mb_type -i $1 -b:v 10M -vf "[IN]drawtext= text=Frame type \\, size \=\\> bytes \\<=: x=10: y=299: fontfile=Courier New.ttf: fontcolor=#ffffffcc: box=1: boxcolor=#000000dd: fontsize=16, drawtext= fontfile=Courier New.ttf: textfile=$1.frames-sizes: fontcolor=#ffffffdd: x=310-tw: y=300-12*n: fontsize=18, drawtext= text=frame %{n} PTS %{pts}: x=(w-tw)/2: y=h-(2*lh)-100: fontcolor=white: box=1: boxcolor=0x00000099: fontsize=18[OUT]" $1.bitrate+mv+bt.mp4 | |
| sleep 1 | |
| rm -f $1.frames-sizes | |
| open $1.bitrate+mv+bt.mp4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment