diff options
Diffstat (limited to 'local')
| -rwxr-xr-x | local/bin/junk | 8 | ||||
| -rwxr-xr-x | local/bin/latest-recording | 2 | ||||
| -rwxr-xr-x | local/bin/screenshot-prompt | 2 | ||||
| -rwxr-xr-x | local/bin/video-to-h264 | 21 | ||||
| -rwxr-xr-x | local/bin/video-to-x264 | 15 |
5 files changed, 29 insertions, 19 deletions
diff --git a/local/bin/junk b/local/bin/junk index faf9b32..9758f68 100755 --- a/local/bin/junk +++ b/local/bin/junk @@ -11,9 +11,11 @@ do if [ -e "$dest" ] then echo "$dest already exists, generating a prefix" - identifier="$(seq 100 | xargs -I N sh -c "echo N; test -e '$dest__N' || exit 255" 2> /dev/null | tail -n1)" + identifier="$(seq 100 | xargs -I N sh -c "echo N; test -e '""$dest""__N' || exit 255" 2> /dev/null | tail -n1)" dest="$dest"__"$identifier" fi - mv "$arg" "$dest" && - echo "$arg moved to $dest" || true + if mv "$arg" "$dest" + then + echo "$arg moved to $dest" + fi done diff --git a/local/bin/latest-recording b/local/bin/latest-recording index bf3b3b2..518ffd6 100755 --- a/local/bin/latest-recording +++ b/local/bin/latest-recording @@ -3,5 +3,5 @@ set -e recordings_dir="$HOME/recordings" -latest_recording="$(ls "$recordings_dir" | sort --numeric-sort | tail -n1)" +latest_recording="$(find "$recordings_dir"/* -prune -print | sort --numeric-sort | tail -n1)" echo "$recordings_dir/$latest_recording" diff --git a/local/bin/screenshot-prompt b/local/bin/screenshot-prompt index 6852eba..b320178 100755 --- a/local/bin/screenshot-prompt +++ b/local/bin/screenshot-prompt @@ -23,6 +23,7 @@ screenshot_dir="$HOME/screenshots" [ ! -d "$screenshot_dir" ] && mkdir "$screenshot_dir" scrot_wrapper() { + # shellcheck disable=SC2016 file_format="$screenshot_dir/"'%Y-%m-%d_$wx$h.png' if [ "$1" = '-' ] then @@ -30,6 +31,7 @@ scrot_wrapper() { shift else # optipng optimizes png size without loss (doesn't work if we output directly to stdout) + # shellcheck disable=SC2016 command -v optipng && optipng_arg='optipng -o4 $f' fi scrot --silent --quality 95 --compression 9 --file "$file_format" -e "$optipng_arg" "$@" diff --git a/local/bin/video-to-h264 b/local/bin/video-to-h264 new file mode 100755 index 0000000..8b4d21b --- /dev/null +++ b/local/bin/video-to-h264 @@ -0,0 +1,21 @@ +#!/usr/bin/bash + +file_path="$1" + +# from: https://stackoverflow.com/questions/2869281/how-to-determine-video-codec-of-a-file-with-ffmpeg +current_codec="$( + ffprobe -v error -select_streams v:0 \ + -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 \ + "$file_path" +)" +[ "$current_codec" = 'h264' ] && { echo 'Video is already in h264'; exit 1; } + +# CUDA options: -hwaccel cuda -hwaccel_output_format cuda -c:v h264_nvenc +# seems slower on gpu tho +# There is also -c:v hvec_nvenc +# +# Options to reduce size: -b:v 5M -crf 28 + +ffmpeg -i "$file_path" \ + -map 0 -c:v libx264 -crf 18 -vf format=yuv420p -c:a copy \ + "${file_path%%.*}-h264.${file_path##*.}" diff --git a/local/bin/video-to-x264 b/local/bin/video-to-x264 deleted file mode 100755 index dd93ca5..0000000 --- a/local/bin/video-to-x264 +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/bash - -file_path="$1" -extension= - - -# CUDA options: -hwaccel cuda -hwaccel_output_format cuda -c:v h264_nvenc -# seems slower on gpu tho -# There is also -c:v hvec_nvenc -# -# Options to reduce size: -b:v 5M -crf 28 - -ffmpeg -i "$file_path" \ - -map 0 -c:v libx264 -crf 18 -vf format=yuv420p -c:a copy \ - "${file_path%%.*}-x264.${file_path##*.}" |
