Skip to content

Instantly share code, notes, and snippets.

John Allard jhallard

Block or report user

Report or block jhallard

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jhallard
jhallard / dataset_licenses.json
Created Aug 22, 2018
JSON description of the most popular licenses for public datasets and their respective legal ramifications
View dataset_licenses.json
{
"Public Domain": {
"license_name": "Public Domain",
"license_full_name": "Public Domain Mark",
"license_text_url": "https://creativecommons.org/choose/mark/",
"license_attributes": {
"public_domain": true,
"required_attribution_upon_sharing": false,
"requires_share_alike": false,
"commercially_available": true,
@jhallard
jhallard / vis_motion_vectors.sh
Created Jun 22, 2018
Visualize the motion vectors in an h264 encoded video using ffmpeg and vlc (works on OSX)
View vis_motion_vectors.sh
vis_motion_vectors ()
{
if [ "$#" -lt 1 ]; then
echo "Need an input file";
return 1;
else
ffmpeg -y -loglevel error -flags2 +export_mvs -i "$1" -vf codecview=mv=pf+bf+bb /tmp/motion_vectors.mp4;
case "$(uname -s)" in
Linux*) vlc /tmp/motion_vectors.mp4;;
Darwin*) open /tmp/motion_vectors.mp4 -a vlc;;
@jhallard
jhallard / showkeyframes.sh
Created Jun 22, 2018
Show the keyframe indices in a video using ffprobe
View showkeyframes.sh
show_keyframes() {
ffprobe -loglevel error -select_streams v -show_frames -show_entries frame=pict_type -of csv $1 | grep -n I | cut -d ':' -f 1
}
# use like
# $ show_keyframes /tmp/video.mp4
# 1
# 31
# 61
# 91
@jhallard
jhallard / showcolor.sh
Created Jun 22, 2018
Show an R,G,B color from the terminal using python and PIL
View showcolor.sh
showcolor () {
if [ "$#" -lt 3 ]; then
echo "need to give 3 (r,g,b) values"
return 1
fi
python -c "from PIL import Image; Image.new('RGB', (300, 300), ($1, $2, $3)).show()"
}
# use like
# $ showcolor 125 125 200
@jhallard
jhallard / get_format_info.sh
Created Jun 22, 2018
Get the format and encoding information for a video in json format from ffprobe
View get_format_info.sh
get_format_info ()
{
ffprobe -v error -select_streams v:0 -show_entries stream -of default=noprint_wrappers=1 -print_format json "$1"
}
# use like get_format_info /tmp/video.mp4
# $ get_format_info /tmp/video.mp4
{
"programs": [
@jhallard
jhallard / gifencode.sh
Created Jun 22, 2018
How to encode a gif from a video file using ffmpeg at a specific resolution and bitrate
View gifencode.sh
gifenc ()
{
palette="/tmp/palette.png";
filters="fps=$4,scale=$3:-1:flags=lanczos";
ffmpeg -v warning -i $1 -vf "$filters,palettegen" -y $palette;
ffmpeg -v warning -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $2
}
# use like this to encode /tmp/video.mp4 to /tmp/output.gif at 240p and 12fps
# $ gifenc /tmp/video.mp4 /tmp/output.gif 240 12
@jhallard
jhallard / ffconcat.sh
Created Jun 22, 2018
Bash function to concatenate all mp4 video file into a single mp4 file at /tmp/concat
View ffconcat.sh
function vidconcat {
TEMP=$(mktemp /tmp/temporary-file.XXXXXXXX)
for file in "$@"
do
echo "file '$file'" >> $TEMP
done
ffmpeg -loglevel error -hide_banner -f concat -safe 0 -i $TEMP -c copy /tmp/concat.mp4
echo "concat video file is at /tmp/concat.mp4"
rm -f $TEMP
}
@jhallard
jhallard / mockify.py
Created Jun 1, 2017
A simple python script to "mockify" a series of words given either through sys.argv or stdin.
View mockify.py
#!/usr/bin/env python
import sys
import os
import random
def mockify_word(word):
last_cap = False
letters = list(word)
for index in range(0, len(letters)):
upper_chance = 1
You can’t perform that action at this time.