Skip to content

Instantly share code, notes, and snippets.

View gyk's full-sized avatar

Yukun Guo gyk

  • Hangzhou, China
  • 16:10 (UTC +08:00)
View GitHub Profile
@gyk
gyk / plots-jl-ffmpeg-deps.md
Created May 30, 2020 08:28
Plots.jl FFmpeg dependencies

Plots.jl/Makie.jl depends on FFmpeg for animation and other fancy features. Judging from the sizes of downloaded artifacts, FFmpeg is no light dependency and possibly takes a long time to install on a poor Internet connection.

 11M  artifacts/6b04ad7f71b1a29adad801f4fdd0d34b3535c638  OpenSSL_jll
1.2M  artifacts/8e4e002b058fdc78ba423fc2a8725d995c8ea9cd  libfdk_aac_jll
4.9M  artifacts/98a8bafb73ec75070d808b170e6aedbfc2ccf474  x264_jll
6.5M  artifacts/9cc8e706ab205ec16daa22d5f4a70711d5ff7885  x265_jll
792K  artifacts/e76f7afca0a2695352d27f767b750e6d997fa6d4  Bzip2_jll
@gyk
gyk / csharp.json
Last active March 10, 2020 09:32
VS Code C# snippet (~/.vscode/extensions/ms-vscode.csharp-$VERSION/snippets/csharp.json) that doesn't put a newline before the opening brace in control blocks.
{
"Attribute using recommended pattern": {
"prefix": "attribute",
"body": [
"[System.AttributeUsage(System.AttributeTargets.${1:All}, Inherited = ${2:false}, AllowMultiple = ${3:true})]",
"sealed class ${4:My}Attribute : System.Attribute",
"{",
" // See the attribute guidelines at",
" // http://go.microsoft.com/fwlink/?LinkId=85236",
" readonly string positionalString;",
@gyk
gyk / README.md
Created July 5, 2019 08:12
Decoded source

Decipher the stupid code posted by this script kiddie on Hacker News (his posts have been downvoted badly).

@gyk
gyk / mp4.c
Created April 15, 2019 09:23
VLC MP4_GetInterleaving, annotated source code
/* Analyzes chunks to find max interleave length
* sets flat flag if no interleaving is in use */
static void MP4_GetInterleaving( demux_t *p_demux, vlc_tick_t *pi_max_contiguous, bool *pb_flat )
{
demux_sys_t *p_sys = p_demux->p_sys;
*pi_max_contiguous = 0;
*pb_flat = true;
/* Find first recorded chunk */
mp4_track_t *tk = NULL;
z = a x + b y + c x y + d
x = 0, z = 1 => b y + d === 1
x = 1, z = y => a + b y + c y + d === y
b y + d === 1 => b == 0, d == 1
a + c y === y - 1 => c == 1, a = -1 => z = -x + x y + 1 => z = 1 + x * (y - 1)

FFmpeg Minimal Build for RTMP Streaming

This tutorial will work you through steps of configuring an FFmpeg build tailored for RTMP streaming on macOS. At first I think of making it support general live streaming, with additional protocols like HLS, but to keep things simple let's stick with RTMP for now. (Anyway, I do include HLS in the protocol list as well as some related bitstream filters but it's untested.)

Goal

The built FFmpeg executable should

@gyk
gyk / rtmpproto.c
Created February 7, 2018 07:21
RTMP digest handshaking in FFmpeg, annotated source code
/// Annotations start with a `///`, just like this line.
/// In `rtmp_open` function:
///
/// rt->state = STATE_START;
/// if (!rt->listen && (ret = rtmp_handshake(s, rt)) < 0)
/// goto fail;
/// if (rt->listen && (ret = rtmp_server_handshake(s, rt)) < 0)
/// goto fail;
///
@gyk
gyk / kafka-consumer-metrics.py
Created December 9, 2016 11:46
Measure Kafka consumer group throughput via Burrow API
"Measure Kafka consumer group throughput via Burrow API"
import json
import urllib2
import time
import sys
import argparse
BURROW_CONSUMER_GROUP_TEMPLATE = 'http://{host}:{port}/v2/kafka/DC/consumer/{consumer}/topic/{topic}'
@gyk
gyk / ST Monad
Last active November 23, 2016 09:11
Haskell STUArray
It's a pita.
@gyk
gyk / runGui.m
Last active August 29, 2015 14:08
Display three images in Matlab
function runGui()
chosenFile = '';
defScalingStr = {'2.0', '3.0', '4.0'};
function btnLoad_click(hObj, event)
[fileName, pathName] = uigetfile({ ...
'*.bmp; *.png', 'Image Files (*.bmp,*.png)'; ...
'*.*', 'All Files (*.*)'}, ...
'Select an image');