97e4cc547a
1. homelab [Gitea](https://gitea.jafner.tools/Jafner/homelab), [Github (docker_config)](https://github.com/Jafner/docker_config), [Github (wiki)](https://github.com/Jafner/wiki), [Github (cloud_tools)](https://github.com/Jafner/cloud_tools), [Github (self-hosting)](https://github.com/Jafner/self-hosting). - Rename? Jafner.net? Wouldn't that be `Jafner/Jafner.net/Jafner.net`? 2. Jafner.dev [Github](https://github.com/Jafner/Jafner.dev). 3. dotfiles [Gitea](https://gitea.jafner.tools/Jafner/dotfiles), [Github](https://github.com/Jafner/dotfiles). 4. nvgm [Gitea](https://gitea.jafner.tools/Jafner/nvgm) 5. pamidi [Gitea](https://gitea.jafner.tools/Jafner/pamidi), [Github](https://github.com/Jafner/pamidi) 6. docker-llm-amd [Gitea](https://gitea.jafner.tools/Jafner/docker-llm-amd) 7. doradash [Gitea](https://gitea.jafner.tools/Jafner/doradash) 8. clip-it-and-ship-it [Gitea (PyClipIt)](https://gitea.jafner.tools/Jafner/PyClipIt), [Github](https://github.com/Jafner/clip-it-and-ship-it). 9. razer battery led [Github](https://github.com/Jafner/Razer-BatteryLevelRGB) 10. 5etools-docker [Github](https://github.com/Jafner/5etools-docker) 11. jafner-homebrew [Github](https://github.com/Jafner/jafner-homebrew)
42 lines
1.8 KiB
Bash
Executable File
42 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# Transcodes a file to x264 with VA API acceleration.
|
|
|
|
# Set the $FILE variable to act on. Varies with file manager, but Dolphin's servicemenus and CLI both use $1
|
|
if ! [ -z $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS ]; then
|
|
echo "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" > ~/.nautilus_script_selected_file_paths
|
|
if (( $(grep -c . <<<"$(cat ~/.nautilus_script_selected_file_paths)") > 1 )); then notify-send -u critical "Script error" "Selecting more than 1 file is not supported."; exit 1; fi
|
|
rm ~/.nautilus_script_selected_file_paths
|
|
INPUT_FILE="$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"
|
|
elif ! [ -z "$1" ]; then
|
|
INPUT_FILE="$1"
|
|
else
|
|
echo "No file selected."
|
|
exit 1
|
|
fi
|
|
|
|
RATE_FACTOR=""
|
|
while [ -z "$RATE_FACTOR" ]; do
|
|
RATE_FACTOR=$(kdialog --title "Transcode: x264 Rate factor" --inputbox "Rate factor (15-28, lower is higher fidelity, higher bitrate.")
|
|
if ! (($RATE_FACTOR >= 15 && $RATE_FACTOR <= 28)); then
|
|
RATE_FACTOR=""
|
|
fi
|
|
done
|
|
|
|
# Break up the input file's parts so we know the:
|
|
# - absolute path (e.g. /home/user/Videos/MyVideo.mkv)
|
|
# - file name (with extension) (e.g. MyVideo.mkv)
|
|
# - file extension (e.g. mkv)
|
|
# - file name (without extension) (e.g. MyVideo)
|
|
# - composed output file absolute path (e.g. /home/user/Videos/MyVideo-clip.mp4)
|
|
INPUT_FILE=$(realpath "$INPUT_FILE")
|
|
FILE_PATH=$(dirname "$INPUT_FILE")
|
|
FILE_NAME=$(basename "$INPUT_FILE")
|
|
FILE_EXT="${FILE_NAME##*.}"
|
|
FILE_NAME="${FILE_NAME%.*}"
|
|
OUTFILE=$(echo "$FILE_PATH/$FILE_NAME.x264.$FILE_EXT")
|
|
|
|
# Actual transcoding happens here:
|
|
notify-send -t 2000 "Transcode starting" "$FILE_NAME"
|
|
ffmpeg -hide_banner -vaapi_device /dev/dri/renderD128 -i "$INPUT_FILE" -map 0 -vf 'format=nv12,hwupload' -c:v h264_vaapi -qp $RATE_FACTOR -c:a copy "$OUTFILE"
|
|
notify-send -t 4000 "Transcode complete" "$FILE_NAME"
|