summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimmy Keller <tjk@tjkeller.xyz>2021-10-26 02:25:17 -0500
committerTimmy Keller <tjk@tjkeller.xyz>2021-10-26 02:25:17 -0500
commitd75d53fe79ee7cf0d2efd30d5e191def8c746056 (patch)
tree1eb44a422da9c32022f61e01f7b2f215adee37d5
parent6b0cb35fd2383caff09c46996087ddd9b28f9d0a (diff)
downloadscripts-d75d53fe79ee7cf0d2efd30d5e191def8c746056.tar.xz
scripts-d75d53fe79ee7cf0d2efd30d5e191def8c746056.zip
changed a bunch of video scripts and added my first and possibly last python script, although it was fun
l---------misc/screenrec1
-rwxr-xr-xold/delsimpic39
-rwxr-xr-xvideo/rectape2
-rwxr-xr-xvideo/rmduppic67
-rwxr-xr-xvideo/screenrec20
-rwxr-xr-xvideo/webcamdesktopffplay (renamed from video/webcamffplay)0
6 files changed, 124 insertions, 5 deletions
diff --git a/misc/screenrec b/misc/screenrec
new file mode 120000
index 0000000..cecd2f8
--- /dev/null
+++ b/misc/screenrec
@@ -0,0 +1 @@
+../video/screenrec \ No newline at end of file
diff --git a/old/delsimpic b/old/delsimpic
new file mode 100755
index 0000000..83c3d1a
--- /dev/null
+++ b/old/delsimpic
@@ -0,0 +1,39 @@
+#!/usr/bin/awk -f
+function convtobytes(num) {
+ if (match(num, " K"))
+ mul = 1000
+ else if (match(num, " M"))
+ mul = 1000 * 1000
+ else if (match(num, " G"))
+ mul = 1000 * 1000 * 1000
+ else
+ mul = 1
+ return int(num * mul)
+}
+
+BEGIN {
+ cmd = "czkawka_cli image -d $PWD"
+ FS = " - "
+ largestsize = 0
+ imc = 0
+ k = 0
+ while (cmd | getline) {
+ print $0
+ if (!match($0, "^/")) {
+ delete images
+ largestsize = 0
+ imc = 0
+ k++
+ break
+ }
+ images[$imc] = $0
+ if (size = convtobytes($3) > largestsize) {
+ largestsize = size
+ keep[$k] = $1
+ }
+ imc++
+ }
+ for (image in keep) {
+ print $image
+ }
+}
diff --git a/video/rectape b/video/rectape
index f6e7a01..1e54370 100755
--- a/video/rectape
+++ b/video/rectape
@@ -3,8 +3,6 @@ if [ -z "$1" ]; then
$1=untitled_$(ls | wc -l)
fi
-# All hevc_amf ffmpeg options: $ ffmpeg -h encoder=hevc_amf
-
ffmpeg \
-f decklink -format_code ntsc -i "Intensity Pro" \
-c:v libx264 \
diff --git a/video/rmduppic b/video/rmduppic
new file mode 100755
index 0000000..6fdc18d
--- /dev/null
+++ b/video/rmduppic
@@ -0,0 +1,67 @@
+#!/usr/bin/env python3
+import os
+import subprocess
+
+def sizeinbytes(size, unit):
+ mag = {'KiB' : 1, 'MiB': 2, 'GiB' : 3}
+ return float(size) * (1000 ** mag[unit])
+
+# Run czkawka_cli on the current directory
+cwd = os.getcwd()
+print("Running czkawa for directory ", cwd, "...", sep="")
+czkawka = ["czkawka_cli", "image", "-d", cwd]
+czkawkadata = subprocess.run(czkawka, stdout=subprocess.PIPE)
+czkawkadata = czkawkadata.stdout.decode('utf-8').splitlines() # Convert to a normal string and split into lines
+if not czkawkadata:
+ print("All images in", cwd, "are unique. Exiting...")
+ exit()
+
+# Get number of images total and remove first line since it would cause issues
+numimages = int(czkawkadata[0].split()[1])
+print ("Done!", numimages, "duplicate images found...")
+czkawkadata.pop(0)
+
+# Split czkawkadata by the delimeter used by czkawka_cli
+czkawkadata = [i.split(' - ') for i in czkawkadata]
+
+# Make keep store the images we want to keep
+largest = 0
+i = 0
+dups = 0
+keep = [None] * numimages
+for image in czkawkadata:
+ if not image[0]:
+ largest = 0
+ i += 1
+ continue
+ dups += 1
+ size = image[2].split()
+ size = sizeinbytes(size[0], size[1]) # Convert to bytes so we can easily compate kb vs mb vs gb
+ if size > largest:
+ largest = size
+ keep[i] = image
+
+# Remove all empty entries from czkawkadata
+czkawkadata[:] = [x for x in czkawkadata if x[0]]
+
+# Remove any images we're keeping from czkawkadata to be left with only the duplicates
+for image in keep:
+ czkawkadata.remove(image)
+
+# User actions
+confirmation = None
+message = "Are you sure you want to delete all " + str(dups - len(keep)) + " duplicate images? (Yes/No/Show) "
+while not confirmation:
+ confirmation = input(message)
+ if (confirmation == "yes"):
+ for image in czkawkadata:
+ os.remove(image[0])
+ print("Removed image", image[0])
+ elif (confirmation == "no"):
+ exit()
+ elif (confirmation == "show"):
+ for image in czkawkadata:
+ print(image)
+ confirmation = None # Prompt again
+ else:
+ confirmation = None
diff --git a/video/screenrec b/video/screenrec
index 91edcd0..fa6b628 100755
--- a/video/screenrec
+++ b/video/screenrec
@@ -1,6 +1,20 @@
#!/bin/sh
newname() { defname="video"; name=$defname`ls | grep "^$defname[0-9]*" | wc -l | tr -d '[:blank:]'`.mkv; }
-vs=`cat /sys/class/drm/*/modes | head -1`
-vs=1366x768
[ -z "$1" ] && newname || name="$1"
-ffmpeg -hide_banner -video_size $vs -framerate 60 -f x11grab -i :0.0+0,0 -c:v libx264 -preset ultrafast -qp 1 -pix_fmt yuv444p "$name"
+# Get screen info. I suspect this script wouldn't work too well with multiple screens. Somebody else can add that
+resinfo="$(xrandr | grep '*' | tr -s ' ')"
+vs="$(echo "$resinfo" | cut -d' ' -f2)"
+fr="$(echo "$resinfo" | sed 's/.*\s\([0-9]*\.[0-9]*\)\*.*/\1/')"
+# -i is screen coordinates for top-leftmost screen
+# Encoder settings are basically lossless and optimized for good speed, decent size, and great quality
+# yuv444p colorspace is needed for a 24 bit rgb monitor, change for hdr. yuv420p is the default and is good for video, but is inadequate for screencasts
+ffmpeg -hide_banner \
+ -video_size $vs \
+ -framerate $fr \
+ -f x11grab \
+ -i :0.0+0,0 \
+ -c:v libx264 \
+ -preset ultrafast \
+ -qp 1 \
+ -pix_fmt yuv444p \
+ "$name"
diff --git a/video/webcamffplay b/video/webcamdesktopffplay
index c56d879..c56d879 100755
--- a/video/webcamffplay
+++ b/video/webcamdesktopffplay