Skip to content

Instantly share code, notes, and snippets.

View chausies's full-sized avatar

Ajay Shanker Tripathi chausies

View GitHub Profile
@ndarville
ndarville / webm.md
Last active September 30, 2023 18:56
4chan’s guide to converting GIF to WebM - https://boards.4chan.org/g/res/41212767

Grab ffmpeg from https://www.ffmpeg.org/download.html

It's a command line tool which means you will have to type things with your keyboard instead of clicking on buttons.

The most trivial operation would be converting gifs:

ffmpeg -i your_gif.gif -c:v libvpx -crf 12 -b:v 500K output.webm
  • -crf values can go from 4 to 63. Lower values mean better quality.
  • -b:v is the maximum allowed bitrate. Higher means better quality.
@dsevero
dsevero / rans.py
Last active September 17, 2024 21:00
Asymmetric Numeral Systems (ANS) codec in pure Python
def push(state, symbol, cdf_func, prec):
cdf_low, cdf_high = cdf_func(symbol)
freq = cdf_high - cdf_low
return prec*(state // freq) + (state % freq) + cdf_low
def pop(state, icdf_func, cdf_func, prec):
cdf_value = state % prec
symbol, cdf_low, cdf_high = icdf_func(cdf_value)
freq = cdf_high - cdf_low
return symbol, freq*(state // prec) + cdf_value - cdf_low