Skip to content

Instantly share code, notes, and snippets.

View mauron85's full-sized avatar

Marián Hello mauron85

View GitHub Profile
@mauron85
mauron85 / imgcompare.html
Last active May 15, 2021 08:22
Sliding compare two images
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
* {
box-sizing: border-box;
}
@mauron85
mauron85 / upddns.sh
Last active February 26, 2020 18:39
Easy update DNS via Cloudfare API
# Script from:
# https://postapocalyptech.com/posts/use_cloudflare_ddns/
# adjusted for OpenWrt's ash
# Running curl command and getting your IP address using akamai's service
# Store it in IPADDRNOW variable
IPADDRNOW=$(curl -s http://whatismyip.akamai.com/); \
# Using cat to read stored IP address and then putting it in STOREDIP variable
@mauron85
mauron85 / snapshot-curl.sh
Created November 1, 2019 17:11
Grab camera snapshot and upload to remote server
# Grab snapshot from camera and upload via HTTP post
post_url="https://myserver/upload.php?token="
camera_url="http://192.168.89.146/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=wuuPhkmUCeI9WG7C&user=guest&password=guest123"
start_hour=6
end_hour=18
now=$(date +"%Y-%m-%d-%H-%M-%S")
year=$(echo "$now" | awk -F'-' '{ printf "%s", $1 }')
month=$(echo "$now" | awk -F'-' '{ printf "%s", $2 }')
@mauron85
mauron85 / ffmosaic-iina.sh
Last active December 9, 2019 22:14
Create multicast stream of two ip camera streams side-by-side
#!/bin/bash
#Watch multicast stream of two ip camera streams side-by-side in IINA player
url="udp://239.0.0.1:1234?ttl=13&pkt_size=1317"
ffmpeg -loglevel panic -re \
-i "rtmp://camera1.lan/bcs/channel0_ext.bcs?channel=0&stream=2&user=guest&password=guest123" \
-i "rtmp://camera2.lan/bcs/channel0_ext.bcs?channel=0&stream=2&user=guest&password=guest123" \
-filter_complex "nullsrc=size=1280x480 [base]; \
<?php
$now = time();
$currentYear = date("Y", $now);
$currentMonth = date("m", $now);
$currentDay = date("d", $now);
$currentHour = date('G', $now);
$currentMinute = intval(date('i', $now));
@mauron85
mauron85 / camera.m3u
Last active January 18, 2020 12:49
Camera surveillance using vlc mosaic
#EXTM3U
#EXTINF:0,rtsp://camera1.lan/h264Preview_01_sub
rtsp://guest:guest123@camera1.lan/h264Preview_01_sub
#EXTINF:0,rtsp://camera2.lan/h264Preview_01_sub
rtsp://guest:guest123@camera2.lan/h264Preview_01_sub
#EXTINF:0,rtmp://camera1.lan/bcs/channel0_main.bcs
rtmp://camera1.lan/bcs/channel0_main.bcs?channel=0&stream=0&user=guest&password=guest123
#EXTINF:0,rtmp://camera2.lan/bcs/channel0_main.bcs
rtmp://camera2.lan/bcs/channel0_main.bcs?channel=0&stream=0&user=guest&password=guest123
#EXTINF:0,rtmp://camera1.lan/bcs/channel0_sub.bcs
@mauron85
mauron85 / cam2.php
Last active October 21, 2019 18:02
Serve newest camera jpg snapshot
<?php
define('MIN_HOUR', 6);
define('MAX_HOUR', 18);
define('SNAPSHOT_DIR', 'cam');
define('SNAPSHOT_PATTERN', '/camera[0-9]*_([0-9]+)\.jpg/');
define('SECONDS_TO_CACHE', 660); // 11 minutes
define('PLACEHOLDER_TEXT', 'Stream is over for today. We will be back at 6:00am.');
$now = time();
@mauron85
mauron85 / maintenance.php
Last active October 21, 2019 13:27
Clear camera images older then x seconds
<?php
echo "maintenance...";
define("ONE_DAY_IN_SECONDS", 86400);
function delete_files_older_than($dir, $fileDateMask, $seconds, $now = NULL) {
if (is_dir($dir) === false) {
echo "Dir $dir doesn't exists\n";
return;
ffmpeg -rtsp_transport tcp \
-analyzeduration 100000 -probesize 100000 \
-i rtsp://guest:guest123@192.168.89.146:554/h264Preview_01_main \
-f segment -segment_time 300 -segment_format mpegts \
-reset_timestamps 1 \
-strftime 1 \
-c copy \
-movflags frag_keyframe /mnt/sda2/rec/cam-%Y%m%d-%H%M%S.mp4
@mauron85
mauron85 / create_new_firmware.sh
Created September 8, 2019 19:16 — forked from tuyenld/Original_vs_Mod_Chip.md
2019-02-11-upgrade-flash-chip-tplink-tl-wr840n-4mb-to-8mb
set -e
flash_size_in_MB=8
sysupgrade_OpenWRT="openwrt-18.06.1-ramips-mt76x8-tl-wr840n-v5-squashfs-sysupgrade.bin"
art_file="upload_openwrt_art.bin"
boot_loader="upload_openwrt_mtd0.bin"
sysupgrade_OpenWRT_size=$(wc -c $sysupgrade_OpenWRT | cut -f 1 -d " ")
art_file_size=$(wc -c $art_file | cut -f 1 -d " ")
boot_loader_size=$(wc -c $boot_loader | cut -f 1 -d " ")