#!/bin/bash # ============================================================================== # Garmin Overlay Render Script for macOS (M4 Pro Optimized) # Usage: ./render.sh # ============================================================================== # 1. Validate Arguments if [ "$#" -ne 2 ]; then echo "Error: Invalid number of arguments." echo "Usage: ./render.sh " echo "Example: ./render.sh activity.fit footage.mp4" exit 1 fi # 2. Define Variables FIT_FILE="$1" VIDEO_FILE="$2" # Extract filename without extension to auto-generate output name BASENAME=$(basename "$VIDEO_FILE") FILENAME="${BASENAME%.*}" # Output format is .mov because we are using H.264/ProRes containers OUTPUT_FILE="overlay_${FILENAME}.mov" # 3. Check and Activate Virtual Environment # This assumes the script is run from the project root where 'venv' exists if [ -d "venv" ]; then source venv/bin/activate else echo "Error: 'venv' directory not found. Please run this script from the project root." exit 1 fi # 4. Check for Dependencies if [ ! -f "pro_layout.xml" ] || [ ! -f "ffmpeg-profiles.json" ]; then echo "Error: Configuration files (pro_layout.xml or ffmpeg-profiles.json) are missing." exit 1 fi echo "================================================================" echo "Starting Render Process" echo "================================================================" echo "FIT Data : $FIT_FILE" echo "Video Input : $VIDEO_FILE" echo "Output File : $OUTPUT_FILE" echo "Profile : m4-youtube (Hardware Accelerated H.264)" echo "Layout : pro_layout.xml" echo "Timestamp : $(date)" echo "================================================================" # 5. Execute gopro-dashboard.py # Using --use-gpx-only to ignore GoPro metadata and force external FIT data gopro-dashboard.py \ --use-gpx-only \ --gpx "$FIT_FILE" \ --layout xml \ --layout-xml pro_layout.xml \ --overlay-size 3840x2160 \ --units-speed kph \ --units-altitude meter \ --font "Roboto-Medium.ttf" \ --config-dir . \ --profile m4-youtube \ "$VIDEO_FILE" "$OUTPUT_FILE" # 6. Completion if [ $? -eq 0 ]; then echo "================================================================" echo "SUCCESS: Render finished. Output saved to: $OUTPUT_FILE" echo "================================================================" else echo "================================================================" echo "FAILURE: An error occurred during rendering." echo "================================================================" fi