Merge branch 'refactor'

Former-commit-id: af1bc4a80f
This commit is contained in:
Malte Rosenbjerg 2020-05-10 14:17:24 +02:00
commit f5ee7cd22e
3 changed files with 29 additions and 24 deletions

View file

@ -6,7 +6,6 @@
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using FFMpegCore.Arguments;
using FFMpegCore.Exceptions;
using FFMpegCore.Pipes;
@ -69,7 +68,7 @@ private void ConvertFromStreamPipe(VideoType type, params IArgument[] inputArgum
try
{
var input = FFProbe.Analyse(VideoLibrary.LocalVideoWebm.FullName);
using (var inputStream = System.IO.File.OpenRead(input.Path))
using (var inputStream = File.OpenRead(input.Path))
{
var pipeSource = new StreamPipeDataWriter(inputStream);
var arguments = FFMpegArguments.FromPipe(pipeSource);
@ -208,13 +207,6 @@ public void Convert(VideoType type, params IArgument[] inputArguments)
}
}
public void ConvertFromPipe(VideoType type, params IArgument[] inputArguments)
{
ConvertFromPipe(type, PixelFormat.Format24bppRgb, inputArguments);
ConvertFromPipe(type, PixelFormat.Format32bppArgb, inputArguments);
ConvertFromPipe(type, PixelFormat.Format48bppRgb, inputArguments);
}
public void ConvertFromPipe(VideoType type, PixelFormat fmt, params IArgument[] inputArguments)
{
var output = Input.OutputLocation(type);
@ -275,10 +267,13 @@ public void Video_ToMP4_Args()
Convert(VideoType.Mp4, new VideoCodecArgument(VideoCodec.LibX264));
}
[TestMethod]
public void Video_ToMP4_Args_Pipe()
[DataTestMethod]
[DataRow(PixelFormat.Format24bppRgb)]
[DataRow(PixelFormat.Format32bppArgb)]
// [DataRow(PixelFormat.Format48bppRgb)]
public void Video_ToMP4_Args_Pipe(PixelFormat pixelFormat)
{
ConvertFromPipe(VideoType.Mp4, new VideoCodecArgument(VideoCodec.LibX264));
ConvertFromPipe(VideoType.Mp4, pixelFormat, new VideoCodecArgument(VideoCodec.LibX264));
}
[TestMethod]
@ -348,10 +343,13 @@ public void Video_ToTS_Args()
new ForceFormatArgument(VideoCodec.MpegTs));
}
[TestMethod]
public void Video_ToTS_Args_Pipe()
[DataTestMethod]
[DataRow(PixelFormat.Format24bppRgb)]
[DataRow(PixelFormat.Format32bppArgb)]
// [DataRow(PixelFormat.Format48bppRgb)]
public void Video_ToTS_Args_Pipe(PixelFormat pixelFormat)
{
ConvertFromPipe(VideoType.Ts, new ForceFormatArgument(VideoCodec.MpegTs));
ConvertFromPipe(VideoType.Ts, pixelFormat, new ForceFormatArgument(VideoCodec.MpegTs));
}
[TestMethod]
@ -366,10 +364,13 @@ public void Video_ToOGV_Resize_Args()
Convert(VideoType.Ogv, new ScaleArgument(VideoSize.Ed), new VideoCodecArgument(VideoCodec.LibTheora));
}
[TestMethod]
public void Video_ToOGV_Resize_Args_Pipe()
[DataTestMethod]
[DataRow(PixelFormat.Format24bppRgb)]
[DataRow(PixelFormat.Format32bppArgb)]
// [DataRow(PixelFormat.Format48bppRgb)]
public void Video_ToOGV_Resize_Args_Pipe(PixelFormat pixelFormat)
{
ConvertFromPipe(VideoType.Ogv, new ScaleArgument(VideoSize.Ed), new VideoCodecArgument(VideoCodec.LibTheora));
ConvertFromPipe(VideoType.Ogv, pixelFormat, new ScaleArgument(VideoSize.Ed), new VideoCodecArgument(VideoCodec.LibTheora));
}
[TestMethod]
@ -384,10 +385,13 @@ public void Video_ToMP4_Resize_Args()
Convert(VideoType.Mp4, new ScaleArgument(VideoSize.Ld), new VideoCodecArgument(VideoCodec.LibX264));
}
[TestMethod]
public void Video_ToMP4_Resize_Args_Pipe()
[DataTestMethod]
[DataRow(PixelFormat.Format24bppRgb)]
[DataRow(PixelFormat.Format32bppArgb)]
// [DataRow(PixelFormat.Format48bppRgb)]
public void Video_ToMP4_Resize_Args_Pipe(PixelFormat pixelFormat)
{
ConvertFromPipe(VideoType.Mp4, new ScaleArgument(VideoSize.Ld), new VideoCodecArgument(VideoCodec.LibX264));
ConvertFromPipe(VideoType.Mp4, pixelFormat, new ScaleArgument(VideoSize.Ld), new VideoCodecArgument(VideoCodec.LibX264));
}
[TestMethod]
@ -508,6 +512,7 @@ public void Video_Join_Image_Sequence()
});
var success = FFMpeg.JoinImageSequence(VideoLibrary.ImageJoinOutput.FullName, images: imageSet.ToArray());
Assert.IsTrue(success);
var result = FFProbe.Analyse(VideoLibrary.ImageJoinOutput.FullName);
VideoLibrary.ImageJoinOutput.Refresh();

View file

@ -63,12 +63,12 @@ public async Task WriteDataAsync(System.IO.Stream stream)
{
if (_framesEnumerator.Current != null)
{
await _framesEnumerator.Current.SerializeAsync(stream);
await _framesEnumerator.Current.SerializeAsync(stream).ConfigureAwait(false);
}
while (_framesEnumerator.MoveNext())
{
await _framesEnumerator.Current!.SerializeAsync(stream);
await _framesEnumerator.Current!.SerializeAsync(stream).ConfigureAwait(false);
}
}

View file

@ -28,7 +28,7 @@
<ItemGroup>
<PackageReference Include="Instances" Version="1.5.0" />
<PackageReference Include="System.Drawing.Common" Version="4.5.1" />
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
<PackageReference Include="System.Text.Json" Version="4.7.1" />
</ItemGroup>