Skip to content

Commit

Permalink
+semver:major Made MediaInfo look for the FFprobe exe in the same loc…
Browse files Browse the repository at this point in the history
…ation as FFmpeg and also on the system path).

Made FFmpegRunner explicitly a static class (technically a breaking change, though all methods were already static).
Made FFmpegRunner look for FFmpeg on the path before trying to find a version installed for Audacity (which is unlikely to succeed anyway).
Renamed FFmpegRunner.FfmpegMinimumVersion property to MinimumVersion.
Significant refactoring in FFmpegRunner and MediaInfo
Made private utility functions in FFmpegRunner and MediaInfo into local functions so they would not accidentally be called by other methods in those classes.
Added some test cases for MediaInfo.FFprobeFolder setter
  • Loading branch information
tombogle committed Nov 22, 2024
1 parent 99e9bc4 commit 4a8106a
Show file tree
Hide file tree
Showing 6 changed files with 212 additions and 165 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- [SIL.Archiving] Added public property isValid to IMDIPackage.
- [SIL.Archiving] Added public event InitializationFailed to IMDIArchivingDlgViewModel.
- [SIL.Archiving] Added the following properties to ArchivingDlgViewModel as an alternative way to customize the initial summary displayed: GetOverriddenPreArchivingMessages, InitialFileGroupDisplayMessageType, OverrideGetFileGroupDisplayMessage
- [SIL.Media] Added FFmpegRunner.FfmpegMinimumVersion property.
- [SIL.Media] Added FFmpegRunner.MinimumVersion property (also used by MediaInfo for FFprobe).

### Changed

Expand Down Expand Up @@ -83,11 +83,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- [SIL.Media] Upgraded irrKlang to v. 1.6.
- [SIL.Media] In FFmpegRunner, changed ExtractMp3Audio, ExtractOggAudio, ExtractAudio, and ChangeNumberOfAudioChannels to use LocateAndRememberFFmpeg instead of LocateFFmpeg. This is potentially a breaking change but only in the edge case where an app does not install FFmpeg and the user installs it while running the app.
- [SIL.Media] Made the Windows implementation of ISimpleAudioSession more robust in that it will attempt to create an irrKlang-based recorder even if there is no audio output device enabled.
- [SIL.Media] Made FFmpegRunner explicitly a static class (technically a breaking change, though all methods were already static).
- [SIL.Media] Made FFmpegRunner look for the exe on the path before trying to find a version installed for Audacity (which is unlikely to succeed anyway).
- [SIL.Media] Made MediaInfo look for the FFprobe exe in the same location as FFmpeg when the application has specified the location for it or when it was previously located in one of the expected locations. Also made it more robust by making it more likely to find FFprobe (when it is on the system path).

### Fixed
- [SIL.Archiving] Fixed typo in RampArchivingDlgViewModel for Ethnomusicology performance collection.
- [SIL.Archiving] Changed URLs that used http: to https: in resource EmptyMets.xml.
- [SIL.Core.Desktop] Implemented GetDefaultProgramForFileType (as trenamed) in a way that works on Windows 11, Mono (probably) and MacOS (untested).
- [SIL.Media] MediaInfo.HaveNecessaryComponents properly returns true if FFprobe is on the system path.
- [SIL.Media] Made MediaInfo.FFprobeFolder look for and return the folder when first accessed, even if no prior call to the setter or other action had caused it t be found.

### Removed

Expand Down
2 changes: 1 addition & 1 deletion SIL.Core/CommandLineProcessing/CommandLineRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public bool Abort(int secondsBeforeTimeout)
}

/// <summary>
/// use this one if you're doing a long running task that you'll have running in a thread,
/// use this one if you're doing a long-running task that you'll have running in a thread,
/// so that you need a way to abort it
/// </summary>
public ExecutionResult Start(string exePath, string arguments, Encoding encoding,
Expand Down
8 changes: 4 additions & 4 deletions SIL.Media.Tests/FFmpegRunnerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,30 @@ public void HaveNecessaryComponents_NoExplicitMinVersion_ReturnsTrue()
[TestCase(4, 9)]
public void HaveNecessaryComponents_TwoDigitMinVersion_ReturnsTrue(int major, int minor)
{
FFmpegRunner.FfmpegMinimumVersion = new Version(major, minor);
FFmpegRunner.MinimumVersion = new Version(major, minor);
Assert.IsTrue(FFmpegRunner.HaveNecessaryComponents);
}

[TestCase(5, 1, 1)]
[TestCase(5, 0, 0)]
public void HaveNecessaryComponents_ThreeDigitMinVersion_ReturnsTrue(int major, int minor, int build)
{
FFmpegRunner.FfmpegMinimumVersion = new Version(major, minor, build);
FFmpegRunner.MinimumVersion = new Version(major, minor, build);
Assert.IsTrue(FFmpegRunner.HaveNecessaryComponents);
}

[TestCase(5, 1, 1, 0)]
[TestCase(5, 0, 0, 9)]
public void HaveNecessaryComponents_FourDigitMinVersion_ReturnsTrue(int major, int minor, int build, int revision)
{
FFmpegRunner.FfmpegMinimumVersion = new Version(major, minor, build, revision);
FFmpegRunner.MinimumVersion = new Version(major, minor, build, revision);
Assert.IsTrue(FFmpegRunner.HaveNecessaryComponents);
}

[Test]
public void HaveNecessaryComponents_ReallyHighVersionThatDoesNotExist_ReturnsFalse()
{
FFmpegRunner.FfmpegMinimumVersion = new Version(int.MaxValue, int.MaxValue);
FFmpegRunner.MinimumVersion = new Version(int.MaxValue, int.MaxValue);
Assert.IsFalse(FFmpegRunner.HaveNecessaryComponents);
}

Expand Down
31 changes: 30 additions & 1 deletion SIL.Media.Tests/MediaInfoTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.IO;
using NUnit.Framework;
using SIL.IO;
using SIL.Media.Tests.Properties;
Expand All @@ -24,7 +25,35 @@ public void CheckRequirements()
[Test]
public void HaveNecessaryComponents_ReturnsTrue()
{
Assert.IsTrue(MediaInfo.HaveNecessaryComponents);
Assert.IsTrue(MediaInfo.HaveNecessaryComponents,
"FFprobe was expected to have been found on system path or in a known location.");
}

[TestCase(null)]
[TestCase("")]
public void SetFFprobeFolder_ToNullOrEmpty_HaveNecessaryComponentsReturnsTrue(string presetFolder)
{
MediaInfo.FFprobeFolder = presetFolder;
Assert.IsTrue(MediaInfo.HaveNecessaryComponents,
"FFprobe was expected to have been found on system path or in a known location.");
}

[Test]
public void SetFFprobeFolder_ToNonexistentFolder_ThrowsDirectoryNotFoundException()
{
Assert.That(() =>
{
MediaInfo.FFprobeFolder = "D:\\ThereIsNoWayThi5F0lderShould\\exist";
}, Throws.Exception.InstanceOf<DirectoryNotFoundException>());
}

[Test]
public void SetFFprobeFolder_ToFolderWithoutFFprobe_ThrowsFileNotFoundException()
{
Assert.That(() =>
{
MediaInfo.FFprobeFolder = Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments);
}, Throws.Exception.InstanceOf<FileNotFoundException>());
}

[Test]
Expand Down
Loading

0 comments on commit 4a8106a

Please sign in to comment.