Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
if [[ $# < 1 ]]; then
echo "usage: $0 input.mov [ffmpeg_opts]..." 1>&2
exit 1
fi
infile="$1"
shift
outfile="${infile%.*}.mp4"
@s4y
s4y / ac3_downmix.txt
Last active January 9, 2019 09:22
Convert mkv to mp4, downmix audio to stereo, keep original audio as second track
for f in *.mkv; do ffmpeg -hide_banner -y -i "$f" -c copy -c:s mov_text -map 0:v -map 0:a -map 0:a -map s -ac:a:0 2 -c:a:0 aac -disposition:a:0 none -disposition:a:1 default -movflags +faststart "${f%.mkv}.mp4" || break; done
@s4y
s4y / 4chan_archive.py
Created November 12, 2018 15:31
4chan thread archiver. Old project; not maintained.
#!/usr/bin/env python3
from urllib.request import urlopen, urlretrieve
from urllib.error import HTTPError
import json
import os
import sys
import time
def update(thread):
youtube-dl -o htba VaL-KP6QOUI && (textargs='borderw=3:font=Arial Black:fontcolor=white:fontsize=40:x=40:y=h-lh-20' ; ffmpeg -ss 38 -t 2.85 -i htba.* -lavfi 'scale=502:-1 , drawtext='"$textargs"':enable=between(t\,1.5\,1.8):text=I , drawtext='"$textargs"':enable=between(t\,1.8\,2.1):text=I RESPECT , drawtext='"$textargs"':enable=gte(t\,2.1):text=I RESPECT WOMEN , split=3[mp4out][s1][s2] ; [s1]palettegen[p], [s2]fifo[s2], [s2][p]paletteuse[gifout]' -map '[mp4out]' -pix_fmt yuv420p -map 0:1 i_respect_women.mp4 -map '[gifout]' i_respect_women.gif)
#include <CoreFoundation/CoreFoundation.h>
#include <IOKit/IOKitLib.h>
typedef struct {
char key[4];
char ignored[24];
uint32_t size;
char ignored2[10];
char cmd;
char ignored3[5];
#include <inttypes.h>
#include <stdlib.h>
typedef enum {
UTF8_OK = 0,
UTF8_ERROR = 4,
} utf8_decode_state_t;
typedef struct {
utf8_decode_state_t state;
@s4y
s4y / maybe_a_shell.c
Last active September 13, 2017 03:21
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int main() {
for (;;) {
char* line = NULL;
size_t cap;
ssize_t sz;
@s4y
s4y / naive_utf8.c
Last active October 15, 2017 09:28
A simple UTF-8 parser that happens to be fast.
#include <inttypes.h>
typedef enum {
UTF8_OK = 0,
UTF8_ERROR = 4,
} utf8_decode_state_t;
typedef struct {
utf8_decode_state_t state;
uint32_t codepoint;

Keybase proof

I hereby claim:

  • I am s4y on github.
  • I am sidney (https://keybase.io/sidney) on keybase.
  • I have a public key ASBp5LKpIbVFwWgRwWcqwjcL3yKJqAQI7sITdhMy16KKrAo

To claim this, I am signing this object:

@s4y
s4y / capture_hls.md
Last active February 3, 2024 12:39
Capture an HLS stream from the beginning with ffmpeg
ffmpeg -live_start_index -99999 -i 'https://….m3u8' -c copy something.ts