#!/bin/bash # GWEncoder v3.0 Comprehensive Testing Script # Tests all encoding modes with all codec variants (AV1, H.264, NVENC HEVC) set -e echo "๐Ÿงช GWEncoder v3.0 - Comprehensive Encoding Test" echo "================================================" echo "" # Check if testvid.webm exists if [ ! -f "testvid.webm" ]; then echo "โŒ testvid.webm not found in current directory" exit 1 fi # Get source file info echo "๐Ÿ“Š SOURCE FILE INFORMATION" echo "==========================" SOURCE_SIZE=$(stat -c%s "testvid.webm") SOURCE_SIZE_MB=$(echo "scale=2; $SOURCE_SIZE / 1024 / 1024" | bc) SOURCE_DURATION=$(ffprobe -v quiet -select_streams v:0 -show_entries format=duration -of csv=p=0 testvid.webm) SOURCE_RESOLUTION=$(ffprobe -v quiet -select_streams v:0 -show_entries stream=width,height -of csv=p=0 testvid.webm) echo "File: testvid.webm" GENL_SIZE_MB=$(echo "scale=2; $SOURCE_SIZE / 1024 / 1024" | bc) echo "Size: $SOURCE_SIZE_MB MB" echo "Duration: $SOURCE_DURATION seconds" echo "Resolution: $SOURCE_RESOLUTION" echo "" # Create results file RESULTS_FILE="encoding_test_results.txt" echo "GWEncoder v3.0 - Encoding Test Results" > $RESULTS_FILE echo "Generated: $(date)" >> $RESULTS_FILE echo "Source: testvid.webm ($SOURCE_SIZE_MB MB, $SOURCE_DURATION s, $SOURCE_RESOLUTION)" >> $RESULTS_FILE echo "" >> $RESULTS_FILE echo "Mode,Codec,CRF,Preset,Container,Audio Bitrate,Encoding Time,Output Size (MB),Size Reduction (%),Compression Ratio" >> $RESULTS_FILE # Function to run encoding test run_test() { local mode=$1 local mode_name=$2 local codec_flag=$3 local codec_name=$4 echo "๐Ÿš€ Testing $mode_name mode ($codec_name)..." echo "Mode: $mode_name ($codec_name)" >> $RESULTS_FILE # Clean up any previous outputs rm -f *-*-*-GWELL.* # Record start time start_time=$(date +%s) # Run encoding with codec flag if ./gwencoder --$mode $codec_flag; then # Record end time end_time=$(date +%s) encoding_time=$((end_time - start_time)) # Find the output file (look for any GWELL file) output_file=$(ls *-*-*-GWELL.* 2>/dev/null | head -1) if [ -f "$output_file" ]; then output_size=$(stat -c%s "$output_file") output_size_mb=$(echo "scale=2; $output_size / 1024 / 1024" | bc) size_reduction=$(echo "scale=2; (($SOURCE_SIZE - $output_size) * 100) / $SOURCE_SIZE" | bc) compression_ratio=$(echo "scale=2; $SOURCE_SIZE / $output_size" | bc) echo "โœ… $mode_name ($codec_name) completed in ${encoding_time}s" echo " Output: $output_file" echo " Size: $output_size_mb MB" echo " Reduction: ${size_reduction}%" echo " Compression: ${compression_ratio}:1" echo "" # Extract settings based on mode and codec case $mode in "fast") case $codec_flag in "") echo "fast,AV1,28,10,mkv,64,$encoding_time,$output_size_mb,$size_reduction,$compression_ratio" >> $RESULTS_FILE ;; "--x264") echo "fast,H264,28,10,mkv,64,$encoding_time,$output_size_mb,$size_reduction,$compression_ratio" >> $RESULTS_FILE ;; "--nvhevc") echo "fast,NVHEVC,26,fast,mkv,64,$encoding_time,$output_size_mb,$size_reduction,$compression_ratio" >> $RESULTS_FILE ;; esac ;; "web") case $codec_flag in "") echo "web,AV1,35,10,webm,64,$encoding_time,$output_size_mb,$size_reduction,$compression_ratio" >> $RESULTS_FILE ;; "--x264") echo "web,H264,35,10,mkv,64,$encoding_time,$output_size_mb,$size_reduction,$compression_ratio" >> $RESULTS_FILE ;; "--nvhevc") echo "web,NVHEVC,28,medium,mp4,64,$encoding_time,$output_size_mb,$size_reduction,$compression_ratio" >> $RESULTS_FILE ;; esac ;; "tiny") case $codec_flag in "") echo "tiny,AV1,42,8,mp4,48,$encoding_time,$output_size_mb,$size_reduction,$compression_ratio" >> $RESULTS_FILE ;; "--x264") echo "tiny,H264,42,fast,mp4,48,$encoding_time,$output_size_mb,$size_reduction,$compression_ratio" >> $RESULTS_FILE ;; "--nvhevc") echo "tiny,NVHEVC,30,fast,mp4,48,$encoding_time,$output_size_mb,$size_reduction,$compression_ratio" >> $RESULTS_FILE ;; esac ;; "hq") case $codec_flag in "") echo "hq,AV1,22,6,mkv,96,$encoding_time,$output_size_mb,$size_reduction,$compression_ratio" >> $RESULTS_FILE ;; "--x264") echo "hq,H264,22,medium,mkv,96,$encoding_time,$output_size_mb,$size_reduction,$compression_ratio" >> $RESULTS_FILE ;; "--nvhevc") echo "hq,NVHEVC,22,medium,mkv,96,$encoding_time,$output_size_mb,$size_reduction,$compression_ratio" >> $RESULTS_FILE ;; esac ;; "slow") case $codec_flag in "") echo "slow,AV1,18,4,mkv,128,$encoding_time,$output_size_mb,$size_reduction,$compression_ratio" >> $RESULTS_FILE ;; "--x264") echo "slow,H264,18,slow,mkv,128,$encoding_time,$output_size_mb,$size_reduction,$compression_ratio" >> $RESULTS_FILE ;; "--nvhevc") echo "slow,NVHEVC,18,slow,mkv,128,$encoding_time,$output_size_mb,$size_reduction,$compression_ratio" >> $RESULTS_FILE ;; esac ;; esac else echo "โŒ No output file found for $mode_name ($codec_name)" echo "ERROR: No output file generated" >> $RESULTS_FILE fi else echo "โŒ $mode_name ($codec_name) encoding failed" echo "ERROR: Encoding failed" >> $RESULTS_FILE fi echo "" >> $RESULTS_FILE echo "---" >> $RESULTS_FILE echo "" } # Check if gwencoder exists if [ ! -f "./gwencoder" ]; then echo "๐Ÿ”จ Building gwencoder..." if [ -f "./build.sh" ]; then ./build.sh else echo "โŒ Build script not found. Please build manually." exit 1 fi fi echo "๐Ÿ“‹ TESTING ALL ENCODING MODES WITH ALL CODECS" echo "=============================================" echo "" # Test all modes with all codec variants echo "๐ŸŽฌ Testing Fast mode..." run_test "fast" "Fast" "" "AV1" run_test "fast" "Fast" "--x264" "H.264" run_test "fast" "Fast" "--nvhevc" "NVENC HEVC" echo "๐ŸŒ Testing Web mode..." run_test "web" "Web" "" "AV1" run_test "web" "Web" "--x264" "H.264" run_test "web" "Web" "--nvhevc" "NVENC HEVC" echo "๐Ÿ“ฆ Testing Tiny mode..." run_test "tiny" "Tiny" "" "AV1" run_test "tiny" "Tiny" "--x264" "H.264" run_test "tiny" "Tiny" "--nvhevc" "NVENC HEVC" echo "๐ŸŽฏ Testing HQ mode..." run_test "hq" "HQ" "" "AV1" run_test "hq" "HQ" "--x264" "H.264" run_test "hq" "HQ" "--nvhevc" "NVENC HEVC" echo "๐ŸŒ Testing Slow mode..." run_test "slow" "Slow" "" "AV1" run_test "slow" "Slow" "--x264" "H.264" run_test "slow" "Slow" "--nvhevc" "NVENC HEVC" echo "๐Ÿ“Š FINAL RESULTS SUMMARY" echo "========================" echo "" # Display results table echo "Mode | Codec | CRF | Preset | Container | Audio | Time(s) | Size(MB) | Reduction | Compression" echo "----------------|----------|-----|--------|-----------|-------|---------|----------|-----------|------------" # Parse results and display tail -n +6 $RESULTS_FILE | grep -v "^$" | grep -v "^---$" | grep -v "^ERROR" | while IFS=',' read -r mode codec crf preset container audio time size reduction compression; do printf "%-15s | %-8s | %-3s | %-6s | %-9s | %-5s | %-7s | %-8s | %-9s | %-11s\n" "$mode" "$codec" "$crf" "$preset" "$container" "$audio" "$time" "$size" "$reduction%" "${compression}:1" done echo "" echo "๐Ÿ“ Results saved to: $RESULTS_FILE" echo "" # Show file sizes echo "๐Ÿ“ OUTPUT FILES:" echo "================" ls -lh *-*-*-GWELL.* 2>/dev/null | awk '{print $5, $9}' | while read size file; do echo "$size - $file" done echo "" echo "๐ŸŽฏ NEW ENCODING MODES:" echo "======================" echo "" echo "Updated encoding modes with new defaults:" echo "โ€ข --fast โ†’ Daily driver, quick turnaround (CRF 28, MKV, Opus 64kbps)" echo "โ€ข --web โ†’ Streaming, Discord, web upload (CRF 35, WEBM, Opus 64kbps)" echo "โ€ข --tiny โ†’ Maximum compression (CRF 42, MP4, Opus 48kbps)" echo "โ€ข --hq โ†’ High quality archival (CRF 22, MKV, Opus 96kbps)" echo "โ€ข --slow โ†’ Best possible quality (CRF 18, MKV, Opus 128kbps)" echo "" echo "All modes support AV1 (default), H.264/x264, and NVIDIA NVENC HEVC codecs!" echo "" echo "โœ… Testing complete!"