Skip to content

Instantly share code, notes, and snippets.

@leandromoreira
leandromoreira / nginx.conf
Last active Mar 11, 2021
nginx.conf optmized for http/2 = HTTPS TLS (ssl)
View nginx.conf
# command to generate dhparams.pen
# openssl dhparam -out /etc/nginx/conf.d/dhparams.pem 2048
limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m;
limit_req_zone $binary_remote_addr zone=req_limit_per_ip:10m rate=5r/s;
limit_req_status 444;
limit_conn_status 503;
proxy_cache_path /var/lib/nginx/proxy levels=1:2 keys_zone=backcache:8m max_size=50m;
proxy_cache_key "$scheme$request_method$host$request_uri$is_args$args";
View block_match.m
function [ref_ii, ref_jj, blk_residual] = block_match(blk, frame)
% frame and block dimensions
[H, W] = size(frame);
blk_size = size(blk, 1);
ref_ii = 1;
ref_jj = 1;
err = (255 ^ 2) * (blk_size ^ 2);
blk_residual = 255 * ones(blk_size, blk_size);
View tweet_fake.go
package main
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"fmt"
)
func main() {
View binary_string_from_hex_to_hex.lua
val = "a0192faa0"
function string.pack(str)
local packed_string = "" for i=1, #str, 2 do
local hex_number = tonumber("0x" .. str:sub(i,i) .. str:sub(i+1,i+1))
packed_string = packed_string .. string.char(hex_number)
end return packed_string
end
View docker-ffmpeg-broadcast.sh
ffmpeg -f lavfi -i 'testsrc2=size=1280x720:rate=60,format=yuv420p' \
-f lavfi -i 'sine=frequency=440:sample_rate=48000:beep_factor=4' \
-c:v libx264 -preset ultrafast -tune zerolatency -profile:v high \
-b:v 1400k -bufsize 2800k -x264opts keyint=120:min-keyint=120:scenecut=-1 \
-c:a aac -b:a 32k -f flv rtmp://transcoder/encoder/colorbar
View file.c
struct Codec
{
*int (*encode)(*int);
*int (*decode)(*int);
};
*int h264_encode(int *bytes)
{
// ...
View acl.lua
if ngx.var.remote_addr == "192.168.0.253" then
return ngx.exit(ngx.HTTP_FORBIDDEN)
end
View ffmpeg.sh
ffmpeg -y -hide_banner -re -t 00:00:10 \
-f lavfi -i 'testsrc2=size=1280x720:rate=60,format=yuv420p' \
-filter_complex "[0:v]fps=1,split=2[out1][out2]" \
-map "[out1]" \
-vcodec libwebp \
-lossless 1 \
-preset photo \
-threads 1 \
pixx/thumb%9d.webp \
-map "[out2]" \
View check_signature.sh
ffmpeg -i small_bunny_1080p_60fps.mp4 -i 2s.mkv -filter_complex signature=detectmode=full:nb_inputs=2 -f null -
View faster_vp9_vorbis_webm_dash_ffmpeg.sh
ffmpeg -hide_banner \
-re -f lavfi -i "testsrc2=size=384x216:rate=30,format=yuv420p" \
-f lavfi -i "sine=frequency=220:beep_factor=4:duration=5" -threads 8\
-c:v libvpx-vp9 -deadline realtime -cpu-used 4 -row-mt 1 \
-speed 6 -tile-columns 4 -frame-parallel 1 -threads 8 -static-thresh 0 -max-intra-rate 300 -deadline realtime -lag-in-frames 0 -error-resilient 1 \
-tile-columns 6 -frame-parallel 1 \
-minrate 400k -maxrate 400k -b:v 400k -keyint_min 30 -g 30 \
-c:a libvorbis -b:a 128k \
-window_size 5 -extra_window_size 10 -remove_at_exit 1 -adaptation_sets "id=0,streams=v id=1,streams=a" \
-fflags +genpts \