Files
gwutilz/gwencoder/scripts/phase5_quick_test.sh
2026-03-23 15:48:34 -07:00

94 lines
3.4 KiB
Bash
Executable File

#!/bin/bash
# Phase 5 Quick Test - Tests 3 key combinations
# This is a faster subset of the full test suite
TEST_FILE="testvid.webm"
OUTPUT_DIR="phase5_quick_outputs"
LOG_FILE="phase5_quick_results.log"
# Colors
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m'
mkdir -p "$OUTPUT_DIR"
if [ ! -f "$TEST_FILE" ]; then
echo -e "${RED}❌ Test file not found: $TEST_FILE${NC}"
exit 1
fi
ORIGINAL_SIZE=$(du -b "$TEST_FILE" 2>/dev/null | cut -f1)
ORIGINAL_SIZE_MB=$(echo "scale=2; $ORIGINAL_SIZE / 1024 / 1024" | bc)
echo -e "${BLUE}══════════════════════════════════════════════════════════════${NC}"
echo -e "${BLUE}GWENCODER PHASE 5 QUICK TEST${NC}"
echo -e "${BLUE}══════════════════════════════════════════════════════════════${NC}"
echo ""
echo -e "Test file: ${GREEN}$TEST_FILE${NC} (${ORIGINAL_SIZE_MB} MB)"
echo ""
get_file_size_mb() {
local file=$1
if [ -f "$file" ]; then
local size=$(du -b "$file" 2>/dev/null | cut -f1)
echo "scale=2; $size / 1024 / 1024" | bc
else
echo "0"
fi
}
run_quick_test() {
local test_name=$1
local mode=$2
local flags=$3
echo -e "${YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${BLUE}TEST: $test_name${NC}"
echo -e "Command: ${GREEN}./gwencoder $mode $flags${NC}"
echo ""
find . -maxdepth 1 -name "*GWELL.*" -type f -delete 2>/dev/null
start_time=$(date +%s.%N)
./gwencoder $mode $flags 2>&1 | tee "$OUTPUT_DIR/${test_name}.log" > /dev/null
end_time=$(date +%s.%N)
duration=$(echo "$end_time - $start_time" | bc)
duration_rounded=$(printf "%.1f" "$duration")
output_file=$(find . -maxdepth 1 -name "*GWELL.*" -type f -newer "$TEST_FILE" 2>/dev/null | head -1)
if [ -n "$output_file" ]; then
file_size_mb=$(get_file_size_mb "$output_file")
mv "$output_file" "$OUTPUT_DIR/" 2>/dev/null
echo -e "${GREEN}✅ Completed${NC} - Duration: ${duration_rounded}s, Size: ${file_size_mb} MB"
echo "$test_name|$mode|$flags|$duration_rounded|$file_size_mb|✅" >> "$LOG_FILE"
else
echo -e "${RED}❌ Failed${NC}"
echo "$test_name|$mode|$flags|N/A|N/A|❌" >> "$LOG_FILE"
fi
echo ""
}
echo "Test Name|Mode|Flags|Duration (s)|Size (MB)|Status" > "$LOG_FILE"
# Test 1: Default settings
run_quick_test "1_Default" "--fast" ""
# Test 2: With AV1 advanced options
run_quick_test "2_AV1_Advanced" "--fast" "--av1-preset 8 --av1-crf 30"
# Test 3: With audio options
run_quick_test "3_Audio_Options" "--fast" "--audio-quality balanced --audio-stereo"
echo -e "${BLUE}══════════════════════════════════════════════════════════════${NC}"
echo -e "${BLUE}QUICK TEST SUMMARY${NC}"
echo -e "${BLUE}══════════════════════════════════════════════════════════════${NC}"
echo ""
column -t -s'|' "$LOG_FILE"
echo ""
echo "Full logs in: $OUTPUT_DIR/"