2020-03-01 12:55:57 +01:00
|
|
|
|
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
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void Probe_Success_FromStream()
|
|
|
|
|
{
|
|
|
|
|
var output = new FFProbe();
|
|
|
|
|
|
|
|
|
|
using (var stream = File.OpenRead(VideoLibrary.LocalVideo.FullName))
|
|
|
|
|
{
|
|
|
|
|
var info = output.ParseVideoInfo(stream);
|
|
|
|
|
Assert.AreEqual(13, info.Duration.Seconds);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void Probe_Success_FromStream_Async()
|
|
|
|
|
{
|
|
|
|
|
var output = new FFProbe();
|
|
|
|
|
|
|
|
|
|
using (var stream = File.OpenRead(VideoLibrary.LocalVideo.FullName))
|
|
|
|
|
{
|
|
|
|
|
var info = output.ParseVideoInfoAsync(stream).WaitForResult();
|
2020-05-10 11:41:53 +02:00
|
|
|
|
|
2020-04-28 14:21:48 +02:00
|
|
|
|
Assert.AreEqual(13, info.Duration.Seconds);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-03-01 12:55:57 +01:00
|
|
|
|
}
|
|
|
|
|
}
|