System Gen44 @ 2025-05-28-00:12:05 by jonas@monolith
This commit is contained in:
1
pkgs/transcode-davinci-resolve/.envrc
Normal file
1
pkgs/transcode-davinci-resolve/.envrc
Normal file
@@ -0,0 +1 @@
|
||||
use flake ../../#transcode-davinci-resolve --show-trace
|
||||
25
pkgs/transcode-davinci-resolve/default.nix
Normal file
25
pkgs/transcode-davinci-resolve/default.nix
Normal 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
|
||||
'';
|
||||
}
|
||||
7
pkgs/transcode-davinci-resolve/shell.nix
Normal file
7
pkgs/transcode-davinci-resolve/shell.nix
Normal file
@@ -0,0 +1,7 @@
|
||||
{pkgs ? import <nixpkgs> {}}: let
|
||||
bin = pkgs.callPackage ./default.nix {};
|
||||
in
|
||||
pkgs.mkShell {
|
||||
name = "transcode-davinci-resolve";
|
||||
inputsFrom = [bin];
|
||||
}
|
||||
44
pkgs/transcode-davinci-resolve/transcode-davinci-resolve.sh
Normal file
44
pkgs/transcode-davinci-resolve/transcode-davinci-resolve.sh
Normal 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"
|
||||
Reference in New Issue
Block a user