diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bf2fe72..33573f9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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. diff --git a/.gitignore b/.gitignore index c9355b8..455c466 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,9 @@ dist-ssr *.njsproj *.sln *.sw? +*.zip + +src-tauri/*.exe # test files src-tauri/tests/audio/*.srt diff --git a/ffmpeg_setup.ps1 b/ffmpeg_setup.ps1 new file mode 100644 index 0000000..50c997d --- /dev/null +++ b/ffmpeg_setup.ps1 @@ -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 \ No newline at end of file diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index d0ab1ed..ecf09cb 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -331,8 +331,8 @@ fn setup_invoke_handlers(builder: tauri::Builder) -> tauri::Builder< fn main() -> Result<(), Box> { 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(); } diff --git a/src-tauri/tauri.windows.conf.json b/src-tauri/tauri.windows.conf.json index f03369a..97e7b6d 100644 --- a/src-tauri/tauri.windows.conf.json +++ b/src-tauri/tauri.windows.conf.json @@ -15,6 +15,6 @@ ] }, "bundle": { - "resources": [] + "resources": ["ffmpeg.exe", "ffplay.exe", "ffprobe.exe"] } } diff --git a/src-tauri/tauri.windows.cuda.conf.json b/src-tauri/tauri.windows.cuda.conf.json index 2e0125e..e4203ca 100644 --- a/src-tauri/tauri.windows.cuda.conf.json +++ b/src-tauri/tauri.windows.cuda.conf.json @@ -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" + ] } }