FFMpegCore/FFMpegCore.Test/AudioTest.cs

84 lines
2.3 KiB
C#
Raw Permalink Normal View History

2019-02-08 11:19:40 +01:00
using FFMpegCore.Enums;
2019-03-03 00:33:00 +01:00
using FFMpegCore.Test.Resources;
2019-02-08 11:19:40 +01:00
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.IO;
2019-03-03 00:33:00 +01:00
namespace FFMpegCore.Test
2019-02-08 11:19:40 +01:00
{
[TestClass]
public class AudioTest : BaseTest
{
[TestMethod]
public void Audio_Remove()
{
var output = Input.OutputLocation(VideoType.Mp4);
try
{
Encoder.Mute(VideoInfo.FromFileInfo(Input), output);
Assert.IsTrue(File.Exists(output.FullName));
}
finally
{
if (File.Exists(output.FullName))
output.Delete();
}
}
[TestMethod]
public void Audio_Save()
{
var output = Input.OutputLocation(AudioType.Mp3);
try
{
Encoder.ExtractAudio(VideoInfo.FromFileInfo(Input), output);
Assert.IsTrue(File.Exists(output.FullName));
}
finally
{
if (File.Exists(output.FullName))
output.Delete();
}
}
[TestMethod]
public void Audio_Add()
{
var output = Input.OutputLocation(VideoType.Mp4);
try
{
var input = VideoInfo.FromFileInfo(VideoLibrary.LocalVideoNoAudio);
Encoder.ReplaceAudio(input, VideoLibrary.LocalAudio, output);
Assert.AreEqual(input.Duration, VideoInfo.FromFileInfo(output).Duration);
Assert.IsTrue(File.Exists(output.FullName));
}
finally
{
if (File.Exists(output.FullName))
output.Delete();
}
}
[TestMethod]
public void Image_AddAudio()
{
var output = Input.OutputLocation(VideoType.Mp4);
try
{
var result = Encoder.PosterWithAudio(new FileInfo(VideoLibrary.LocalCover.FullName), VideoLibrary.LocalAudio, output);
Assert.IsTrue(result.Duration.TotalSeconds > 0);
Assert.IsTrue(result.Exists);
}
finally
{
if (File.Exists(output.FullName))
output.Delete();
}
}
}
}