FFMpegCore/FFMpegCore.Test/FFProbeTests.cs

60 lines
1.6 KiB
C#
Raw Permalink Normal View History

using System.IO;
using FFMpegCore.Enums;
using FFMpegCore.FFMPEG;
using FFMpegCore.FFMPEG.Argument;
using FFMpegCore.Test.Resources;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
namespace FFMpegCore.Test
{
[TestClass]
public class FFProbeTests
{
[TestMethod]
public void Probe_TooLongOutput()
{
var output = new FFProbe(5);
Assert.ThrowsException<JsonSerializationException>(() =>
{
output.ParseVideoInfo(VideoLibrary.LocalVideo.FullName);
});
}
[TestMethod]
public void Probe_Success()
{
var output = new FFProbe();
var info = output.ParseVideoInfo(VideoLibrary.LocalVideo.FullName);
Assert.AreEqual(13, info.Duration.Seconds);
}
2020-04-28 14:21:48 +02:00
2020-05-10 12:07:28 +02:00
[TestMethod, Timeout(10000)]
2020-04-28 14:21:48 +02:00
public void Probe_Success_FromStream()
{
var output = new FFProbe();
2020-05-10 11:46:33 +02:00
using (var stream = File.OpenRead(VideoLibrary.LocalVideoWebm.FullName))
2020-04-28 14:21:48 +02:00
{
var info = output.ParseVideoInfo(stream);
2020-05-10 11:46:33 +02:00
Assert.AreEqual(10, info.Duration.Seconds);
2020-04-28 14:21:48 +02:00
}
}
2020-05-10 12:07:28 +02:00
[TestMethod, Timeout(10000)]
2020-04-28 14:21:48 +02:00
public void Probe_Success_FromStream_Async()
{
var output = new FFProbe();
2020-05-10 11:46:33 +02:00
using (var stream = File.OpenRead(VideoLibrary.LocalVideoWebm.FullName))
2020-04-28 14:21:48 +02:00
{
var info = output.ParseVideoInfoAsync(stream).WaitForResult();
2020-05-10 11:41:53 +02:00
2020-05-10 11:46:33 +02:00
Assert.AreEqual(10, info.Duration.Seconds);
2020-04-28 14:21:48 +02:00
}
}
}
}