# CLAUDE.md This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. ## Project Overview This is a Go CLI application for professional video frame analysis and comparison. The project provides tools to count frames in videos, compare individual frames, analyze differences between two videos, and perform comprehensive frame persistence analysis for single videos with DigitalFoundry-style CSV output. ## Core Architecture The application is built using: - **CLI Framework**: urfave/cli/v3 for command-line interface - **Video Processing**: AlexEidt/Vidio library for video file handling with FPS detection - **Image Processing**: Standard Go image libraries for frame comparison - **CSV Export**: Built-in CSV generation for professional video analysis visualization ### Main Components - **CLI Commands**: Five main commands for comprehensive frame analysis operations - **Frame Comparison**: Pixel-level comparison with configurable tolerance using squared difference - **Video Processing**: Frame-by-frame video analysis with streaming support and memory-efficient processing - **Two-Pass Analysis**: Advanced frame persistence analysis with pre-calculated total durations - **CSV Generation**: DigitalFoundry-style data export for professional visualization tools ### Key Functions - `count_video_frames()`: Counts total frames in a video file - `compare_frames()`: Compares two frames with tolerance-based difference detection - `compare_frames_alt()`: Alternative frame comparison using exact pixel matching - `countUniqueVideoFrames()`: Analyzes differences between corresponding frames in two videos - `analyzeFramePersistence()`: **Main feature** - Two-pass frame persistence analysis with CSV export - `isDiffUInt8WithTolerance()`: Pixel comparison with configurable tolerance threshold - `imageToRGBA()`: Converts images to RGBA format for consistent processing ## Development Commands ### Build and Run ```bash # Normal build go build -o fps-go-brr . ./fps-go-brr [args] # Optimized compact build (requires UPX) ./build-compact.sh ./fps-go-brr-compact [args] # Cross-platform build (requires gox) go install github.com/mitchellh/gox@latest gox -os="darwin" -os="linux" -os="windows" -arch="amd64" -arch="arm64" -osarch="linux/386" -osarch="windows/386" ``` ### Testing ```bash go test ./... ``` ### Module Management ```bash go mod tidy go mod download ``` ### Release Builds - Forgejo Actions automatically build and release cross-platform binaries on tag pushes - Uses custom runner: `9950x` - Cross-compilation via `gox` for Darwin (macOS), Linux, and Windows - Multiple architectures: amd64, arm64, and 386 (Linux/Windows only) - UPX compression applied to Linux builds only using `--brute` flag - Platform-specific `.tar.gz` bundles for distribution ## Repository Information - **Main Repository**: https://git.aria.coffee/aria/fps-go-brr (Personal Forgejo instance) - **Mirror**: https://github.com/BuyMyMojo/fps-go-brr (GitHub - accepts PRs and issues) - **Dual Licensed**: MIT OR Apache-2.0 (SPDX-License-Identifier: MIT OR Apache-2.0) - **Copyright**: 2025 Aria, Wicket ### Inspirations This project draws inspiration from: - Digital Foundry (YouTube) - Professional video game performance analysis - Brazil Pixel (YouTube) - Technical video analysis and frame rate studies - TRDrop (GitHub) - Raw video analysis program for framerate estimation - Original Python implementation - Early proof-of-concept for frame persistence analysis ## Memories - The forgejo workflow runner is executed as root so it does not need to use root - Updated workflow to use `gox` for cross-compilation and create platform-specific `.tar.gz` bundles ## CLI Usage Available commands: - `count-frames