doocus update and meeting list export

This commit is contained in:
Mariano Gabriel
2026-07-05 11:15:57 -03:00
parent fa3a0e3d1a
commit 300806b936
17 changed files with 614 additions and 628 deletions

View File

@@ -7,14 +7,19 @@
# the mirrored output subfolder.
#
# Usage:
# ctrl/batch.sh -i <input-dir> -o <output-dir> [-e "mkv mp4 ..."] [-n] \
# [-- <process_meeting.py flags>]
# ctrl/batch.sh -i <input-dir> -o <output-dir> [-e "mkv mp4 ..."] \
# [-l <list-file>] [-n] [-- <process_meeting.py flags>]
#
# Examples:
# # Everything under a mounted share, default extraction flags forwarded
# ctrl/batch.sh -i "/mnt/win/trainings" -o output/batch \
# -- --embed-images --scene-detection --diarize
#
# # Only the meetings doocus found (relative paths), re-rooted at a new mount,
# # output into the doocus folder for later packaging:
# ctrl/batch.sh -i "/mnt/drive" -o docs-output -l docs-output/meetings.txt \
# -- --embed-images --scene-detection --diarize
#
# # Dry run: just show which videos map to which output folders
# ctrl/batch.sh -i "/mnt/win/trainings" -o output/batch -n
#
@@ -42,6 +47,7 @@ INPUT=""
OUTPUT=""
EXTS="mkv mp4 mov avi m4v webm wmv ogg mp3 wav m4a opus flac aac"
DRY=false
LIST="" # optional newline list of RELATIVE paths (re-rooted at INPUT)
FORWARD=()
while [[ $# -gt 0 ]]; do
@@ -49,6 +55,7 @@ while [[ $# -gt 0 ]]; do
-i|--input) INPUT="$2"; shift 2 ;;
-o|--output) OUTPUT="$2"; shift 2 ;;
-e|--ext) EXTS="$2"; shift 2 ;;
-l|--list) LIST="$2"; shift 2 ;;
-n|--dry-run) DRY=true; shift ;;
-h|--help) usage; exit 0 ;;
--) shift; FORWARD=("$@"); break ;;
@@ -59,6 +66,7 @@ done
[ -n "$INPUT" ] || { echo "ERROR: -i/--input is required" >&2; exit 1; }
[ -n "$OUTPUT" ] || { echo "ERROR: -o/--output is required" >&2; exit 1; }
[ -d "$INPUT" ] || { echo "ERROR: input dir not found: $INPUT" >&2; exit 1; }
[ -z "$LIST" ] || [ -f "$LIST" ] || { echo "ERROR: list file not found: $LIST" >&2; exit 1; }
# Absolute paths so relative-path math is stable regardless of where we cd'd.
INPUT="$(realpath "$INPUT")"
@@ -74,16 +82,35 @@ unset 'find_expr[${#find_expr[@]}-1]' # drop the trailing -o
echo "Input : $INPUT"
echo "Output: $OUTPUT"
echo "Exts : $EXTS"
[ -n "$LIST" ] && echo "List : $LIST (relative paths, re-rooted at input)" || echo "Exts : $EXTS"
[ "$DRY" = true ] && echo "(dry run — nothing will be processed)"
echo
# Producer: either the given list of relative paths (re-rooted at INPUT) or a
# recursive find by extension. Both emit null-delimited absolute paths.
producer() {
if [ -n "$LIST" ]; then
while IFS= read -r rel || [ -n "$rel" ]; do
[ -z "$rel" ] && continue
printf '%s\0' "$INPUT/$rel"
done < "$LIST"
else
find "$INPUT" -type f \( "${find_expr[@]}" \) -print0 | sort -z
fi
}
total=0 ok=0 fail=0
# Process substitution (not a pipe) so counters survive into the summary.
while IFS= read -r -d '' video; do
total=$((total + 1))
rel="${video#"$INPUT"/}" # path relative to the input root
if [ ! -f "$video" ]; then # list may name a path missing under this root
echo "[$total] $rel !! not found under input (skipped)" >&2
fail=$((fail + 1))
continue
fi
reldir="$(dirname "$rel")"
if [ "$reldir" = "." ]; then
outdir="$OUTPUT" # video sat directly in the input root
@@ -110,7 +137,7 @@ while IFS= read -r -d '' video; do
fail=$((fail + 1))
fi
echo
done < <(find "$INPUT" -type f \( "${find_expr[@]}" \) -print0 | sort -z)
done < <(producer)
echo "----------------------------------------"
if [ "$DRY" = true ]; then