Skip to content

Instantly share code, notes, and snippets.

@leandromoreira
leandromoreira / nginx.conf
Last active November 29, 2023 11:39
nginx.conf optmized for http/2 = HTTPS TLS (ssl)
# 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";
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
struct Codec
{
*int (*encode)(*int);
*int (*decode)(*int);
};
*int h264_encode(int *bytes)
{
// ...
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);
% it creates a simple gray image (4x4)
I = [255, 255, 30, 100
255, 50, 90, 20
70, 70, 20, 10
100, 20, 10, 0];
% it converts it to grayscale
I = mat2gray(I);
% shows it
imshow(I);
package main
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"fmt"
)
func main() {
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
if ngx.var.remote_addr == "192.168.0.253" then
return ngx.exit(ngx.HTTP_FORBIDDEN)
end
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]" \
ffmpeg -i small_bunny_1080p_60fps.mp4 -i 2s.mkv -filter_complex signature=detectmode=full:nb_inputs=2 -f null -