From 6d726a102967e9e1b4a0585023043bf56814fad2 Mon Sep 17 00:00:00 2001 From: feos Date: Mon, 30 May 2022 14:45:17 +0300 Subject: [PATCH] depend on versioned ffmpeg release instead of nightly (#3259) * depend on versioned ffmpeg release instead of nightly * Use 4.4.1, fix download/extract on Linux * update windows build link Co-authored-by: YoshiRulz --- .../AVOut/FFmpegDownloaderForm.cs | 11 ++++++++--- src/BizHawk.Common/FFmpegService.cs | 17 +++++++++-------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/BizHawk.Client.EmuHawk/AVOut/FFmpegDownloaderForm.cs b/src/BizHawk.Client.EmuHawk/AVOut/FFmpegDownloaderForm.cs index 90402449f5..a30f25a641 100644 --- a/src/BizHawk.Client.EmuHawk/AVOut/FFmpegDownloaderForm.cs +++ b/src/BizHawk.Client.EmuHawk/AVOut/FFmpegDownloaderForm.cs @@ -20,7 +20,7 @@ namespace BizHawk.Client.EmuHawk txtLocation.Text = FFmpegService.FFmpegPath; txtUrl.Text = FFmpegService.Url; - if (OSTailoredCode.IsUnixHost) textBox1.Text = string.Join("\n", textBox1.Text.Split('\n').Take(3)) + $"\n\n(Linux user: Create a symlink with the below filename pointing to the ffmpeg binary with version {FFmpegService.Version}.)"; + if (OSTailoredCode.IsUnixHost) textBox1.Text = string.Join("\n", textBox1.Text.Split('\n').Take(3)) + "\n\n(Linux user: If installing manually, you can use a symlink.)"; } private int pct = 0; @@ -81,15 +81,20 @@ namespace BizHawk.Client.EmuHawk //try acquiring file using (var hf = new HawkFile(fn)) { - using (var exe = hf.BindFirstOf(".exe")) + using (var exe = OSTailoredCode.IsUnixHost ? hf.BindArchiveMember("ffmpeg") : hf.BindFirstOf(".exe")) { - var data = exe.ReadAllBytes(); + var data = exe!.ReadAllBytes(); //last chance. exiting, don't dump the new ffmpeg file if (exiting) return; File.WriteAllBytes(FFmpegService.FFmpegPath, data); + if (OSTailoredCode.IsUnixHost) + { + OSTailoredCode.ConstructSubshell("chmod", $"+x {FFmpegService.FFmpegPath}", checkStdout: false).Start(); + Thread.Sleep(50); // Linux I/O flush idk + } } } diff --git a/src/BizHawk.Common/FFmpegService.cs b/src/BizHawk.Common/FFmpegService.cs index 72fc6285fe..1fd249c9d3 100644 --- a/src/BizHawk.Common/FFmpegService.cs +++ b/src/BizHawk.Common/FFmpegService.cs @@ -12,13 +12,15 @@ namespace BizHawk.Common { public static class FFmpegService { + private const string BIN_HOST_URI_LINUX_X64 = "https://github.com/TASEmulators/ffmpeg-binaries/raw/master/ffmpeg-4.4.1-static-linux-x64.7z"; + + private const string BIN_HOST_URI_WIN_X64 = "https://github.com/TASEmulators/ffmpeg-binaries/raw/master/ffmpeg-4.4.1-static-windows-x64.7z"; + + private const string VERSION = "ffmpeg version 4.4.1"; + public static string FFmpegPath = string.Empty; // always updated in DiscoHawk.Program/EmuHawk.Program - //could return a different version for different operating systems.. shouldnt be hard. - public static readonly string Version = "N-92462-g529debc987"; - - //likewise - public static readonly string Url = "https://github.com/TASEmulators/ffmpeg-binaries/blob/master/ffmpeg-20181118-529debc-win64-static_ffmpeg.7z?raw=true"; + public static readonly string Url = OSTailoredCode.IsUnixHost ? BIN_HOST_URI_LINUX_X64 : BIN_HOST_URI_WIN_X64; public class AudioQueryResult { @@ -48,13 +50,12 @@ namespace BizHawk.Common { try { - string stdout = Run("-version").Text; - if (stdout.Contains($"ffmpeg version {Version}")) return true; + return Run("-version").Text.Contains(VERSION); } catch { + return false; } - return false; } public struct RunResults