CLI Stuff

Last Updated - [5/17/2023]

Shy's collection of various cli things or scripts that are super useful!

all preformatted so expect pagebreaks!

FFMPEG Related:

Find all webp's in a folder and create a png from them:

find ./ -name "*.webp" -exec ffmpeg -i {} {}.png \;

This isn't perfect, if you have an "animated" webp then it doesn't generate the png, I use Xconvert usually but this sometimes comes in handy when I am limted to a CLI

put the audio of one video into another:

ffmpeg -an -i video.mp4 -vn -i audio.mp4 -c:a copy -c:v copy output.mov

output must be a "container" format like mov or mkv, and both streams must be compat with that format, in my case I am using aac audio and h265 video

convert a video to prores + aac

ffmpeg.exe -i file.mp4 -map 0:0 -c:v prores -profile:v 0 -c:a none output.mov
ffmpeg -i file.mp4 -vn -map 0:1 -acodec aac -b:a 320k output.aac

refer to my bashrc function that does the same thing, I use ffmpeg.exe in WSL2 since the windows version runs at full speed

my ingest script

cd /mnt/x/VIDEO/INGEST
for f in *.mkv; do ffmpeg.exe -i "$f" -map 0:0 -c:v prores -profile:v 3 -filter:v fps=30 -c:a none "../READYFOREDIT/${f%.*}.mov" && ffmpeg.exe -i "$f" -vn -map 0:1 -acodec copy "../READYFOREDIT/${f%.*}_track1.aac" && ffmpeg.exe -i "$f" -vn -map 0:2 -acodec copy "../READYFOREDIT/${f%.*}_track2.aac"; done

I typically use profile:v 1 and fps=60 but this one is the "HD" ingest. I don't define pix format I let it use defaults which is 422 so thats prefectly fine for youtube (which is 420) as for the profile it controls the bitrate, 0 is 45, 1 is 102, 2 is 147, and 3 is 220mbps. honestly I'd say even 0 (proxy, 45mbps) is fine for what I do, very little quality loss from the original obs recording but i still prefer profile 1. FPS matters, 30fps files will be half the size as 60. I cant give an exact size per hour becuase it actually seems to kind of depend on the content? MAYBE? I can't tell I've ran tests and can't figure it out. Just assume at least 150gb per hour to b safe. However using profile 1 at 30 fps about 4 hours of footage ended up being under 200gb.

script to convert webms to mp4 for editing

cd /mnt/x/VIDEO/INGEST
for f in *.webm; do ffmpeg.exe -i "$f" -crf 26 -preset medium "${f%.*}.mp4"; done

This is for when I need to use a youtube vid or something but the format is in webm, i need to convert it to a reasonable quality mp4 to use it in my videos, this seems to be decent.


Find instances of words inside of specific file types:

grep -r --include=*.file "word" .

DO NOT FORGET THE DOT! will search files with ONLY .file extentions and will return each file and each line that "word" is in. For example: grep -r --include=*.vmt "shystudios" . from my materials folder will return stuff like ./shystudios/tools/toolsnodraw_blue.vmt: "$basetexture" "shystudios/tools/nodraw_blue"

Find all text files of a given name and merge them to a single text file:

find . -name 'Archive.txt' -exec cat {} \; > test.txt

I used this to merge all of my ytdlp archive files, which I get when archiving a whole youtube channel into a single master file that the software can check during normal use.

Log out of connected network servers on windows:

net use * /delete
klist purge

can also specify the server in net use

Show the common fingerprint of a pgp key

gpg --show-keys --fingerprint file.pgp

batch file for killing non responding tasks on windows save this as killtasks.bat

@echo off
TITLE Kill Tasks
tasklist.exe /FI "status eq NOT RESPONDING"
echo Kill These tasks?

CHOICE /M Select /C yn

If Errorlevel 2 goto end
If Errorlevel 1 goto kill

taskkill.exe /F /FI "status eq NOT RESPONDING"
goto end

click the link for the file, put it in the system32 folder
then make a reg entry like:
and set the default string key there to:
cmd.exe /K killtasks.bat
Then add the following string keys to the taskkilla (or whatever u named it) key:
Icon 		%SystemRoot%\\System32\\imageres.dll,-98
MUIVerb 	Kill not responding tasks
Position 	Bottom

Source Engine Related:

Launch gmod dedi:

./srcds_run -tickrate 33 -game garrysmod +maxplayers 4 +map gm_flatgrass

This is tuned for my lil unlisted test server

run another games's vis on a gmod map:

.\vvis.exe -low -game "C:\STEAM\steamapps\common\GarrysMod\garrysmod\" "c:\map\mapfile"

obviously run this from the bin fodler of your game

run another games's rad on a gmod map:

.\vrad.exe -ldr -final -StaticPropLighting -StaticPropPolys -game "C:\STEAM\steamapps\common\GarrysMod\garrysmod\" "C:\maps\mapname"

generate ssbump:

./height2ssbump.exe -r 100 ./file.tga 17

-r isn't needed but default is 250 the 17 is the bumpscale and really depends on your hightmap. 15-25 is usually good for most things. The heightmap must be in the alpha channel of the tga plz refer to this page for more info

batch file to convert vtf to a tga file, save this as vtf2tga.bat or something:

start "" "T:\STEAM\steamapps\common\GarrysMod\bin\vtf2tga.exe" -i %1%

edit the path to suit your need, drag a vtf file onto the batch file's icon.

Shy's Bashrc stuff:

alias clist='echo newingest tx rmbh ytm yt yta ytanf ytlq yt7 c2prores'
#i use the above to document my commands incase i forget
alias newingest='cd /mnt/x/VIDEO/INGEST'
alias tx='cd /mnt/x/SHARE/TX'
alias rmbh='rm /home/shy/.bash_history'

function ytm(){
	yt-dlp --no-playlist -f 140 --download-archive Archive.txt --cookies "/home/shy/.stuff/ytcookies.txt" $1

function yt(){
	yt-dlp --no-playlist --cookies "/home/shy/.stuff/ytcookies.txt" --sponsorblock-remove all --download-archive Archive.txt $1

function ytlq(){
        yt-dlp --no-playlist -f 18 --cookies "/home/shy/.stuff/ytcookies.txt" --sponsorblock-remove all --download-archive Archive.txt $1

function yt7(){
        yt-dlp --no-playlist -f 22 --cookies "/home/shy/.stuff/ytcookies.txt" --sponsorblock-remove all --download-archive Archive.txt $1

function yta(){
	yt-dlp --download-archive Archive.txt -f 22 --cookies "/home/shy/.stuff/ytcookies.txt" --no-playlist $1

function ytanf(){
	yt-dlp --download-archive Archive.txt --cookies "/home/shy/.stuff/ytcookies.txt" --no-playlist $1

function ytam(){
        yt-dlp --download-archive Archive.txt -f 140 --cookies "/home/shy/.stuff/ytcookies.txt" $1

function yttw(){
	yt-dlp --download-archive Archive.txt --cookies "/home/shy/.stuff/twitter.com_cookies.txt" $1

function c2prores(){
	ffmpeg.exe -i "$1" -map 0:0 -c:v prores -profile:v 0 -c:a none "$1".mov && ffmpeg -i "$1" -vn -map 0:1 -acodec aac -b:a 320k "$1".aac