Skip to content

Instantly share code, notes, and snippets.

@jessetan
jessetan / Grafana-InfluxDB-internals.json
Last active April 7, 2016 11:52
Grafana 2.6 Dashboard for InfluxDB 0.10.3 _internal database
{
"id": 7,
"title": "InfluxDB internals",
"originalTitle": "InfluxDB internals",
"tags": [],
"style": "dark",
"timezone": "browser",
"editable": true,
"hideControls": false,
"sharedCrosshair": false,
@jessetan
jessetan / vidsidebyside.sh
Created December 29, 2015 13:25
Place two videos side by side in new video using ffmpeg
#!/bin/bash
ffmpeg -i test1.mp4 -vf "[in] scale=iw/2:ih/2, pad=2*iw:ih [left]; movie=test2.mp4, scale=iw/2:ih/2 [right]; [left][right] overlay=main_w/2:0 [out]" Output.mp4
@jessetan
jessetan / stacktrace.cc
Last active October 1, 2021 18:03
Print callstack trace from c++
// Add #include <execinfo.h> to includes
// START STACK TRACE
void* tracePtrs[100];
int count = backtrace( tracePtrs, 100 );
char** funcNames = backtrace_symbols( tracePtrs, count );
// Print the stack trace
printf("Stack trace:\n");
for( int ii = 0; ii < count; ii++) {
@jessetan
jessetan / calcavgbitrate.sh
Last active October 25, 2023 13:43
Calculates average bitrate of a video file by looking at size of each frame. Uses ffprobe, sed and awk
#!/bin/bash
# Calculates average bitrate of a video file by looking at size of each frame. Uses ffprobe, sed and awk
if [ -z "$1" ]; then
echo "Error: No input video file specified"
exit 1
fi
echo "Estimating bitrate statistics for $1..." ; ffprobe -show_frames -loglevel error $1 | \
@jessetan
jessetan / secondsToSMPTE.js
Last active April 6, 2023 21:11
Convert seconds to SMPTE timecode JSON object and string
/** Convert seconds to SMPTE timecode JSON object, example input is html video.currentTime */
function secondsToSMPTE(seconds, framerate) {
var f = Math.floor((seconds % 1) * framerate);
var s = Math.floor(seconds);
var m = Math.floor(s / 60);
var h = Math.floor(m / 60);
m = m % 60;
s = s % 60;
return {h: h, m: m, s: s, f: f};
@jessetan
jessetan / visbitrate.sh
Last active August 29, 2015 14:08
Visualize video bitrate per frame + motion vectors + blocktype
#!/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