Skip to content

Commit 568a65c

Browse files
committed
Add x86 support for ffmpeg
1 parent 472b5f7 commit 568a65c

5 files changed

Lines changed: 30 additions & 39 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using System.IO;
3+
using System.Reflection;
4+
5+
namespace SoftSled.Components.AudioVisual.VideoFpsLab {
6+
7+
/// <summary>
8+
/// Resolves the bundled native FFmpeg DLL directory for the CURRENT
9+
/// process architecture. The DLLs ship under
10+
/// <c>&lt;exeDir&gt;\Tools\ffmpeg\x64</c> and <c>...\x86</c>; a 32-bit
11+
/// process must load the x86 set and a 64-bit process the x64 set, or
12+
/// FFmpeg.AutoGen fails to load avcodec/avutil with a "module not found".
13+
/// Mirrors the arch selection the native RDP loader uses in App.xaml.cs.
14+
/// </summary>
15+
internal static class FfmpegRuntime {
16+
public static string NativeDir() {
17+
string baseDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
18+
string arch = Environment.Is64BitProcess ? "x64" : "x86";
19+
return Path.Combine(baseDir, "Tools", "ffmpeg", arch);
20+
}
21+
}
22+
}

SoftSledWPF/Components/AudioVisual/VideoFpsLab/LibAvVideoDecoder.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ public void Start() {
6767
// Point FFmpeg.AutoGen at the same native DLLs FFME uses. Safe to
6868
// set even if FFME already loaded them (AutoGen resolves lazily).
6969
try {
70-
string ffmpegDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
71-
+ "\\Tools\\ffmpeg\\x64";
72-
if (string.IsNullOrEmpty(ffmpeg.RootPath)) ffmpeg.RootPath = ffmpegDir;
70+
if (string.IsNullOrEmpty(ffmpeg.RootPath)) ffmpeg.RootPath = FfmpegRuntime.NativeDir();
7371
} catch (Exception ex) {
7472
_log?.LogError($"[libav-video] could not set ffmpeg.RootPath: {ex.Message}");
7573
}

SoftSledWPF/Components/AudioVisual/VideoFpsLab/LibAvVideoPushDecoder.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ public LibAvVideoPushDecoder(AVCodecID codecId, int clockHz, Logger log) {
6565
public void Start() {
6666
if (_worker != null) return;
6767
try {
68-
string ffmpegDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
69-
+ "\\Tools\\ffmpeg\\x64";
70-
if (string.IsNullOrEmpty(ffmpeg.RootPath)) ffmpeg.RootPath = ffmpegDir;
68+
if (string.IsNullOrEmpty(ffmpeg.RootPath)) ffmpeg.RootPath = FfmpegRuntime.NativeDir();
7169
} catch (Exception ex) {
7270
_log?.LogError($"[libav-vpush] could not set ffmpeg.RootPath: {ex.Message}");
7371
}

SoftSledWPF/Components/Shell/ExtenderSessionControl.xaml.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -759,8 +759,7 @@ private void EnsureFfmeInitialised() {
759759
// ffmpeg.RootPath, which must be set process-wide before the first
760760
// ffmpeg call. Safe to set repeatedly.
761761
try {
762-
string ffmpegDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
763-
+ "\\Tools\\ffmpeg\\x64";
762+
string ffmpegDir = SoftSled.Components.AudioVisual.VideoFpsLab.FfmpegRuntime.NativeDir();
764763
FFmpeg.AutoGen.ffmpeg.RootPath = ffmpegDir;
765764
_avLogger?.LogInfo($"[ffmpeg] RootPath set to {ffmpegDir} " +
766765
$"(exists={System.IO.Directory.Exists(ffmpegDir)})");

SoftSledWPF/SoftSledWPF.csproj

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@
219219
<Compile Include="Components\AudioVisual\VideoFpsLab\LiveVideoTap.cs" />
220220
<Compile Include="Components\AudioVisual\VideoFpsLab\PtsFramePacer.cs" />
221221
<Compile Include="Components\AudioVisual\VideoFpsLab\D3DImagePresenter.cs" />
222+
<Compile Include="Components\AudioVisual\VideoFpsLab\FfmpegRuntime.cs" />
222223
<Compile Include="Components\AudioVisual\ExternalSync\ExternalAudioFormat.cs" />
223224
<Compile Include="Components\AudioVisual\ExternalSync\LibAvAudioDecoder.cs" />
224225
<Compile Include="Components\AudioVisual\ExternalSync\NAudioMasterRenderer.cs" />
@@ -443,37 +444,10 @@
443444
<Content Include="native\x86\softsled-rdp.dll" />
444445
<Content Include="native\x86\winpr3.dll" />
445446
<Content Include="native\x86\z.dll" />
446-
<Content Include="Tools\ffmpeg\x64\avcodec-58.dll">
447-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
448-
</Content>
449-
<Content Include="Tools\ffmpeg\x64\avdevice-58.dll">
450-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
451-
</Content>
452-
<Content Include="Tools\ffmpeg\x64\avfilter-7.dll">
453-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
454-
</Content>
455-
<Content Include="Tools\ffmpeg\x64\avformat-58.dll">
456-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
457-
</Content>
458-
<Content Include="Tools\ffmpeg\x64\avutil-56.dll">
459-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
460-
</Content>
461-
<Content Include="Tools\ffmpeg\x64\ffmpeg.exe">
462-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
463-
</Content>
464-
<Content Include="Tools\ffmpeg\x64\ffplay.exe">
465-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
466-
</Content>
467-
<Content Include="Tools\ffmpeg\x64\ffprobe.exe">
468-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
469-
</Content>
470-
<Content Include="Tools\ffmpeg\x64\postproc-55.dll">
471-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
472-
</Content>
473-
<Content Include="Tools\ffmpeg\x64\swresample-3.dll">
474-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
475-
</Content>
476-
<Content Include="Tools\ffmpeg\x64\swscale-5.dll">
447+
<!-- Bundle the native FFmpeg DLLs for BOTH architectures, preserving the
448+
x64\ / x86\ subfolders in the output. FfmpegRuntime.NativeDir() selects
449+
the set matching the current process bitness at runtime. -->
450+
<Content Include="Tools\ffmpeg\**\*.*">
477451
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
478452
</Content>
479453
<Resource Include="wmc.bmp" />

0 commit comments

Comments
 (0)