mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-10 08:34:12 +01:00
Merge branch 'refactor'
This commit is contained in:
commit
af1bc4a80f
3 changed files with 29 additions and 24 deletions
|
@ -6,7 +6,6 @@
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using FFMpegCore.Arguments;
|
using FFMpegCore.Arguments;
|
||||||
using FFMpegCore.Exceptions;
|
using FFMpegCore.Exceptions;
|
||||||
using FFMpegCore.Pipes;
|
using FFMpegCore.Pipes;
|
||||||
|
@ -69,7 +68,7 @@ private void ConvertFromStreamPipe(VideoType type, params IArgument[] inputArgum
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var input = FFProbe.Analyse(VideoLibrary.LocalVideoWebm.FullName);
|
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 pipeSource = new StreamPipeDataWriter(inputStream);
|
||||||
var arguments = FFMpegArguments.FromPipe(pipeSource);
|
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)
|
public void ConvertFromPipe(VideoType type, PixelFormat fmt, params IArgument[] inputArguments)
|
||||||
{
|
{
|
||||||
var output = Input.OutputLocation(type);
|
var output = Input.OutputLocation(type);
|
||||||
|
@ -275,10 +267,13 @@ public void Video_ToMP4_Args()
|
||||||
Convert(VideoType.Mp4, new VideoCodecArgument(VideoCodec.LibX264));
|
Convert(VideoType.Mp4, new VideoCodecArgument(VideoCodec.LibX264));
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[DataTestMethod]
|
||||||
public void Video_ToMP4_Args_Pipe()
|
[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]
|
[TestMethod]
|
||||||
|
@ -348,10 +343,13 @@ public void Video_ToTS_Args()
|
||||||
new ForceFormatArgument(VideoCodec.MpegTs));
|
new ForceFormatArgument(VideoCodec.MpegTs));
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[DataTestMethod]
|
||||||
public void Video_ToTS_Args_Pipe()
|
[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]
|
[TestMethod]
|
||||||
|
@ -366,10 +364,13 @@ public void Video_ToOGV_Resize_Args()
|
||||||
Convert(VideoType.Ogv, new ScaleArgument(VideoSize.Ed), new VideoCodecArgument(VideoCodec.LibTheora));
|
Convert(VideoType.Ogv, new ScaleArgument(VideoSize.Ed), new VideoCodecArgument(VideoCodec.LibTheora));
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[DataTestMethod]
|
||||||
public void Video_ToOGV_Resize_Args_Pipe()
|
[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]
|
[TestMethod]
|
||||||
|
@ -384,10 +385,13 @@ public void Video_ToMP4_Resize_Args()
|
||||||
Convert(VideoType.Mp4, new ScaleArgument(VideoSize.Ld), new VideoCodecArgument(VideoCodec.LibX264));
|
Convert(VideoType.Mp4, new ScaleArgument(VideoSize.Ld), new VideoCodecArgument(VideoCodec.LibX264));
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[DataTestMethod]
|
||||||
public void Video_ToMP4_Resize_Args_Pipe()
|
[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]
|
[TestMethod]
|
||||||
|
@ -508,6 +512,7 @@ public void Video_Join_Image_Sequence()
|
||||||
});
|
});
|
||||||
|
|
||||||
var success = FFMpeg.JoinImageSequence(VideoLibrary.ImageJoinOutput.FullName, images: imageSet.ToArray());
|
var success = FFMpeg.JoinImageSequence(VideoLibrary.ImageJoinOutput.FullName, images: imageSet.ToArray());
|
||||||
|
Assert.IsTrue(success);
|
||||||
var result = FFProbe.Analyse(VideoLibrary.ImageJoinOutput.FullName);
|
var result = FFProbe.Analyse(VideoLibrary.ImageJoinOutput.FullName);
|
||||||
|
|
||||||
VideoLibrary.ImageJoinOutput.Refresh();
|
VideoLibrary.ImageJoinOutput.Refresh();
|
||||||
|
|
|
@ -63,12 +63,12 @@ public async Task WriteDataAsync(System.IO.Stream stream)
|
||||||
{
|
{
|
||||||
if (_framesEnumerator.Current != null)
|
if (_framesEnumerator.Current != null)
|
||||||
{
|
{
|
||||||
await _framesEnumerator.Current.SerializeAsync(stream);
|
await _framesEnumerator.Current.SerializeAsync(stream).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (_framesEnumerator.MoveNext())
|
while (_framesEnumerator.MoveNext())
|
||||||
{
|
{
|
||||||
await _framesEnumerator.Current!.SerializeAsync(stream);
|
await _framesEnumerator.Current!.SerializeAsync(stream).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Instances" Version="1.5.0" />
|
<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" />
|
<PackageReference Include="System.Text.Json" Version="4.7.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue