Skip to content

Instantly share code, notes, and snippets.

@JustCauseWhyNot
Created November 14, 2025 21:33
Show Gist options
  • Select an option

  • Save JustCauseWhyNot/b4374c40da3185780702871e2a8e7d31 to your computer and use it in GitHub Desktop.

Select an option

Save JustCauseWhyNot/b4374c40da3185780702871e2a8e7d31 to your computer and use it in GitHub Desktop.
.local/bin/ffmpegbatchRecording
#!/bin/bash
input_base=~/Videos/Recording
output_base=~/Videos/Archive
# Expand tilde
input_base="${input_base/#\~/$HOME}"
output_base="${output_base/#\~/$HOME}"
# Create a temporary file to store the list
temp_file=$(mktemp)
find "$input_base" -type f -iname "*.mkv" > "$temp_file"
# Count total files
total=$(wc -l < "$temp_file")
current=0
while IFS= read -r file; do
current=$((current + 1))
rel_path="${file#$input_base/}"
output_file="$output_base/${rel_path%.*}.mkv"
# Skip if already exists
if [ -f "$output_file" ]; then
echo "[$current/$total] Skipping (already exists): $rel_path"
continue
fi
mkdir -p "$(dirname "$output_file")"
echo "[$current/$total] Processing: $rel_path"
chrt -i 0 ffmpeg -nostdin -i "$file" -c:v libsvtav1 -crf 55 -g 300 -pix_fmt yuv420p10le -svtav1-params preset=4:psy-rd=4:qm-min=8:noise-adaptive-filtering=1:noise-norm-strength=3:qp-scale-compress-strength=2:complex-hvs=1:hbd-mds=1:enable-dlf=2:spy-rd=1 -map 0 -c:a copy -loglevel error -stats "$output_file" < /dev/null
if [ $? -eq 0 ]; then
echo "✓ Completed: $rel_path"
else
echo "✗ Failed: $rel_path"
fi
done < "$temp_file"
# Clean up
trash "$temp_file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment