Skip to content

Instantly share code, notes, and snippets.

View denji's full-sized avatar
🇺🇦

Denis Denisov denji

🇺🇦
View GitHub Profile
@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.

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 / 60-ioschedulers.rules
Last active December 10, 2024 01:17
#udev #linux /etc/udev/rules.d/60-ioschedulers.rules ("udevadm control --reload-rules && udevadm trigger")
# /etc/udev/rules.d/60-ioschedulers.rules
# https://github.com/pop-os/default-settings/blob/master_jammy/lib/udev/rules.d/60-block-pop.rules
# https://wiki.archlinux.org/index.php/Improving_performance
# https://wiki.archlinux.org/title/improving_performance#Input/output_schedulers
# https://gist.github.com/Th3Whit3Wolf/2f24b29183be7f8e9c0b05115aefb693
# https://support.purestorage.com/Solutions/Linux/Linux_Reference/Linux_Recommended_Settings
# https://www.kernel.org/doc/html/latest/block/index.html
# https://wiki.ubuntu.com/Kernel/Reference/IOSchedulers
# https://forum.endeavouros.com/t/ssd-scheduler/36109/4
# https://github.com/CachyOS/CachyOS-Settings/blob/master/usr/lib/udev/rules.d/60-ioschedulers.rules
@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.
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.

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

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

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
@denji
denji / zram-zwap.md
Last active July 24, 2022 22:57
Linux zSwap LZ4 (z3fold) sudo update-initramfs -k all -u / zram #lz4 #zstd #lz4hc #zbud #zsmalloc #z3fold #iot #router #embedded

/etc/default/grub

GRUB_CMDLINE_LINUX_DEFAULT="... zswap.enabled=1 zswap.compressor=lz4 zswap.max_pool_percent=20 zswap.zpool=z3fold"

/etc/initramfs-tools/modules (Linux zSwap lz4+z3fold)

# List of modules that you want to include in your initramfs.
# They will be loaded at boot time in the order below.
#
@denji
denji / linux-usb-file-copy-fix.md
Created July 20, 2022 01:08 — forked from 2E0PGS/linux-usb-file-copy-fix.md
Fix Ubuntu and other Linux slow/hanging file copying via USB.

If your running a x64 bit Ubuntu or other Linux and find USB transfers hang at the end apply this fix:

echo $((16*1024*1024)) > /proc/sys/vm/dirty_background_bytes
echo $((48*1024*1024)) > /proc/sys/vm/dirty_bytes

I suggest you edit your /etc/rc.local file to make this change persistant across reboots.

sudo nano /etc/rc.local

@denji
denji / 60-vboxdrv.rules.save
Last active July 20, 2022 00:45
#udev #linux /etc/udev/rules.d/60-vboxdrv.rules.save ("udevadm control --reload-rules && udevadm trigger")
SUBSYSTEM=="usb_device", ACTION=="add", RUN+="/usr/share/virtualbox/VBoxCreateUSBNode.sh $major $minor vboxusers"
SUBSYSTEM=="usb", ACTION=="add", ENV{DEVTYPE}=="usb_device", RUN+="/usr/share/virtualbox/VBoxCreateUSBNode.sh $major $minor vboxusers"
@denji
denji / hd_power_save.rules
Last active July 20, 2022 00:44
#udev #linux /etc/udev/rules.d/hd_power_save.rules ("udevadm control --reload-rules && udevadm trigger")
# /etc/udev/rules.d/hd_power_save.rules
ACTION=="add", SUBSYSTEM=="scsi_host", KERNEL=="host*", ATTR{link_power_management_policy}="med_power_with_dipm"