Skip to content

Instantly share code, notes, and snippets.

@obskyr
obskyr / audacity_chapters_to_ffmpeg_metadata.py
Last active February 9, 2025 09:26
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 September 28, 2024 12:18
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
@obskyr
obskyr / DeselectChapterTags.qml
Last active February 7, 2025 04:52
A QML script for Kid3 that lets you copy/delete audio metadata without chapter markers, or *only* chapter markers without the other metadata.
/**
* \file DeselectChapterTags.qml
* Deselect chapter tag frames to exclude them from operations (e.g. copying
* or deletion).
*
* \b Project: Kid3
* \author Molly Messner
* \date 7 Feb 2025
*
* Copyright (C) 2025 Molly Messner