#!/bin/bash # # GnommoEditor - Code-first video editing pipeline # # Usage: # gnommo.sh -p Render project # gnommo.sh -p import Generate slides.json from image files # gnommo.sh -p validate Validate only # gnommo.sh -p preprocess Apply video preprocessing filters # gnommo.sh -p transcribe Transcribe video # gnommo.sh -p align Align markers to transcript # gnommo.sh -p all Full pipeline: transcribe → align → render # set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" VENV_PYTHON="$SCRIPT_DIR/venv/bin/python" # Check for venv if [[ ! -f "$VENV_PYTHON" ]]; then echo "Error: Virtual environment not found at $SCRIPT_DIR/venv" echo "Create it with: python -m venv venv && ./venv/bin/pip install openai-whisper" exit 1 fi # Parse arguments PROJECT="" COMMAND="render" VERBOSE="" FORCE="" usage() { echo "Usage: gnommo.sh -p [command] [options]" echo "" echo "Commands:" echo " render Render video (default)" echo " import Generate slides.json from image files" echo " validate Validate project only" echo " preprocess Apply video preprocessing filters (chroma key, etc.)" echo " transcribe Transcribe video audio" echo " align Align manuscript to transcript" echo " all Full pipeline: transcribe → align → render" echo "" echo "Options:" echo " -p Project directory (required)" echo " -v Verbose output" echo " -f Force overwrite existing files" echo " -h Show this help" echo "" echo "Examples:" echo " gnommo.sh -p video1 # Render video1 project" echo " gnommo.sh -p video1 import # Generate slides.json" echo " gnommo.sh -p video1 import -f # Force overwrite slides.json" echo " gnommo.sh -p video1 validate # Validate only" echo " gnommo.sh -p video1 all # Full pipeline" exit 0 } while [[ $# -gt 0 ]]; do case $1 in -p|--project) PROJECT="$2" shift 2 ;; -v|--verbose) VERBOSE="-v" shift ;; -f|--force) FORCE="-f" shift ;; -h|--help) usage ;; import|validate|render|preprocess|transcribe|align|all) COMMAND="$1" shift ;; *) echo "Unknown option: $1" usage ;; esac done # Validate project argument if [[ -z "$PROJECT" ]]; then echo "Error: Project directory required (-p )" echo "" usage fi if [[ ! -d "$PROJECT" ]]; then echo "Error: Project directory not found: $PROJECT" exit 1 fi if [[ ! -f "$PROJECT/project.json" ]]; then echo "Error: project.json not found in $PROJECT" exit 1 fi # Run commands using new CLI interface run_gnommo() { "$VENV_PYTHON" -m gnommo -p "$PROJECT" -a "$1" $VERBOSE } run_gnommo_import() { "$VENV_PYTHON" -m gnommo -p "$PROJECT" -a validate -i $FORCE $VERBOSE } case $COMMAND in import) echo "=== Importing assets for $PROJECT ===" run_gnommo_import ;; validate) echo "=== Validating $PROJECT ===" run_gnommo validate ;; transcribe) echo "=== Transcribing $PROJECT ===" run_gnommo transcribe ;; align) echo "=== Aligning $PROJECT ===" run_gnommo align ;; render) echo "=== Rendering $PROJECT ===" run_gnommo render ;; preprocess) echo "=== Preprocessing $PROJECT ===" run_gnommo preprocess ;; all) echo "=== Full Pipeline: $PROJECT ===" run_gnommo all ;; *) echo "Unknown command: $COMMAND" usage ;; esac