feat: bundle ffmpeg for installer on windows

This commit is contained in:
Xinrea
2025-03-30 23:31:39 +08:00
parent c85c9206f6
commit 7d9428de14
6 changed files with 57 additions and 4 deletions

View File

@@ -19,6 +19,9 @@ jobs:
- platform: "windows-latest" - platform: "windows-latest"
args: "--features cuda" args: "--features cuda"
features: "cuda" features: "cuda"
- platform: "windows-latest"
args: ""
features: "none"
runs-on: ${{ matrix.platform }} runs-on: ${{ matrix.platform }}
steps: steps:
@@ -61,6 +64,14 @@ jobs:
with: with:
workspaces: "./src-tauri -> target" workspaces: "./src-tauri -> target"
- name: Setup ffmpeg
if: matrix.platform == 'windows-latest'
working-directory: ./
shell: pwsh
# running script ffmpeg_setup.ps1 to install ffmpeg on windows.
# This script is located in the root of the repository.
run: ./ffmpeg_setup.ps1
- name: install frontend dependencies - name: install frontend dependencies
# If you don't have `beforeBuildCommand` configured you may want to build your frontend here too. # If you don't have `beforeBuildCommand` configured you may want to build your frontend here too.
run: yarn install # change this to npm or pnpm depending on which one you use. run: yarn install # change this to npm or pnpm depending on which one you use.

3
.gitignore vendored
View File

@@ -22,6 +22,9 @@ dist-ssr
*.njsproj *.njsproj
*.sln *.sln
*.sw? *.sw?
*.zip
src-tauri/*.exe
# test files # test files
src-tauri/tests/audio/*.srt src-tauri/tests/audio/*.srt

32
ffmpeg_setup.ps1 Normal file
View File

@@ -0,0 +1,32 @@
# download ffmpeg from https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip
$ffmpegUrl = "https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip"
$ffmpegPath = "ffmpeg-release-essentials.zip"
# download the file if it doesn't exist
if (-not (Test-Path $ffmpegPath)) {
Invoke-WebRequest -Uri $ffmpegUrl -OutFile $ffmpegPath
}
# extract the 7z file
Add-Type -AssemblyName System.IO.Compression.FileSystem
$extractPath = "ffmpeg"
# check if the directory exists, if not create it
if (-not (Test-Path $extractPath)) {
New-Item -ItemType Directory -Path $extractPath
}
[System.IO.Compression.ZipFile]::ExtractToDirectory($ffmpegPath, $extractPath)
# move the bin directory to the src-tauri directory
# ffmpeg/ffmpeg-*-essentials_build/bin to src-tauri
$ffmpegDir = Get-ChildItem -Path $extractPath -Directory | Where-Object { $_.Name -match "ffmpeg-.*-essentials_build" }
if ($ffmpegDir) {
$binPath = Join-Path $ffmpegDir.FullName "bin"
} else {
Write-Host "No ffmpeg directory found in the extracted files."
exit 1
}
$destPath = Join-Path $PSScriptRoot "src-tauri"
Copy-Item -Path "$binPath/*" -Destination $destPath -Recurse
# remove the extracted directory
Remove-Item $extractPath -Recurse -Force

View File

@@ -331,8 +331,8 @@ fn setup_invoke_handlers(builder: tauri::Builder<tauri::Wry>) -> tauri::Builder<
fn main() -> Result<(), Box<dyn std::error::Error>> { fn main() -> Result<(), Box<dyn std::error::Error>> {
let _ = fix_path_env::fix(); let _ = fix_path_env::fix();
// only auto download ffmpeg if it's not macOS // only auto download ffmpeg if it's linux
if !cfg!(target_os = "macos") { if cfg!(target_os = "linux") {
ffmpeg_sidecar::download::auto_download().unwrap(); ffmpeg_sidecar::download::auto_download().unwrap();
} }

View File

@@ -15,6 +15,6 @@
] ]
}, },
"bundle": { "bundle": {
"resources": [] "resources": ["ffmpeg.exe", "ffplay.exe", "ffprobe.exe"]
} }
} }

View File

@@ -15,6 +15,13 @@
] ]
}, },
"bundle": { "bundle": {
"resources": ["cudart64*.dll", "cublas64*.dll", "cublasLt64*.dll"] "resources": [
"ffmpeg.exe",
"ffplay.exe",
"ffprobe.exe",
"cudart64*.dll",
"cublas64*.dll",
"cublasLt64*.dll"
]
} }
} }