mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2025-12-15 02:25:44 +00:00
Update code after update from main
This commit is contained in:
parent
ca305cd8cd
commit
c60e217a2f
2 changed files with 124 additions and 21 deletions
|
|
@ -18,12 +18,17 @@ namespace FFMpegCore.Test;
|
|||
public class VideoTest
|
||||
{
|
||||
private const int BaseTimeoutMilliseconds = 15_000;
|
||||
|
||||
private string _segmentPathSource = "";
|
||||
|
||||
public TestContext TestContext { get; set; }
|
||||
|
||||
[TestInitialize]
|
||||
public void Setup()
|
||||
{
|
||||
_segmentPathSource = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid()}-");
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
public void Cleanup()
|
||||
{
|
||||
|
|
@ -32,7 +37,6 @@ public class VideoTest
|
|||
File.Delete(file);
|
||||
}
|
||||
}
|
||||
public TestContext TestContext { get; set; }
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
|
|
@ -1087,5 +1091,99 @@ public class VideoTest
|
|||
Assert.AreEqual("h264", outputInfo.PrimaryVideoStream.CodecName);
|
||||
Assert.AreEqual("aac", outputInfo.PrimaryAudioStream!.CodecName);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_Segmented_File_Output()
|
||||
{
|
||||
using var input = File.OpenRead(TestResources.WebmVideo);
|
||||
var success = FFMpegArguments
|
||||
.FromPipeInput(new StreamPipeSource(input))
|
||||
.OutPutToSegmentedFiles(
|
||||
new SegmentArgument($"{_segmentPathSource}%Y-%m-%d_%H-%M-%S.mkv", true, segmentOptions => segmentOptions
|
||||
.Strftime(true)
|
||||
.Wrap()
|
||||
.Time()
|
||||
.ResetTimeStamps()),
|
||||
options => options
|
||||
.CopyChannel()
|
||||
.WithVideoCodec("h264")
|
||||
.ForceFormat("matroska")
|
||||
.WithConstantRateFactor(21)
|
||||
.WithVideoBitrate(3000)
|
||||
.WithFastStart()
|
||||
.WithVideoFilters(filterOptions => filterOptions
|
||||
.Scale(VideoSize.Hd)
|
||||
.DrawText(DrawTextOptions.Create(@"'%{localtime}.%{eif\:1M*t-1K*trunc(t*1K)\:d\:3}'",
|
||||
@"C:/Users/yan.gauthier/AppData/Local/Microsoft/Windows/Fonts/Roboto-Regular.ttf")
|
||||
.WithParameter("fontcolor", "yellow")
|
||||
.WithParameter("fontsize", "40")
|
||||
.WithParameter("x", "(w-text_w)")
|
||||
.WithParameter("y", "(h - text_h)")
|
||||
.WithParameter("rate", "19")
|
||||
)
|
||||
)
|
||||
)
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously(false);
|
||||
Assert.IsTrue(success);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_MultiOutput_With_Segmented_File_Output()
|
||||
{
|
||||
using var input = File.OpenRead(TestResources.WebmVideo);
|
||||
var success = FFMpegArguments
|
||||
.FromPipeInput(new StreamPipeSource(input))
|
||||
.MultiOutput(args => args
|
||||
.OutputToFile($"{_segmentPathSource}2", true, options => options
|
||||
.CopyChannel()
|
||||
.WithVideoCodec("mjpeg")
|
||||
.ForceFormat("matroska")
|
||||
.WithConstantRateFactor(21)
|
||||
.WithVideoBitrate(4000)
|
||||
.WithFastStart()
|
||||
.WithVideoFilters(filterOptions => filterOptions
|
||||
.Scale(VideoSize.Hd)
|
||||
.DrawText(DrawTextOptions.Create(@"'%{localtime}.%{eif\:1M*t-1K*trunc(t*1K)\:d\:3}'",
|
||||
@"C:/Users/yan.gauthier/AppData/Local/Microsoft/Windows/Fonts/Roboto-Regular.ttf")
|
||||
.WithParameter("fontcolor", "yellow")
|
||||
.WithParameter("fontsize", "40")
|
||||
.WithParameter("x", "(w-text_w)")
|
||||
.WithParameter("y", "(h - text_h)")
|
||||
.WithParameter("rate", "19")
|
||||
)
|
||||
)
|
||||
)
|
||||
.OutPutToSegmentedFiles(
|
||||
new SegmentArgument($"{_segmentPathSource}%Y-%m-%d_%H-%M-%S.mkv", true, segmentOptions => segmentOptions
|
||||
.Strftime(true)
|
||||
.Wrap()
|
||||
.Time()
|
||||
.ResetTimeStamps()),
|
||||
options => options
|
||||
.CopyChannel()
|
||||
.WithVideoCodec("h264")
|
||||
.ForceFormat("matroska")
|
||||
.WithConstantRateFactor(21)
|
||||
.WithVideoBitrate(3000)
|
||||
.WithFastStart()
|
||||
.WithVideoFilters(filterOptions => filterOptions
|
||||
.Scale(VideoSize.Hd)
|
||||
.DrawText(DrawTextOptions.Create(@"'%{localtime}.%{eif\:1M*t-1K*trunc(t*1K)\:d\:3}'",
|
||||
@"C:/Users/yan.gauthier/AppData/Local/Microsoft/Windows/Fonts/Roboto-Regular.ttf")
|
||||
.WithParameter("fontcolor", "yellow")
|
||||
.WithParameter("fontsize", "40")
|
||||
.WithParameter("x", "(w-text_w)")
|
||||
.WithParameter("y", "(h - text_h)")
|
||||
.WithParameter("rate", "19")
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously(false);
|
||||
Assert.IsTrue(success);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -151,7 +151,12 @@ public sealed class FFMpegArguments : FFMpegArgumentsBase
|
|||
{
|
||||
return ToProcessor(new OutputPipeArgument(reader), addArguments);
|
||||
}
|
||||
public FFMpegArgumentProcessor OutPutToSegmentedFiles(SegmentArgument segmentArgument, Action<FFMpegArgumentOptions>? addArguments = null) => ToProcessor(new OutputSegmentArgument(segmentArgument), addArguments);
|
||||
|
||||
public FFMpegArgumentProcessor OutPutToSegmentedFiles(SegmentArgument segmentArgument, Action<FFMpegArgumentOptions>? addArguments = null)
|
||||
{
|
||||
return ToProcessor(new OutputSegmentArgument(segmentArgument), addArguments);
|
||||
}
|
||||
|
||||
private FFMpegArgumentProcessor ToProcessor(IOutputArgument argument, Action<FFMpegArgumentOptions>? addArguments)
|
||||
{
|
||||
var args = new FFMpegArgumentOptions();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue