System Gen44 @ 2025-05-28-00:12:05 by jonas@monolith

This commit is contained in:
2025-05-28 00:12:06 +02:00
parent 0591f6f740
commit f8fc20953f
8 changed files with 98 additions and 8 deletions

View File

@@ -0,0 +1 @@
use flake ../../#transcode-davinci-resolve --show-trace

View File

@@ -0,0 +1,25 @@
{
bash,
ffmpeg,
fzf,
gum,
stdenv,
tree,
...
}:
stdenv.mkDerivation {
name = "transcode-davinci-resolve";
src = ./.;
buildInputs = [
bash
ffmpeg
fzf
gum
tree
];
installPhase = ''
install -Dm755 transcode-davinci-resolve.sh $out/bin/transcode-davinci-resolve
'';
}

View File

@@ -0,0 +1,7 @@
{pkgs ? import <nixpkgs> {}}: let
bin = pkgs.callPackage ./default.nix {};
in
pkgs.mkShell {
name = "transcode-davinci-resolve";
inputsFrom = [bin];
}

View File

@@ -0,0 +1,44 @@
#!/usr/bin/env bash
set -e
where="${1:-.}"
selection=$(find "$where" -type f | fzf --multi --preview 'ffprobe -v error -show_format -show_streams {}' --preview-window=up:wrap)
output_dir=$(find $HOME -type d ! -name '.*' ! -path '*/.*/*' | fzf --preview 'tree -C {}' --preview-window=up:wrap --prompt "Select output directory: ")
if gum confirm "Flatten the directory structure?";
then
flatten=true
else
flatten=false
fi
function transcode_job {
local file="$1"
local output_dir="$2"
local flatten="$3"
local where=$4
local fname=$(basename "$file")
local segment=$(realpath --relative-to="$where" "$file")
if [ "$flatten" = true ]; then
output_file="$output_dir/$fname.mov"
else
output_file="$output_dir/$segment.mov"
fi
mkdir -p "$(dirname "$output_file")" >> log.txt
ffmpeg -i "$file" -c:v dnxhd -profile:v dnxhr_hq -pix_fmt yuv422p -c:a pcm_s16le "$output_file" || true
}
export -f transcode_job
i=1
len=$(echo "$selection" | wc -l)
while IFS= read -r file; do
gum spin --spinner dot --title "[$i/$len] Transcoding $file" -- bash -c "source <(declare -f transcode_job); transcode_job \"$file\" \"$output_dir\" \"$flatten\" \"$where\""
((i++))
done <<< "$selection"