Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved unit tests for FFmpegRunner #1364

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1642a26
Improved unit tests for FFmpegRunner to not take over display, be dep…
tombogle Nov 8, 2024
dba4714
Merge branch 'master' into improve-tests
tombogle Nov 14, 2024
cf3c597
Added CI build step to install ffprobe and ffmpeg before running tests.
tombogle Nov 16, 2024
43cbcd6
add a line to debug ffmpeg path
hahn-kev Nov 18, 2024
6d7fb90
search the path for ffmpeg
hahn-kev Nov 18, 2024
c82cea2
Removed inaccurate comments
tombogle Nov 18, 2024
6baf806
Merge branch 'master' into improve-tests
tombogle Nov 19, 2024
4fabb1a
+semver:minor Added FFmpegRunner.FfmpegMinimumVersion static property
tombogle Nov 19, 2024
590ffc1
Merge branch 'master' into improve-tests
tombogle Nov 19, 2024
02b8bfb
Added not in CHANGELOG.md about enhanced FFmpegRunner functionality: …
tombogle Nov 19, 2024
4901250
Allow (the only non-ignored test in) AudioPlayerTests to run on CI build
tombogle Nov 19, 2024
568c08b
Attempt to enable tests that use audio devices on CI build
tombogle Nov 19, 2024
b7e5120
Upgraded irrKlang DLLs to version 1.6
tombogle Nov 19, 2024
77ea045
Added specific NUnit cataegories for RequiresAudioOutputDevice and Re…
tombogle Nov 21, 2024
c0e0ce0
Added FFmpeg to path in build.yml
tombogle Nov 21, 2024
99e9bc4
removed `add-path` step from build.yml since that command is disabled…
tombogle Nov 21, 2024
10d0165
+semver:major Made MediaInfo look for the FFprobe exe in the same loc…
tombogle Nov 22, 2024
a77c5d9
Added installation of ffmpeg to Appveyor build and excluded tests tha…
tombogle Nov 22, 2024
2e5e58c
Try installing ab-audio-cable to see if that simulates presence of au…
tombogle Nov 22, 2024
269b695
Merge branch 'master' into improve-tests
tombogle Dec 3, 2024
c1e1801
Since vb-audio-cable doesn't have a choco installer, try downloading …
tombogle Dec 3, 2024
9b9df3a
Removed silent switch from VB Cable installer so I see if it is maybe…
tombogle Dec 5, 2024
f36c07d
Run VB Cable installer with elevated privileges and verify installation
tombogle Dec 5, 2024
bd14972
Gave up on installing a virtual audio input driver on Github build ag…
tombogle Dec 6, 2024
7ec02ef
See if explicitly creating SLDR cache folder will enable test setup t…
tombogle Dec 6, 2024
9b61be8
Revert "See if explicitly creating SLDR cache folder will enable test…
tombogle Dec 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 45 additions & 2 deletions SIL.Media.Tests/FFmpegRunnerTests.cs
hahn-kev marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.IO;
using FFMpegCore;
using NUnit.Framework;
using SIL.IO;
using SIL.Media.Tests.Properties;
Expand Down Expand Up @@ -79,7 +81,27 @@ public void MakeLowQualityCompressedAudio_CreatesFile()
var outputPath = originalAudioPath.Replace("mp3", "low.mp3");
FFmpegRunner.MakeLowQualityCompressedAudio(originalAudioPath, outputPath, new ConsoleProgress());
Assert.IsTrue(File.Exists(outputPath));
System.Diagnostics.Process.Start(outputPath);

var mediaInfoOrig = FFProbe.Analyse(file.Path);
var mediaInfo = FFProbe.Analyse(outputPath);

// Validate resolution and bit rate
Assert.That(mediaInfo.PrimaryVideoStream, Is.Null);
Assert.That(mediaInfo.PrimaryAudioStream, Is.Not.Null);
Assert.That(mediaInfo.AudioStreams.Count, Is.EqualTo(1));
Assert.That(mediaInfo.PrimaryAudioStream.Channels, Is.EqualTo(1));
Assert.That(mediaInfo.Format.BitRate, Is.LessThan(mediaInfoOrig.Format.BitRate));
Assert.That(mediaInfo.PrimaryAudioStream.SampleRateHz, Is.EqualTo(8000));
try
{
// When running the by-hand test, the default media player might leave this
// locked, so this cleanup will fail.
RobustFile.Delete(outputPath);
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
}

Expand All @@ -92,7 +114,28 @@ public void MakeLowQualitySmallVideo_CreatesFile()
var outputPath = file.Path.Replace("wmv", "low.wmv");
FFmpegRunner.MakeLowQualitySmallVideo(file.Path, outputPath, 0, new ConsoleProgress());
Assert.IsTrue(File.Exists(outputPath));
System.Diagnostics.Process.Start(outputPath);

var mediaInfoOrig = FFProbe.Analyse(file.Path);
var mediaInfo = FFProbe.Analyse(outputPath);

// Validate resolution and bit rate
Assert.That(mediaInfo.PrimaryVideoStream, Is.Not.Null);
Assert.That(mediaInfo.VideoStreams.Count, Is.EqualTo(1));
Assert.That(mediaInfo.PrimaryAudioStream, Is.Not.Null);
Assert.That(mediaInfo.AudioStreams.Count, Is.EqualTo(1));
Assert.That(mediaInfo.PrimaryVideoStream.Width, Is.EqualTo(160));
Assert.That(mediaInfo.PrimaryVideoStream.Height, Is.EqualTo(120));
Assert.That(mediaInfo.Format.BitRate, Is.LessThan(mediaInfoOrig.Format.BitRate));
try
{
// When running the by-hand test, the default media player might leave this
// locked, so this cleanup will fail.
RobustFile.Delete(outputPath);
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions SIL.Media/FFmpegRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public static ExecutionResult ExtractMp3Audio(string inputPath, string outputPat
var arguments = $"-i \"{inputPath}\" -vn {mp3LameCodecArg} -ac {channels} \"{outputPath}\"";
var result = RunFFmpeg(arguments, progress);

//hide a meaningless error produced by some versions of liblame
// Hide a meaningless error produced by some versions of liblame
if (result.StandardError.Contains("lame: output buffer too small")
&& File.Exists(outputPath))
{
Expand Down Expand Up @@ -203,7 +203,7 @@ public static ExecutionResult ExtractOggAudio(string inputPath, string outputPat
var arguments = $"-i \"{inputPath}\" -vn -acodec vorbis -ac {channels} \"{outputPath}\"";
var result = RunFFmpeg(arguments, progress);

//hide a meaningless error produced by some versions of liblame
// Hide a meaningless error produced by some versions of liblame
if (result.StandardError.Contains("lame: output buffer too small")
&& File.Exists(outputPath))
{
Expand Down Expand Up @@ -294,7 +294,7 @@ private static ExecutionResult ExtractAudio(string inputPath, string outputPath,

var result = RunFFmpeg(arguments, progress);

//hide a meaningless error produced by some versions of liblame
// Hide a meaningless error produced by some versions of liblame
if (result.StandardError.Contains("lame: output buffer too small")
&& File.Exists(outputPath))
{
Expand Down Expand Up @@ -328,7 +328,7 @@ public static ExecutionResult ChangeNumberOfAudioChannels(string inputPath,

var result = RunFFmpeg(arguments, progress);

//hide a meaningless error produced by some versions of liblame
// Hide a meaningless error produced by some versions of liblame
if (result.StandardError.Contains("lame: output buffer too small") && File.Exists(outputPath))
{
var doctoredResult = new ExecutionResult
Expand Down Expand Up @@ -361,7 +361,7 @@ public static ExecutionResult MakeLowQualityCompressedAudio(string inputPath, st

var result = RunFFmpeg(arguments, progress);

//hide a meaningless error produced by some versions of liblame
// Hide a meaningless error produced by some versions of liblame
if (result.StandardError.Contains("lame: output buffer too small")
&& File.Exists(outputPath))
{
Expand Down Expand Up @@ -404,7 +404,7 @@ public static ExecutionResult MakeLowQualitySmallVideo(string inputPath, string

var result = RunFFmpeg(arguments, progress);

//hide a meaningless error produced by some versions of liblame
// Hide a meaningless error produced by some versions of liblame
if (result.StandardError.Contains("lame: output buffer too small")
&& File.Exists(outputPath))
{
Expand Down
Loading