Skip to content

Instantly share code, notes, and snippets.

View evadecker's full-sized avatar

Eva Decker evadecker

View GitHub Profile
@evadecker
evadecker / framestomp4.sh
Created February 26, 2024 04:42
Convert .png frames to a video
# 1 frame per second
ffmpeg -framerate 1 -pattern_type glob -i '*.png' \
-c:v libx264 -r 30 -pix_fmt yuv420p out.mp4
# 30 frames per second
ffmpeg -framerate 30 -pattern_type glob -i '*.png' \
-i audio.ogg -c:a copy -shortest -c:v libx264 -pix_fmt yuv420p out.mp4
@evadecker
evadecker / convertmp4.sh
Created February 17, 2024 02:34
Convert .mov to .mp4
ffmpeg -i "input.mov" "output.mp4"
@evadecker
evadecker / generateposter.sh
Last active February 17, 2024 03:27
Generate poster .png image from first frame of .mp4
# Generate a poster from the first frame
ffmpeg -i input.mp4 -vframes 1 output.png
# Generate a poster from the frame starting at 5 seconds
ffmpeg -i input.mp4 -ss 00:00:05 -vframes 1 output.png
@evadecker
evadecker / increasevolume.sh
Created November 23, 2018 21:19
Increase the volume of a sample
# Change 10dB to the amount you'd like to bump the volume.
# You can use negative values to decrease volume, too.
ffmpeg -i input.wav -filter:a "volume=10dB" output.wav
@evadecker
evadecker / trimsilence.sh
Created November 23, 2018 21:16
Trim start/end silence on audio files
# This will overwrite the original file! Be careful!
# I use ZSH. If you use Bash, the syntax will be different here.
# Options:
# Change -20dB to whatever threshold you consider "silent" to be.
for file in *.mp3; ffmpeg -y -i $file -af silenceremove=1:0:-20dB ${file%.mp3}.mp3
@evadecker
evadecker / audiosprite.sh
Last active November 23, 2018 21:14
Generate an audiosprite for use with Howler
# For use with https://github.com/tonistiigi/audiosprite
# and https://github.com/goldfire/howler.js/
# Replace outputNameWithoutExtension with whatever you want.
#
# *.mp3 will find all mp3 files in the current directory.
#
# * will find ALL files in the current directory, allowing you
# to mix wav, mp3, etc into the final combined sprite.
@evadecker
evadecker / bitrate.sh
Created November 23, 2018 21:11
Lower bitrate of an mp3 file
# Command to lower the bitrate of an mp3 using FFMPEG
# Options:
# Low: 96k
# Medium (Radio quality): 128k
# Medium-High (CD quality): 192k
# High: 320k
# "Converting an MP3 to a higher bit rate does not add any more
# audio information to the file, so the sound quality does not
@evadecker
evadecker / audioshift.sh
Last active November 23, 2018 21:05
Shift audio pitch up or down
# Calculations courtesy of http://www.microsoftbob.com/post/Adjusting-Pitch-for-MP3-Files-with-FFmpeg
# Up half step
ffmpeg -i input.wav -filter:a "asetrate=r=46722.3224612449211671764955071340,atempo=0.94387431268169349664191315" output_up_halfstep.wav
# Up whole step
ffmpeg -i input.wav -filter:a "asetrate=r=49500.5763304433484812188074908520,atempo=0.8908987181403393047402262055" output_up_wholestep.wav
# Up 3 half steps
ffmpeg -i input.wav -filter:a "asetrate=r=52444.0337716199990422417487017170,atempo=0.84089641525371454303112547623321" output_up_3halfsteps.wav
@evadecker
evadecker / index.html
Created November 20, 2018 06:07
Synth
<div id="synth">
<svg width="100%" viewBox="0 0 270 152" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="synth-base">
<rect id="Shadow" fill-opacity="0.1" fill="#000000" x="0" y="4" width="270" height="148" rx="12"></rect>
<rect fill="#40445E" x="0" y="0" width="270" height="148" rx="12"></rect>
<path d="M0,9.99832468 C0,4.47640243 4.47593818,0 10,0 L20,0 L20,148 L10,148 C4.4771525,148 0,143.530333 0,138.001675 L0,9.99832468 Z" id="Left-Endcap" fill="#272B43"></path>
<path d="M250,0 L260,0 C265.522847,0 270,4.46966749 270,9.99832468 L270,138.001675 C270,143.523598 265.524062,148 260,148 L250,148 L250,0 Z" id="Right-Endcap" fill="#272B43"></path>
</g>
<g id="synth-keys" transform="translate(24.000000, 60.000000)">
@evadecker
evadecker / tiffjoin.py
Last active August 18, 2017 02:08
Join normal and retina images into a multi-page TIFF.
import os
exportdir = 'new'
# Create a 'new' directory to put merged files
os.system('mkdir ' + exportdir)
# Iterate over files and combine using tiffcp
for file in os.listdir('.'):
if file.endswith('@2x.tiff'):