Skip to content

Instantly share code, notes, and snippets.

@greg-randall
greg-randall / avg.py
Last active May 22, 2020 03:32
This is basically a moving average for timelapse images. Make sure you have ImageMagick installed.
#Toss this in a directory of timelapse photos, make sure your files are ordered somehow
#(I've been using unix timestamp for my files), and run it. It'll create a folder called
#'equalized' and it will equalize exposure of all the images, and then it will it will
#average the first 12 images to create output image 1, then it'll average images 2-13
#to create output image 2, and so on until all the images in the folder have been
#averaged. You can change the number of images to average by changing #the average
#variable. Do note, large numbers of images averaged will take _forever_.
import os
from os import path
@greg-randall
greg-randall / gist:6538fcd464023723c54dbb87519666a9
Created November 11, 2019 20:20
Create a blank video with audio, upload to youtube, download the auto generated captions, and then make a transcript. Useful for uploading to youtube to get a free transcript.
Step 1:
ffmpeg -r 1 -loop 1 -i blank_1920x1080.png -i input.wav -r 1 -shortest output.mp4
Step 2:
Upload output.mp4 to youtube. Wait an hour or so for the automatic captions to generate
Step 3:
youtube-dl --write-sub --sub-lang en --skip-download ____Youtube URL from Previous Step____
Step 4:
@greg-randall
greg-randall / gist:2dcd79a769a3d64ad3b3f0de81b9e6bb
Created September 19, 2019 16:48
Remove all metadata from a folder of JPGS
for i in *.jpg; do echo "Processing $i"; exiftool -all= "$i"; done
from: http://www.linux-magazine.com/Online/Blogs/Productivity-Sauce/Remove-EXIF-Metadata-from-Photos-with-exiftool
@greg-randall
greg-randall / delete_all_files_and_folders.php
Last active July 8, 2019 18:59
This tries to delete everything in it's directory and lower -- files and folders. I made this to delete some files with weird names that I couldn't delete over FTP. It will probably delete itself. Be really really sure you want this before you do this.
<pre>
<?php
//ARE YOU SURE YOU WANT TO DELETE EVERYTHING???
$rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('.'));
foreach ($rii as $file) {
echo $file->getPathname() . "<br>";
@greg-randall
greg-randall / size-of-all-directories.php
Last active March 3, 2020 16:43
Prints out a table with all the directories on a web server. Good for chasing down large files during a cleanup. Bytes column is for easy sorting in excel if needed. If you have a lot of files it will be slow.
<?php
$root = '.';
$min_size = 10485760;
/* in bytes.
1 mb = 1048576
10 mb = 10485760
100 mb = 104857600
1 gb = 1048576000
*/
@greg-randall
greg-randall / disk-space.php
Last active July 8, 2019 16:05
Prints out the free space and the total space on a web server.
<?php
$folder = ".";
$free = disk_free_space($folder);
$total = disk_total_space($folder);
echo '<strong>Free Space:</strong> ' . formatBytes($free) . ' (' . round( ($free / $total) * 100 , 1) . '%)<br>';
echo '<strong>Total Space:</strong> ' . formatBytes($total);
@greg-randall
greg-randall / gist:9c3c9ac8589cfac1f1cc959824bd3488
Created May 2, 2019 16:25
dialogue compressor procedure for audition
remove huge peaks if not in speaking areas
favorites: normalize to -0.1db
effects rack slot 2 - hard limiter:
-0.1 maximum amplitude
0 input boost
7 look ahead time
100 release time
@greg-randall
greg-randall / gist:a75d5a0824f609430924c737f6c6244e
Last active May 15, 2021 18:24
Hardcode Subs with FFMPEG - SRT & WebVTT both seem to work.
ffmpeg -i input-without-subs.mp4 -c:v libx264 -vb 20M -c:a copy -vf subtitles=subs.srt output-with-subs.mp4
To change the font size use this one:
ffmpeg -i input.mp4 -c:a copy -c:v libx264 -vb 20M -vf "subtitles=try_1.en_us.srt:force_style='Fontsize=24'" output-with-subs.mp4
To do a two pass encode while hardcoding subs:
ffmpeg -y -i input.mp4 -vf subtitles=subs.srt -c:v libx264 -b:v 5000k -pass 1 -an -f mp4 /dev/null
ffmpeg -y -i input.mp4 -vf subtitles=subs.srt -c:v libx264 -b:v 5000k -pass 2 -c:a copy output.mp4
@greg-randall
greg-randall / thumbs_from_raw.sh
Last active October 19, 2021 20:39
Generate quick small thumbnails from a folder of raw files using DCRAW, ImageMagick, and cjpeg.
#!/bin/bash
if [ ! -d "../thumb" ]
then
mkdir ../thumb
fi
for i in *
do
if [[ $i == *.RWZ ]] || [[ $i == *.RW2 ]] || [[ $i == *.CR2 ]] || [[ $i == *.DNG ]] || [[ $i == *.ARW ]] || [[ $i == *.ERF ]] || [[ $i == *.NRW ]] || [[ $i == *.RAF ]] || [[ $i == *.NEF ]] || [[ $i == *.K25 ]] || [[ $i == *.DNG ]] || [[ $i == *.SRF ]] || [[ $i == *.EIP ]] || [[ $i == *.DCR ]] || [[ $i == *.RAW ]] || [[ $i == *.CRW ]] || [[ $i == *.3FR ]] || [[ $i == *.BAY ]] || [[ $i == *.MEF ]] || [[ $i == *.CS1 ]] || [[ $i == *.KDC ]] || [[ $i == *.ORF ]] || [[ $i == *.ARI ]] || [[ $i == *.SR2 ]] || [[ $i == *.MOS ]] || [[ $i == *.MFW ]] || [[ $i == *.CR3 ]] || [[ $i == *.FFF ]] || [[ $i == *.SRW ]] || [[ $i == *.J6I ]] || [[ $i == *.X3F ]] || [[ $i == *.KC2 ]] || [[ $i == *.RWL ]] || [[ $i == *.MRW ]] || [[ $i == *.PEF ]] || [[ $i == *.IIQ ]] || [[ $i == *.CXI ]] || [[ $i == *.MDC ]]
@greg-randall
greg-randall / index.php
Created October 16, 2018 16:26
PHP Based Title Case, Insert acronyms that are specific to your field/industry
<?php
// Converts to proper case, deals with some edge cases, and capitalizes many medical acronyms.
// this assumes that the title is completely uppercase or completely lowercase that we get no hints
function proper_case($title)
{
// http://www.superheronation.com/2011/08/16/words-that-should-not-be-capitalized-in-titles/#comment-1945084
$lowercase_words = array('a ', 'aboard ', 'about ', 'above ', 'across ', 'after ', 'against ', 'along ', 'amid ', 'among ', 'an ', 'and ', 'anti ', 'around ', 'as ', 'at ', 'before ', 'behind ', 'below ', 'beneath ', 'beside ', 'besides ', 'between ', 'beyond ', 'but ', 'by ', 'concerning ', 'considering ', 'despite ', 'down ', 'during ', 'except ', 'excepting ', 'excluding ', 'following ', 'for ', 'from ', 'in ', 'inside ', 'into ', 'like ', 'minus ', 'near ', 'of ', 'off ', 'on ', 'onto ', 'opposite ', 'or ', 'outside ', 'over ', 'past ', 'per ', 'plus ', 'regarding ', 'round ', 'save ', 'since ', 'so ', 'than ', 'the ', 'through ', 'to ', 'toward ', 'towards ', 'unde