FFMpegCore/FFMpegCore.Test/AudioTest.cs
Malte Rosenbjerg 1dc7524ecd Revert "Cleanup"
This reverts commit d95f687e46.
2020-05-12 21:28:50 +02:00

82 lines
No EOL
2.5 KiB
C#

using System;
using FFMpegCore.Enums;
using FFMpegCore.Test.Resources;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.IO;
namespace FFMpegCore.Test
{
[TestClass]
public class AudioTest : BaseTest
{
[TestMethod]
public void Audio_Remove()
{
var output = Input.OutputLocation(VideoType.Mp4);
try
{
FFMpeg.Mute(Input.FullName, output);
Assert.IsTrue(File.Exists(output));
}
finally
{
if (File.Exists(output)) File.Delete(output);
}
}
[TestMethod]
public void Audio_Save()
{
var output = Input.OutputLocation(AudioType.Mp3);
try
{
FFMpeg.ExtractAudio(Input.FullName, output);
Assert.IsTrue(File.Exists(output));
}
finally
{
if (File.Exists(output)) File.Delete(output);
}
}
[TestMethod]
public void Audio_Add()
{
var output = Input.OutputLocation(VideoType.Mp4);
try
{
var success = FFMpeg.ReplaceAudio(VideoLibrary.LocalVideoNoAudio.FullName, VideoLibrary.LocalAudio.FullName, output);
Assert.IsTrue(success);
var audioAnalysis = FFProbe.Analyse(VideoLibrary.LocalVideoNoAudio.FullName);
var videoAnalysis = FFProbe.Analyse(VideoLibrary.LocalAudio.FullName);
var outputAnalysis = FFProbe.Analyse(output);
Assert.AreEqual(Math.Max(videoAnalysis.Duration.TotalSeconds, audioAnalysis.Duration.TotalSeconds), outputAnalysis.Duration.TotalSeconds, 0.15);
Assert.IsTrue(File.Exists(output));
}
finally
{
if (File.Exists(output)) File.Delete(output);
}
}
[TestMethod]
public void Image_AddAudio()
{
var output = Input.OutputLocation(VideoType.Mp4);
try
{
FFMpeg.PosterWithAudio(VideoLibrary.LocalCover.FullName, VideoLibrary.LocalAudio.FullName, output);
var analysis = FFProbe.Analyse(VideoLibrary.LocalAudio.FullName);
Assert.IsTrue(analysis.Duration.TotalSeconds > 0);
Assert.IsTrue(File.Exists(output));
}
finally
{
if (File.Exists(output)) File.Delete(output);
}
}
}
}