Skip to content

Instantly share code, notes, and snippets.

Avatar
🇺🇦

Denis Denisov denji

🇺🇦
View GitHub Profile
@denji
denji / readme.md
Created June 4, 2023 20:35 — forked from ShannonScott/readme.md
[Moving efficiently in the CLI] Key-combination reference for movement in the shell. #tags: mac, linux, bash
@denji
denji / Video Screen Capture with GStreamer.md
Created June 4, 2023 20:34 — forked from ShannonScott/Video Screen Capture with GStreamer.md
[Video Screen Capture with GStreamer] Capture a Linux desktop window video with gsteramer. #tags: gstreamer, linux, xwindows, video
View Video Screen Capture with GStreamer.md

Capture a video of a given X Window with gstreamer.

X Window ID

Get the target window ID with the following:

xwininfo
@denji
denji / nvenc-install.sh
Created June 4, 2023 20:31 — forked from lucaspar/nvenc-install.sh
Installation script of CUDA-accelerated `ffmpeg` with NVIDIA Encoder
View nvenc-install.sh
#!/bin/bash
# ==================================================================
# This script will compile and install a static ffmpeg build with
# support for NVENC in Ubuntu. Developed in Ubuntu 22.04 LTS,
# with NVIDIA Drivers v510.73 and CUDA v11.6
# It assumes NVIDA drivers are installed and that you have a
# CUDA-compatible GPU. You can check installed drivers with:
# $ apt list *nvidia-driver-* | grep installed
# $ nvidia-smi
# ==================================================================
@denji
denji / nvidia.conf
Created May 21, 2023 02:21
/etc/modprobe.d/nvidia.conf
View nvidia.conf
# https://wiki.archlinux.org/title/NVIDIA/Tips_and_tricks
# https://forums.developer.nvidia.com/t/does-modprobe-d-nvidia-conf-nvreg-enablestreammemops-need-to-be-set-for-gpudirect-to-work/79511
# https://github.com/NVIDIA/open-gpu-kernel-modules/blob/main/src/nvidia/interface/nvrm_registry.h
# Requires nvidia.ko >= 510.40.3 loaded with PeerMappingOverride=1. https://docs.nvidia.com/nvshmem/install-guide/index.html
# https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers/en
# https://github.com/ventureoo/nvidia-tweaks
# https://nvdam.widen.net/s/k8vrp9xkft/tech-overview-magnum-io-1790750-r5-web
# https://developer.download.nvidia.com/devzone/devcenter/cuda/docs/GPUDirect_Technology_Overview.pdf
# https://docs.nvidia.com/nvshmem/pdf/NVSHMEM-Installation-Guide.pdf
@denji
denji / disable-fb.sh
Created May 14, 2023 16:08 — forked from null-dev/disable-fb.sh
Disable efifb at runtime
View disable-fb.sh
#!/usr/bin/env bash
# 1. Download and install the QEMU hook helper from here: https://github.com/PassthroughPOST/VFIO-Tools
# 2. Place this file in /etc/libvirt/hooks/qemu.d/NAME OF YOUR VM/prepare/begin/disable-fb.sh
# 3. Make disable-fb.sh executable.
VM_NAME="$1"
echo "libvirt-qemu disable-fb: Disabling efi-framebuffer to prepare to pass GPU to VM $VM_NAME" > /dev/kmsg 2>&1
echo "efi-framebuffer.0" > /sys/bus/platform/devices/efi-framebuffer.0/driver/unbind
@denji
denji / ffmpeg-hevc-encode-nvenc.md
Created May 9, 2023 18:57 — forked from jbboehr/ffmpeg-hevc-encode-nvenc.md
This gist shows you how to encode specifically to HEVC with ffmpeg's NVENC on supported hardware, with a two-pass profile and optional CUVID-based hardware-accelerated decoding.
View ffmpeg-hevc-encode-nvenc.md

Encoding high-quality HEVC content in a two-pass manner with FFmpeg - based NVENC encoder on supported hardware:

If you've built ffmpeg as instructed here on Linux and the ffmpeg binary is in your path, you can do fast HEVC encodes as shown below, using NVIDIA's NPP's libraries to vastly speed up the process.

Now, to do a simple NVENC encode in 1080p, (that will even work for Maxwell Gen 2 (GM200x) series), start with:

ffmpeg  -i <inputfile> -pass 1 \
-filter:v hwupload_cuda,scale_npp=w=1920:h=1080:format=nv12:interp_algo=lanczos,hwdownload,format=nv12 \

-c:v hevc_nvenc -profile main -preset slow -rc vbr_2pass \

@denji
denji / nvidia-x-server-settings.txt
Created March 13, 2023 05:16 — forked from DavidMetcalfe/nvidia-x-server-settings.txt
Documents the PowerMizer CLI for potential cron jobs, etc.
View nvidia-x-server-settings.txt
Because PowerMizer settings in NVIDIA X Server Settings doesn't persist across sessions,
attempts to overclock can become a nuisance.
The following documents the three CLI settings to modify the Preferred Mode as desired:
# Auto:
nvidia-settings -a [gpu:0]/GPUPowerMizerMode=2
# Adaptive:
nvidia-settings -a [gpu:0]/GPUPowerMizerMode=0
@denji
denji / TypeClipboard.md
Created March 13, 2023 04:04 — forked from ethack/TypeClipboard.md
Scripts that simulate typing the clipboard contents. Useful when pasting is not allowed.
View TypeClipboard.md

It "types" the contents of the clipboard.

Why can't you just paste the contents you ask? Sometimes pasting just doesn't work.

  • One example is in system password fields on OSX.
  • Sometimes you're working in a VM and the clipboard isn't shared.
  • Other times you're working via Remote Desktop and again, the clipboard doesn't work in password boxes such as the system login prompts.
  • Connected via RDP and clipboard sharing is disabled and so is mounting of local drives. If the system doesn't have internet access there's no easy way to get things like payloads or Powershell scripts onto it... until now.

Windows

The Windows version is written in AutoHotKey and easily compiles to an executable. It's a single line script that maps Ctrl-Shift-V to type the clipboard.

@denji
denji / you-need-spice-vdagent.md
Created March 6, 2023 20:04 — forked from plembo/you-need-spice-vdagent.md
You need spice-vdagent
View you-need-spice-vdagent.md

You need spice-vdagent

Debian or Kali Linux installed to as KVM (libvirtd) guests do not automatically have qemu-guest-agent or spice-vdagent installed. This will prevent seamless movement of the mouse cursor between the guest and host desktop in Virtual Machine Manager (requiring the use of a Ctrl-Alt to release the cursor from the guest window).

To cure this, install both qemu-guest-agent and spice-vdagent on each guest and reboot (the guests).

$ sudo apt install qemu-guest-agent
$ sudo apt install spice-vdagent
View manjaro-gpu-passthrough.md

Install softwares

sudo pacman -S qemu python python-pip
sudo pacman -S qemu virt-manager virt-viewer dnsmasq vde2 bridge-utils openbsd-netcat
sudo pacman -S ebtables iptables
sudo systemctl enable libvirtd.service
sudo systemctl restart libvirtd.service
sudo virsh net-start default