Skip to content

Instantly share code, notes, and snippets.

View igorrendulic's full-sized avatar

Igor Rendulic igorrendulic

View GitHub Profile
@igorrendulic
igorrendulic / ffmpeg_concat.sh
Created September 21, 2020 13:40
FFmpeg concatenate multiple mp4 files in a folder
for f in *.mp4; do echo file $f >> list.txt; done
ffmpeg -f concat -safe 0 -i list.txt -c copy output.mp4
def validate_param(param_name):
"""
Validating OS environment variables
"""
if param_name not in os.environ:
raise ValueError("missing environment variable " + param_name)
return os.environ[param_name]
if __name__ == "__main__":
import tensorflow as tf
from tensorflow.keras.applications.mobilenet_v2 import preprocess_input
from tensorflow.keras.preprocessing.image import img_to_array
from tensorflow.keras.models import load_model
import numpy as np
import imutils
import cv2
import os
import time
import chrysalis
def validate_param(param_name):
"""
Validating OS environment variables
"""
if param_name not in os.environ:
raise ValueError("missing environment variable " + param_name)
return os.environ[param_name]
if __name__ == "__main__":
port = validate_param('chrys_port')
def add_face_markers(frame):
"""
Adding face markers onto a single frame
"""
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
rects = detector(gray, 0)
for (i, rect) in enumerate(rects):
shape = predictor(gray, rect)
shape = face_utils.shape_to_np(shape)
import os
import cv2
import dlib
from imutils import face_utils
import chrysalis
# get the display
os.environ['DISPLAY'] = ":0"
raspivid -t 0 -w 640 -h 480 -fps 15 -hf -b 1000000 -o - | \
> gst-launch-1.0 fdsrc ! h264parse config-interval=2 ! flvmux ! rtmpsink location='rtmp://127.0.0.1/live live=1'
created - A container that has been created (e.g. with docker create) but not started
restarting - A container that is in the process of being restarted
running - A currently running container
paused - A container whose processes have been paused
exited - A container that ran and completed ("stopped" in other contexts, although a created container is technically also "stopped")
dead- A container that the daemon tried and failed to stop (usually due to a busy device or resource used by the container)
# (tested on Ubuntu 18.04 Desktop)
# Stream your own desktop to RTMP
ffmpeg -f x11grab -s 1920x1200 -framerate 15 -i :0.0 -c:v libx264 -preset fast -pix_fmt yuv420p -s 1280x800 -threads 0 -f flv "rtmp://127.0.0.1/live/mystreamkey"
# Broadcasting Examples
ffmpeg -f dshow -i video="Virtual-Camera" -preset ultrafast -vcodec libx264 -tune zerolatency -b 900k -f mpegts udp://127.0.0.1:1234
ffmpeg -f dshow -i video="screen-capture-recorder":audio="Stereo Mix (IDT High Definition" \
@igorrendulic
igorrendulic / MailGun.java
Created December 3, 2017 22:17
MailGun Webhook Signature Validation
private static final key = "mailgun_key"
public static boolean isSignatureValid(String token , long timestamp, String signature) {
try {
Mac hmac = Mac.getInstance("HmacSHA256");
SecretKeySpec signingKey = new SecretKeySpec(key.getBytes(), "HmacSHA256");
hmac.init(signingKey);
String signed = Hex.encodeHexString(hmac.doFinal((timestamp + token).getBytes()));
if (signed.equals(signature)) {
return true;
}