Skip to content

Instantly share code, notes, and snippets.


Mateusz Starzak matiaspl

  • @Tellyo & Lodz University of Technology
  • Lodz, Poland
View GitHub Profile
matiaspl / gist:5b797153629e44f4d8986042bcdeef37
Created Jan 13, 2021
Convert w_scan channels.conf list to a DVBv5 dtv-scan-tables for tvheadend
View gist:5b797153629e44f4d8986042bcdeef37
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)
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
View ATEM Pro ISO <> ATEM Streaming

ATEM Pro ISO - nginx-rtmp

[verbose] RTMP_ClientPacket, received: notify 371 bytes
[verbose] (object begin)
[verbose] Property: <Name:           no-name., STRING:	onMetaData>
[verbose] Property: <Name:           no-name., ECMA_ARRAY>
[verbose] (object begin)
[verbose] Property: <Name:                2.1, BOOLEAN:	FALSE>
[verbose] Property: <Name:                3.1, BOOLEAN:	FALSE>
[verbose] Property: <Name:                4.0, BOOLEAN:	FALSE>
matiaspl /
Last active Mar 4, 2021
Link Pi & TBS encoder findings

Link Pi ENC1 / TBS 2603SE encoders

The device is based on a F3520D mainboard -

F3520D with EX2 extension board

The base software is shared among whole line of LinkPi encoders, so ENC-Tiny, ENC1V2, ENC2, ENC5, ENC9 and ENCSH (and TBS) have the same ups and downs.

Personal disclaimer

My personal opinion is that they are great devices, more capable than some of 10x as expensive known-brand encoders, with a well planned and responsive UI. The picture and audio quality is good and everything "just works" (I'm kind of used not to expect much from a $100-ish video devices, so testing ENC1 was an Eureka moment ;) )

matiaspl / Stream pi screen framebuffer over http
Last active Oct 10, 2020
Live stream pi screen over HTTP (telepi + vlc)
View Stream pi screen framebuffer over http
SUDO_UID=1000 ./telepi | export SUDO_UID=1000 cvlc -vvv stream:///dev/stdin --sout '#standard{access=http,mux=ts,dst=:8090}' :demux=h264
matiaspl /
Last active Jan 27, 2021
Tronxy specific gists

All Tronxy stuff goes here - algorithm for creating previews displayed on the Tronxy LCD using M4010 GCODE commands (as seen in the Tronxy Slicer) - base for a Cura postprocessing script/plugin. The function is executed from Tronxys' CuraEngineBackend like this:

if self._screenshotImages and Preferences.getInstance().getValue('cura/enablePreview'):
            startX, startY, endX, endY = cprsImage.detectImageValidRange(self._screenshotImages[1])
            self._scene.gcode_list.insert(0, cprsImage.genImageGcode(self._screenshotImages[0], startX, startY, endX, endY))
matiaspl /
Last active Sep 21, 2020
mpv based vectorscope, waveform monitor and EBU-R128 audio meter

mpv --hwdec="no" --lavfi-complex="[aid1]asplit=3[sv][eb][av];[sv]showvolume=b=4:w=720:h=68[sv-v];[eb]ebur128=video=1:size=720x540:meter=18[eb-v][ao];[av]avectorscope=s=720x540:zoom=1.3:rc=2:gc=200:bc=10:rf=1:gf=8:bf=7[av-v];[sv-v][eb-v][av-v]vstack=3[1c];[vid1]split=4[v][wf][wfc][vs];[wf]waveform=m=1:d=0:r=0:c=7[wf-vus];[wf-vus][v]scale2ref=iw:1220-ih[wf-va][sig];[wf-va]setsar=1[wf-v];[wfc]waveform=m=0:d=0:r=0:c=7,scale=610x610,setsar=1[wfc-v];[vs]vectorscope=m=color3:g=color,scale=610x610,setsar=1[vs-v];[sig][wf-v]vstack[2c];[wfc-v][vs-v]vstack[3c];[1c][2c][3c]hstack=3,scale=1280:-1[vo]" rtmp://server/app/key

matiaspl /
Last active Oct 3, 2020
Replace VID, PID, MAC and channel plan on Realtek USB wifi dongles (e.g. 8811AU)

Why would you even want to do that?

Well, there are some vendor locked dongles out there (I'm looking at you Panasonic!) that use regular off-the-shelf chips but cost a lot of money and not $5 that they're really worth. E.g. there's the AJ-WM50E dual band AC dongle (sold for 160 USD) that you should use with AG-UX180 camera to get wifi CCU running.

I happen to have one such dongle, couple of summer holiday nights and family far, far away. Why not do some hacking then?

The camera is - as far as I can tell - running Linux or a similar system. If so, it has a limited set of tools to get to know what's getting connected to it.

Ultimate goal

Make the not-so-Panasonic dongle resemble the Panasonic one as much as possible, so that the camera just enables it thinking it's legit.

matiaspl /
Last active Aug 22, 2019
Stream RTMP with FFMPEG + BMD Ultrastudio Recorder on OSX (hardware accelerated encoding)

You might ask why would anyone do it in the first place? Well, OBS is the only reasonable free tool for OSX for streaming but it has a flaw which makes it impossible to stream 1080p50/p60 on my i5 MacBook Pro. It works if you disable preview, but then if you can't see the video there's no reason for using OBS ;)

You need ffmpeg-dl from ffmpegdecklink brew package by AMIA Open Source (brew install ffmpegdecklink). It's worth noting that unlike brew's regular ffmpeg this one allows building ffmpeg with additional libraries (e.g. brew install ffmpegdecklink -with-srt in case you need SRT).

/usr/local/opt/ffmpegdecklink/bin/ffmpeg-dl -f decklink -i 'UltraStudio Mini Recorder' -video_input hdmi -format_code Hi50 -audio_input embedded -channels 2 -vf yadif=1 -c:v h264_videotoolbox -profile:v main -b:v 6M -pix_fmt yuv420p -color_range 1 -coder cabac -c:a aac_at -b:a 192k -f flv rtmp://your_server/app/key

What this does is capture 1080i50 signal from HDMI input (use *-vi

View Blackmagic Videohub Smart Control - broken PoE ethernet fix
This device has a design flaw which - if you're not careful enough - might lead to ethertnet socket popping out of the board and taking solder pads along on a bad day. And on a good day you might end up with partially working socket because only a smaller part of the socket will lose contact with the board - power but no link, link but no power, etc.
The bad thing is that the PCB is a multi layered one and you can't really see where the traces go. The good thing however is everyone uses a more or less reference design for ethernet sockets with isolation transformers. And it's easy to figure out what goes where if you know where to look (so I did).
The board utilizes an isolation transfermer U15 (Yuan Dean Scientific 15FB-10BNL) which includes four differential line isolation in a single package (IN and OUT sockets). The IN socket goes to pins 19, 21 (tx) and 22, 24 (rx). OUT socket uses 16, 18 (tx) and 13, 15 (rx). PoE for the input socket goes to the lower bridge rectifier BR2 (Vishay DF01S).
The fix:
matiaspl / hi3521a_console_output.txt
Last active Jan 7, 2021
Hacking a Hi3521 ARBCV100 4x1 multiviewer / seamless switcher (see comments!)
View hi3521a_console_output.txt
U-Boot 2010.06 (Aug 11 2018 - 18:47:37)
Check Flash Memory Controller v100 ... Found
SPI Nor(cs 0) ID: 0xc2 0x20 0x17
Block:64KB Chip:8MB Name:"MX25L6436F"
SPI Nor total size: 8MB
Cannot found a valid SPI Nand Device
In: serial
Out: serial
Err: serial