2020-03-01 12:55:57 +01:00
|
|
|
|
using System.IO;
|
2020-05-08 11:07:51 +02:00
|
|
|
|
using System.Threading.Tasks;
|
2020-03-01 12:55:57 +01:00
|
|
|
|
using FFMpegCore.FFMPEG;
|
|
|
|
|
using FFMpegCore.Test.Resources;
|
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
|
|
|
|
|
|
namespace FFMpegCore.Test
|
|
|
|
|
{
|
|
|
|
|
[TestClass]
|
|
|
|
|
public class FFProbeTests
|
|
|
|
|
{
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void Probe_TooLongOutput()
|
|
|
|
|
{
|
2020-05-08 11:07:51 +02:00
|
|
|
|
Assert.ThrowsException<System.Text.Json.JsonException>(() => FFProbe.Analyse(VideoLibrary.LocalVideo.FullName, 5));
|
2020-03-01 12:55:57 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void Probe_Success()
|
|
|
|
|
{
|
2020-05-08 11:07:51 +02:00
|
|
|
|
var info = FFProbe.Analyse(VideoLibrary.LocalVideo.FullName);
|
2020-03-01 12:55:57 +01:00
|
|
|
|
Assert.AreEqual(13, info.Duration.Seconds);
|
|
|
|
|
}
|
2020-04-28 14:21:48 +02:00
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void Probe_Success_FromStream()
|
|
|
|
|
{
|
2020-05-08 11:07:51 +02:00
|
|
|
|
using var stream = File.OpenRead(VideoLibrary.LocalVideo.FullName);
|
|
|
|
|
var info = FFProbe.Analyse(stream);
|
|
|
|
|
Assert.AreEqual(13, info.Duration.Seconds);
|
2020-04-28 14:21:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
2020-05-08 11:07:51 +02:00
|
|
|
|
public async Task Probe_Success_FromStream_Async()
|
2020-04-28 14:21:48 +02:00
|
|
|
|
{
|
2020-05-08 11:07:51 +02:00
|
|
|
|
await using var stream = File.OpenRead(VideoLibrary.LocalVideo.FullName);
|
|
|
|
|
var info = await FFProbe.AnalyseAsync(stream);
|
|
|
|
|
Assert.AreEqual(13, info.Duration.Seconds);
|
2020-04-28 14:21:48 +02:00
|
|
|
|
}
|
2020-03-01 12:55:57 +01:00
|
|
|
|
}
|
|
|
|
|
}
|