Skip to content

Instantly share code, notes, and snippets.

View matiaspl's full-sized avatar

Mateusz Starzak matiaspl

  • Amagi & Lodz University of Technology
  • Lodz, Poland
View GitHub Profile
@matiaspl
matiaspl / midi_button.py
Last active October 8, 2024 14:04
Simple MIDI button (foot switch) for the WaveShare RP2040-Zero (Raspbery Pi Pico clone) done using CircuitPython. The idea behind it was to have a super inexpensive physical trigger for use inside vMix, that would allow the sign language interpreter to decide when he/she wants to be visible on screen (a task that would be otherwise delegated to …
import board
import digitalio
import busio
import usb_midi
import adafruit_midi
import neopixel
from adafruit_debouncer import Debouncer
from adafruit_midi.note_off import NoteOff
from adafruit_midi.note_on import NoteOn
@matiaspl
matiaspl / sync_bar_gen.sh
Last active February 21, 2024 13:43
moving bar testcard generator for synchronization testing based on timestamps
#!/bin/bash
fps=25
delay=2
width=640
height=360
bar_width=20
bar_height=$((height / 2))
bar_speed=4
C:\ffmpeg\bin>ffplay -f lavfi testsrc=s=1080x1920:r=60 -vf format=yuv444p,transpose=1,scroll=horizontal=0.005,chromashift=cbh=-50:crh=-50,extractplanes=y+u+v[y][u][v],[y][u][v]hstack
C:\ffmpeg\bin>ffmpeg -f lavfi -i colorchart=patch_size=320x320:r=60:d=10 -vf format=yuv420p,scroll=horizontal=0.005:vertical=0.005 -c:v h264 -cq 0 -f mp4 chroma_motion_patch_test_420.mp4
Endeco's idea:
/etc/udev/rules.d/11-usb-hotplug.rules
ATTRS(idVendor)=="1edb", ATTRS(idProduct)=="be??", RUN+="/etc/udev/atem.sh"
/etc/udev/atem.sh
echo "1edb be55" | tee /sys/bus/usb/drivers/uvcvideo/new_id
echo "1edb be49" | tee /sys/bus/usb/drivers/uvcvideo/new_id
atem mini: be49
@matiaspl
matiaspl / preemphasis.ff
Last active December 13, 2023 13:32
Internet radio to regular radio with 50us (European) preemphasis and RDS using pifmrds - runs fine on RPi1 (sox firfit used as the audio processor)
20 0.000
50 0.001
100 0.004
400 0.068
1000 0.409
2000 1.445
3000 2.761
4000 4.115
5000 5.400
6000 6.583
@matiaspl
matiaspl / checkts.sh
Last active May 14, 2024 13:42
A visual aid for debugging embedded timestamp issues. Shows both SEI and PTS timestamps and some general stream info. Accepts one parameter - the stream/file URL/URI.
#!/bin/sh
#
# This script uses a pretty monospaced/terminal font called iosevka by be5invis (https://github.com/be5invis/Iosevka/)
# Get the TTF file from here: https://git.mmk2410.org/deb/fonts-iosevka/src/branch/main/ttf-unhinted/iosevka-extended.ttf
#
ffplay -loglevel info -sync ext -x 960 -y 540 -vf "drawtext=text='\ SEI\: %{metadata\:timecode\:NOT PRESENT}
PTS\:%{pts\:hms} / %{pict_type}
PTS(UTC)\: %{pts\:gmtime}
INFO\: %{eif\:w\:d}x%{eif\:h\:d} %{e\:1/duration} Hz
@matiaspl
matiaspl / mars400s.md
Last active September 19, 2024 22:33
Hollyland Mars 400S Pro hacking

Architecture:

The TX side act as an access point for both the hardware reciever and the software clients. The video goes over regular 5G AC wifi link.

A simple IP scan shows the following:

192.168.218.10        6e-02-ab-96-f8-b2     dynamic  1 ms (unknown)
192.168.218.100       6c-4d-51-01-fe-74     dynamic  1 ms (Shenzhen Ceres Technology Co., Ltd.)
192.168.218.200       6c-4d-51-02-16-a1     dynamic  2 ms (Shenzhen Ceres Technology Co., Ltd.)

192.168.218.202 6c-4d-51-02-16-a1 dynamic 2 ms (Shenzhen Ceres Technology Co., Ltd.)

@matiaspl
matiaspl / ffmpeg_delay_line.md
Last active November 5, 2023 20:57
FFMPEG based live stream delay line for Decklink

What is it for

FFMPEG based delay loop running in RAM for Blackmagic Decklink video cards. It's useful if you need a "profanity protection" buffer, but could also be used as a poormans instant replay.

How does it work

The idea behind this is to use exploit ffmpeg's concat filter as an intermediate buffer. The length of the delay line is set by the -t parameter before anullsrc in the example below ((or d after smptehdbars).

In my case I wanted PAL interlaced input and output. If you want to use different framerate change the format using the aproppriate -format_code parameter.

@matiaspl
matiaspl / Macrosilicon settings.md
Last active November 5, 2023 20:58
Macrosilicon "can't link" HDMI capture settings

"Can't link" USB capture device - cheap Elgato Camlink alternative built on MS 2109 Macrosilicon chip

EDIT: a more scientific approach to good color reproduction can be found here: http://ciko.io/posts/cheap_usb_hdmi/ and here: https://ciko.io/posts/cheap_usb_hdmi_2/

The "coffee" capture card isn't actually USB 3.0. It only has a blue-colored USB 2.0 connector. So definitely not as advertised. The difference between the black and coffee version is PCB version (1.5 vs 1.6 on coffee one) and - possibly - firmware that exposes modes above 30 fps for 1920x1080 through UVC.

Hovewer judging by the video motion I can say that the 50/60 fps modes in higher resolutions don't work as expected and the stream analysis shows that every 2nd frame is missing.

So in 1080p it always runs 30 fps (while in MJPG mode) or less. Other than that, it's well worth it's money. Good to carry around in your backpack.

@matiaspl
matiaspl / channels_to_scan_table.md
Last active December 17, 2023 00:59
Convert w_scan channels.conf list to a DVBv5 dtv-scan-tables for tvheadend

If you happen to have created a channels.conf after a lengthy scanning process using w_scan:

w_scan -f c -c PL -X -S 1 -v

(in this case a Polish DVB-C scan with SR 6875)

then you can use the following line to create your own scan table (you have to run it as root to write to /usr/share):

cut -d: -f2,3,4,5,6 channels.conf | sort -u | awk -F["/:"] '{ printf "[CHANNEL]\n\tDELIVERY_SYSTEM = DVBC/ANNEX_A\n\tFREQUENCY = %s\n\tSYMBOL_RATE =  %s\n\tINNER_FEC = %s\n\tMODULATION = %s\n\tINVERSION = %s\n\n", $1, $3, $4, $5, $2 }' > /usr/share/dvb/dvb-c/pl-Toya