Skip to content

Conversation

Copy link

Copilot AI commented Dec 26, 2025

Summary: Automatically download the correct architecture for FFMPEG

  • Explore repository structure and understand FFmpeg download mechanism
  • Identify the two PackageManager files that need updates (SentryReplay and TeslaCam)
  • Research available ARM64 FFmpeg builds for Windows
  • Implement architecture detection using RuntimeInformation.ProcessArchitecture
  • Update URL selection logic to choose correct build based on architecture
  • Add basic unit tests for PackageManager
  • Address code review feedback (updated comment about zip structure)
  • Run security checks (passed with 0 alerts)
  • Show error for unsupported architectures instead of defaulting to x64
  • Delete unused duplicate TeslaCam folder
  • Fix extraction to flatten bin directory for proper FFmpeg detection
  • Address code review feedback (removed magic number)
  • Complete and finalize

Changes Made

Core Implementation

  • Added architecture detection using System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture
  • Switched FFmpeg source from GyanD/codexffmpeg to BtbN/FFmpeg-Builds
    • GyanD only provides x64 Windows builds
    • BtbN provides both x64 and ARM64 Windows builds
  • Updated PackageManager.cs (SentryReplay namespace only)
  • Removed duplicate TeslaCam folder that was not part of the solution
  • Fixed extraction logic to flatten the bin directory so FFmpeg is found correctly

Error Handling for Unsupported Architectures

Throws PlatformNotSupportedException for any architecture other than x64 or ARM64:

_ => throw new PlatformNotSupportedException($"Unsupported architecture: {architecture}. Only x64 and ARM64 are supported.")

Extraction Fix

The BtbN FFmpeg builds have a nested structure with files in a bin directory. The extraction now flattens this structure so that ffmpeg.exe and DLLs are extracted directly to the ffmpeg/ folder instead of ffmpeg/ffmpeg-master-latest-winarm64-gpl-shared/bin/. This ensures the application can find FFmpeg after download.

Before: ffmpeg/ffmpeg-master-latest-winarm64-gpl-shared/bin/ffmpeg.exe
After: ffmpeg/ffmpeg.exe

URL Selection Logic

private static string GetFFmpegDownloadUrl()
{
    var architecture = RuntimeInformation.ProcessArchitecture;
    
    return architecture switch
    {
        Architecture.Arm64 => "https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-winarm64-gpl-shared.zip",
        Architecture.X64 => "https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl-shared.zip",
        _ => throw new PlatformNotSupportedException($"Unsupported architecture: {architecture}. Only x64 and ARM64 are supported.")
    };
}

Testing & Validation

  • ✅ Added PackageManagerTests.cs with basic unit tests
  • ✅ Code review completed - all feedback addressed
  • ✅ CodeQL security scan passed (0 alerts)

Files Modified

  • SentryReplay/PackageManager.cs - Added architecture detection, error handling, and flattened extraction
  • SentryReplay.Tests/PackageManagerTests.cs - New test file for PackageManager
  • Deleted: Entire TeslaCam/ folder (was not part of solution, duplicate code)

How It Works

  1. When the user clicks to download FFmpeg, the app detects the system architecture
  2. For ARM64 systems, it downloads the ARM64-specific build
  3. For x64 systems, it downloads the x64 build
  4. For any other architecture, it throws a clear error message
  5. The extraction logic flattens the bin directory structure so FFmpeg files are directly in the ffmpeg/ folder
  6. The application successfully finds and loads FFmpeg from the flattened structure
Original prompt

This section details on the original issue you should resolve

<issue_title>Automatically download the correct architecture for FFMPEG</issue_title>
<issue_description>arm64 needs the arm version</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits December 26, 2025 20:21
Co-authored-by: danielchalmers <7112040+danielchalmers@users.noreply.github.com>
Co-authored-by: danielchalmers <7112040+danielchalmers@users.noreply.github.com>
Copilot AI changed the title [WIP] Automatically download correct architecture for FFMPEG Auto-detect system architecture for FFmpeg downloads Dec 26, 2025
Copilot AI requested a review from danielchalmers December 26, 2025 20:25
@danielchalmers
Copy link
Owner

@copilot Show an error for unsupported architectures instead of defaulting to x64. Delete the unused duplicate TeslaCam folder because everything should be under the SentryReplay folder instead.

…folder

Co-authored-by: danielchalmers <7112040+danielchalmers@users.noreply.github.com>
Copy link
Author

Copilot AI commented Dec 26, 2025

@copilot Show an error for unsupported architectures instead of defaulting to x64. Delete the unused duplicate TeslaCam folder because everything should be under the SentryReplay folder instead.

Done in commit 9da72af:

  • Now throws PlatformNotSupportedException for unsupported architectures with a clear error message
  • Deleted the entire TeslaCam folder (not part of solution)

@danielchalmers danielchalmers marked this pull request as ready for review December 26, 2025 20:39
@danielchalmers
Copy link
Owner

@copilot it doesn't seem to be finding ffmpeg after downloading it. It just keeps saying "FFmpeg is required to play clips" even though it downloaded ".\SentryReplay-0.0.0-arm64\ffmpeg\ffmpeg-master-latest-winarm64-gpl-shared\bin\ffmpeg.exe"

Copilot AI and others added 2 commits December 26, 2025 22:09
Co-authored-by: danielchalmers <7112040+danielchalmers@users.noreply.github.com>
Co-authored-by: danielchalmers <7112040+danielchalmers@users.noreply.github.com>
Copy link
Author

Copilot AI commented Dec 26, 2025

@copilot it doesn't seem to be finding ffmpeg after downloading it. It just keeps saying "FFmpeg is required to play clips" even though it downloaded ".\SentryReplay-0.0.0-arm64\ffmpeg\ffmpeg-master-l...

Fixed in commit 1926a68. The BtbN builds have a nested bin directory structure that wasn't being flattened during extraction. The extraction logic now flattens the structure so ffmpeg.exe ends up in ffmpeg/ffmpeg.exe instead of ffmpeg/ffmpeg-master-latest-winarm64-gpl-shared/bin/ffmpeg.exe, allowing the application to find it correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automatically download the correct architecture for FFMPEG

2 participants