Skip to content

Instantly share code, notes, and snippets.

@hekmon
hekmon / mkvattachfonts.sh
Created August 6, 2024 12:49
Analyze SubStationAlpha subtitles (ASS) within a MKV file to extract the used font and add them back to the MKV file as attachments
#!/usr/bin/env bash
set -e
FONTSDIR="/fonts/dir/change/me"
attachment_exists() {
local mkv_file="$1"
local attachment_name="$2"
mkvmerge -i "$mkv_file" | grep -q -E "^Attachment ID [0-9]+: .+ file name '$attachment_name'$"
@hekmon
hekmon / probe_gop.sh
Created July 25, 2024 18:03
Count GOP (Group Of Pictures) and their frames (I, P and B frames) within a video file
#!/usr/bin/env bash
set -e
GOP=0
iframes=0
totiframes=0
pframes=0
totpframes=0
bframes=0
@hekmon
hekmon / ffmpeg_vmaf.sh
Last active September 14, 2024 12:31
ffmpeg w vmaf
docker run -ti --name ffmpeg_vmaf nvidia/cuda:12.5.1-devel-ubuntu24.04 /bin/bash
# cuda 12.6.0 and 12.6.1 produce a ffmpeg binary that segfault when using vmaf_cuda filter within ffmpeg
# INSIDE THE CONTAINER
## VMAF
apt update && apt upgrade -y
apt install -y libopenjp2-7-dev ninja-build cmake git python3-full python3-pip nasm xxd pkg-config curl unzip
git clone https://github.com/Netflix/vmaf.git && cd vmaf && git checkout master && cd ..
@hekmon
hekmon / README.md
Last active July 21, 2025 16:01
EDF Time based Tempo prices

Simply include the file within your configuration.yaml file like this:

# ...
template: !include templates.yaml
# ...

You will need prices input number from this gist and the RTE Tempo extension.

@hekmon
hekmon / README.md
Last active August 21, 2025 13:30
EDF Tarif Bleu prices within Home Assistant

Simply include the file within your configuration.yaml file like this:

# ...
input_number: !include input_numbers.yaml
# ...

Restart your Home Assistant to update the values (reloading YAML will not be enough).

@hekmon
hekmon / README.md
Last active June 26, 2022 19:55
Linux TCP tuning for CIFS over WAN/VPN

TCP Tuning for CIFS over VPN/WAN

If your bandwitch allows it, this will enable stutter free streaming of 4K remuxes over CIFS/VPN/WAN.

Install

sudo wget 'https://gist.github.com/hekmon/78b30ae8cb76b076d01bddaf79b2c693/raw/d063a1bee463745ce2b8ded41475b5d9c179c7b4/sysctl.conf' -O '/etc/sysctl.d/90-CIFS_over_WAN.conf'
sudo sysctl -p
@hekmon
hekmon / awscliv2.sh
Last active May 23, 2023 16:02
AWS CLI v2 - install and update on a bash based linux system
#!/bin/bash -e
# https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-linux.html#cliv2-linux-install
# https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-completion.html
echo "* Switching to tmp folder..."
cd "$(mktemp -d)"
echo
echo "* Downloading the AWS cli..."
wget -q "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -O awscliv2.zip
@hekmon
hekmon / chroot.sh
Last active September 7, 2020 11:04
Quick live rescue chroot script
#!/bin/bash -e
ROOT=$1
HOME=$2
if [ ! -b "$ROOT" ]
then
echo "First parameter (/) is not a block device" >&2
exit 1
fi
@hekmon
hekmon / dp_autostop.go
Last active February 1, 2021 17:39
Golang "autostop" design pattern: controller with clean context stop (avoid Start() Stop() workflow)
package foobar
import (
"context"
"errors"
)
// Controller is a base pattern controller
type Controller struct {
ctx context.Context