Skip to content

Instantly share code, notes, and snippets.

View matiaspl's full-sized avatar

Mateusz Starzak matiaspl

  • @Tellyo & Lodz University of Technology
  • Lodz, Poland
View GitHub Profile
@matiaspl
matiaspl / gist:2a5775d13249d21da465e667c59e6d83
Last active May 23, 2016 11:09
Convert a bunch of MTS files from a camera to a sort-of-HTML5-compatible MP4's (while keeping the directory structure)
find /base_folder -name "*.MTS" -exec sh -c 'ffmpeg -n -i "$0" -c:v copy -c:a libfdk_aac "`basename "$0" .MTS`.mp4"' '{}' \;
Note:
The video track in the original MTS files most likely are H.264 High Profile, so they are not mobile-friendly.
Beware that the resulting MP4's may not play on older devices mobile. Change the base_folder according to your needs.
@matiaspl
matiaspl / Stream pi screen framebuffer over http
Last active October 10, 2020 12:27
Live stream pi screen over HTTP (telepi + vlc)
SUDO_UID=1000 ./telepi | export SUDO_UID=1000 cvlc -vvv stream:///dev/stdin --sout '#standard{access=http,mux=ts,dst=:8090}' :demux=h264

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
matiaspl / 5.5"_WaveShare_AMOLED_Pi4.md
Last active April 9, 2021 12:37
5.5" AMOLED WaveShare on Pi4 with FKMS video driver

Derived from screen's EDID (which seems to be wrong - bad checksum) using wxEDID, cvt_modeline_calculator. It's a pitty the embedded controller doesn't have hardware rotation because the screens orientation (portrait) seems to be the source of all evil.

On Windows machines the screen does run in FHD, HD and QHD modes. The resolutions below are only full HD, the "b" mode worked best for me.

export DISPLAY=:0

xrandr --newmode "a" 116.148  1080 1112 1144 1184  1920 1928 1932 1936  -HSync +VSync
xrandr --newmode "b" 137.533440  1080 1112 1144 1184  1920 1928 1932 1936  -HSync +VSync
xrandr --newmode "c" 114.611200  1080 1112 1144 1184  1920 1928 1932 1936  -HSync +VSync
@matiaspl
matiaspl / README_tronxy.md
Last active September 23, 2021 21:31
Tronxy specific gists

All Tronxy stuff goes here

cprsImage.py - 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))

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: 1

@matiaspl
matiaspl / realtek_vid_pid_mac_hacking.md
Last active November 5, 2023 20:29
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
matiaspl / mars400s.md
Last active November 5, 2023 20:57
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.