mirror of
https://github.com/Xinrea/bili-shadowreplay.git
synced 2025-11-24 20:15:34 +08:00
feat: bundle ffmpeg for installer on windows
This commit is contained in:
11
.github/workflows/main.yml
vendored
11
.github/workflows/main.yml
vendored
@@ -19,6 +19,9 @@ jobs:
|
||||
- platform: "windows-latest"
|
||||
args: "--features cuda"
|
||||
features: "cuda"
|
||||
- platform: "windows-latest"
|
||||
args: ""
|
||||
features: "none"
|
||||
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
@@ -61,6 +64,14 @@ jobs:
|
||||
with:
|
||||
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
|
||||
# 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.
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -22,6 +22,9 @@ dist-ssr
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
*.zip
|
||||
|
||||
src-tauri/*.exe
|
||||
|
||||
# test files
|
||||
src-tauri/tests/audio/*.srt
|
||||
|
||||
32
ffmpeg_setup.ps1
Normal file
32
ffmpeg_setup.ps1
Normal 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
|
||||
@@ -331,8 +331,8 @@ fn setup_invoke_handlers(builder: tauri::Builder<tauri::Wry>) -> tauri::Builder<
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let _ = fix_path_env::fix();
|
||||
// only auto download ffmpeg if it's not macOS
|
||||
if !cfg!(target_os = "macos") {
|
||||
// only auto download ffmpeg if it's linux
|
||||
if cfg!(target_os = "linux") {
|
||||
ffmpeg_sidecar::download::auto_download().unwrap();
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,6 @@
|
||||
]
|
||||
},
|
||||
"bundle": {
|
||||
"resources": []
|
||||
"resources": ["ffmpeg.exe", "ffplay.exe", "ffprobe.exe"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,13 @@
|
||||
]
|
||||
},
|
||||
"bundle": {
|
||||
"resources": ["cudart64*.dll", "cublas64*.dll", "cublasLt64*.dll"]
|
||||
"resources": [
|
||||
"ffmpeg.exe",
|
||||
"ffplay.exe",
|
||||
"ffprobe.exe",
|
||||
"cudart64*.dll",
|
||||
"cublas64*.dll",
|
||||
"cublasLt64*.dll"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user