Skip to content

Instantly share code, notes, and snippets.

@obskyr
obskyr / audacity_chapters_to_ffmpeg_metadata.py
Created September 8, 2023 12:23
Convert chapters exported with “Export Labels…” in Audacity to an FFmpeg-compatible metadata text file.
#!/usr/bin/env python3
"""Turn an Audacity "Label Track.txt" into an FFmpeg metadata file."""
import os
import re
import sys
LABEL_LINE_RE = re.compile(r"^(?P<start>[0-9]+(?:.[0-9]+)?)\s+(?P<end>[0-9]+(?:.[0-9]+)?)\s+(?P<title>.*)$")
def to_ffmetadata(labels_s):
@obskyr
obskyr / postfiles-date-image-fix.rb
Last active February 11, 2024 22:30
A workaround for the jekyll-postfiles bug that makes dates at the start of image filenames impossible.
# jekyll-postfiles is lovely, *but* it has a bug that prevents images named
# like posts from being copied. (Or rather, perhaps this is a problem with Jekyll.)
# https://github.com/nhoizey/jekyll-postfiles/issues/1
# This plugin excludes such files from Jekyll's processing, and manually copies
# them over to the _site/ directory. (You are also no longer required to
# manually exclude images from _posts/ or _drafts/ in the config.)
require 'cgi'
EXTENSIONS_NOT_TO_PROCESS = Set[
@obskyr
obskyr / loop_and_fade.py
Last active April 22, 2024 16:51
Loop a video game music file and fade it out, so that it may be listened to properly in music apps.
#!/usr/bin/env python3
"""Loop an audio file to a length that's pleasant to listen to and, fade it out
smoothly, and add trailing silence. Particularly useful to turn looping video
game music into versions that might be more friendly to music-listening apps.
"""
import math
import os
import re