Skip to content

Instantly share code, notes, and snippets.

@chertov
chertov / main.go
Created January 1, 2020 04:34
pion h264
package main
import (
"io"
"log"
"os"
"strconv"
"time"
)
@chertov
chertov / wasm.rs
Last active February 16, 2022 17:06
use std::rc::Rc;
use std::cell::RefCell;
use wasm_bindgen::prelude::*;
use wasm_bindgen::{JsValue, JsCast};
use wasm_bindgen::closure::Closure;
use web_sys::{ErrorEvent, MessageEvent, WebSocket, BinaryType};
struct State {
// Camera: 192.168.0.11
// NVR: 192.168.0.12
// NVR discovery packet UDP 192.168.0.12:54432 -> 239.255.255.250:3702
// < ? xml version="1.0" encoding="UTF-8" ? >
// <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:dn="http://www.onvif.org/ver10/network/wsdl" xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery">
// <SOAP-ENV:Header>
// <wsa:MessageID>urn:uuid:36a51323-5566-7788-99aa-2a3f00125c87</wsa:MessageID>
// <wsa:To>urn:schemas-xmlsoap-org:ws:2005:04:discovery</wsa:To>
// automatically generated by the FlatBuffers compiler, do not modify
use std::mem;
use std::cmp::Ordering;
extern crate flatbuffers;
use self::flatbuffers::EndianScalar;
@chertov
chertov / encode.sh
Last active August 8, 2019 11:42
recode to h264 baseline 1920x1080, 25 fps, 25 gop
#!/bin/bash
set -e
bitrate=2048k
fps=25
ffmpeg \
-i input.mkv `# input file` \
-y `# force overwrite output file` \
-ss 00:17:00 `# start time position` \
@chertov
chertov / gpio_monitor.sh
Last active July 2, 2019 08:00
Monitor pins
#!/bin/sh
muxctrl_reg01=004 # 0: SENSOR_RSTN, 1: GPIO0_5
# muxctrl_reg02=008 # 000: GPIO0_6, 001: FLASH_TRIG, 010: SFC_EMMC_BOOT_MODE, 011: SPI1_CSN1, 100: VI_VS_BT1120
muxctrl_reg03=00C # 000: GPIO0_7, 001: SHUTTER_TRIG, 010: SFC_DEVICE_MODE, 100: VI_HS_BT1120
# muxctrl_reg04=010 # 000: GPIO2_0, 001: RMII_CLK, 011: VO_CLK, 100: SDIO1_CCLK_OUT
# muxctrl_reg05=014 # 000: GPIO2_1, 001: RMII_TX_EN, 011: VO_VS, 100: SDIO1_CARD_DETECT
# muxctrl_reg06=018 # 000: GPIO2_2, 001: RMII_TXD0, 011: VO_DATA5, 100: SDIO1_CWPR
# muxctrl_reg07=01C # 000: GPIO2_3, 001: RMII_TXD1, 011: VO_DE, 100: SDIO1_CDATA1
# muxctrl_reg08=020 # 000: GPIO2_4, 001: RMII_RX_DV, 011: VO_DATA7, 100: SDIO1_CDATA0
@chertov
chertov / gist:febb7483dfd33f0847bb0743097aca36
Last active June 28, 2019 07:05
Mikrotik bridge settings
[admin@MikroTik] /interface bridge> export
# jun/28/2019 14:03:43 by RouterOS 6.43.10
# software id = 32JT-U887
#
# model = RBD52G-5HacD2HnD
/interface bridge
add admin-mac=74:4D:28:59:45:C9 arp=proxy-arp auto-mac=no comment=defconf name=bridge
/interface bridge filter
add action=passthrough chain=forward
add action=accept chain=forward comment="web admin" dst-port=80 ip-protocol=tcp mac-protocol=ip out-interface=eoip-tunnel1
import * as fs from 'fs'
import {Buf} from './buf'
class Font {
header: UcsFontHeader
// blocks:
}
class UcsFontHeader {
@chertov
chertov / rtmp.sh
Created June 3, 2019 07:49
ffmpeg youtube live rtmp streaming
#!/bin/sh
set -e
url=rtmp://x.rtmp.youtube.com/live2/
key=m4..-....-....-..fu
ffmpeg \
-re -f lavfi -i testsrc=size=1280x720:rate=30 \
-deinterlace -f lavfi -i anullsrc \
-vcodec libx264 -pix_fmt yuv420p -preset veryfast -r 30 -g 60 -b:v "1000k" \
@chertov
chertov / ubootenv.sh
Last active April 28, 2019 20:35
Parse bootargs and create /etc/fw_env.config
#!/bin/sh
set -e
fw_env_path="/etc/fw_env.config"
bootargs_param="ubootenv"
cmdline=`cat /proc/cmdline`
# for testing
# cmdline="cmdline mem=128M totalmem=192M sensor=imx222 console=ttyAMA0,115200 phyaddru=0 phyaddrd=1 ubootenv=/dev/mtd1,0x00000,0x40000,0x10000 mtdparts=hi_sfc:320K(uboot),192K(ubootenv),6144K(romfs),5120K(romfail),3072K(app),1536K(config)"