Skip to content

Instantly share code, notes, and snippets.

View safijari's full-sized avatar

Jari safijari

View GitHub Profile
@safijari
safijari / capture-pipewiresrc-using-gst.py
Last active July 20, 2024 17:52
Recreating Valve Video Recording on the Steam Deck
import gi
gi.require_version('Gst', '1.0')
from gi.repository import Gst, GLib
class VideoProcessor:
def __init__(self):
Gst.init(None)
self.pipeline = Gst.Pipeline.new("video_processing_pipeline")
self.setup_pipeline()
@safijari
safijari / convert_valve_video.py
Created June 27, 2024 04:46
Sketch ass script to convert the m4s files being saved by the new Steam Game Recording feature into an mp4 file. It also allows "clipping" the last 30 seconds of the most recent active background recording.
import os
import subprocess
from random import sample
from uuid import uuid4
from pathlib import Path
def create_filelist(folder, init_file, file_pattern):
files = sorted([f for f in os.listdir(folder) if f.startswith(file_pattern) and f.endswith('.m4s')])
return [f"{os.path.join(folder, init_file)}"] + [f"{os.path.join(folder, file)}" for file in files]
@safijari
safijari / gist:4f7fbb189941bf2723462b1c0a863c54
Last active March 27, 2024 15:30
How to use python from a container for elpy in emacs

Create an executable bash script somewhere which runs your python command, for me this contained

#!/usr/bin/env bash
distrobox enter cv -e ~/.virtualenvs/cv/bin/python3 "$@"

which allows me to use a virtualenv I have in my distrobox container directly. Note the "$@" at the end. This is imperative so that commands like ... -m pip can work.

@safijari
safijari / make_sdh_pr.sh
Last active March 19, 2024 21:50
Making/updating PRs for decky plugins
#!/bin/bash
# $1 should be name of folder
# $2 should be name of branch
# $3 should be a commit message
rm -rf /tmp/decky-plugin-database
cd /tmp
git clone git@github.com:YOURGITHUBHANDLE/decky-plugin-database
cd /tmp/decky-plugin-database
git fetch --all
git pull
@safijari
safijari / gist:372dbd0eaf10fa66f71cc3c9d5ba1c08
Created March 4, 2024 02:37
DFL independent plugins how
Move decky-frontend-lib to a devDependency
In your Rollup config:
add decky-frontend-lib to external
add 'decky-frontend-lib': 'DFL' to output.globals
@safijari
safijari / Readme.md
Created November 30, 2023 14:55
Defringing for OLED Steam Deck Samsung Panel

tldr: Fringing happens because the subpixels are not properly aligned. It can be alleviated by "shifting" the underlying data to colocale in the center of the pixel. On the Samsung Panel, a simplistic solution to this is as follows:

green_amt = 0.2
red_amt = 0.4
blue_amt = 0.3
for i in range(1, im.shape[0]-1):
    for j in range(1, im.shape[1]-1):
 green_out[i, j] = green[i, j+1]*(green_amt) + green[i, j]*(1-green_amt)
@safijari
safijari / setup.sh
Created November 13, 2023 19:43
Script for getting set up to build gamescope with rwfus enabled
#!/bin/bash
sudo rm /etc/ld.so.conf.d/lib32-fakeroot.conf
sudo rm /etc/ld.so.conf.d/fakeroot.conf
sudo rm /etc/ssh/sshd_config.d/99-archlinux.conf
sudo rm -rf /etc/pacman.d/gnupg/ || :
sudo pacman-key --init
sudo pacman-key --populate
sudo pacman -Sy --noconfirm --needed archlinux-keyring
sudo pacman --noconfirm -S $(pacman -Qnkq | cut -d' ' -f1 | sort | uniq)
sudo pacman -S base-devel multilib-devel --needed
@safijari
safijari / readme.org
Last active December 24, 2024 00:11
How to use Orange Pi 5B for 4k 120hz (non HDR) streaming with Moonlight

IMPORTANT: DON’T USE THIS GUIDE AS IS. GNOME HAS A WEIRD VSYNC ISSUES. Instead you can use the official Debian image and make sure all the updated drivers are installed and the rest should remain the same.

Preamble

This guide is made using the Orange Pi 5B 4GB+32GB. The device is capable of handling a 4k 120hz stream but you should know that the decode time for 4k stream hovers around 8ms and can spike up to 15ms during a benchmark. I can’t feel any added latency from it and I don’t have any dropped frames. The decode time goes down to 4ms for 1440p. It’s certainly not the blazing fast sub ms decode latency we get on the Steam Deck or mini PCs. I bought the device for $99 and for that price I think this performance is fantastic, but your mileage/expecations may vary.

How to get this result (or rather how I got it)

  1. Install the official Gnome Ubuntu Jammy image using Balena Etcher onto a 16+ GB microSD card
@safijari
safijari / gist:1cc2d3c567f8c04a434ef080cb8a302a
Created April 10, 2023 16:06
pipewire gamescope bug investigation and info
Last pipewire commit that works: https://github.com/PipeWire/pipewire/commit/76313161866db1a48a798da1ff8e196de747d238
@safijari
safijari / CMakeLists.txt
Created April 1, 2021 20:56
The code relevant to pybind11 video
cmake_minimum_required(VERSION 3.4...3.18)
project(pybindtest)
add_subdirectory(pybind11)
pybind11_add_module(module_name main.cpp)