mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-10 08:34:12 +01:00
commit
bb0a7b3fc6
3 changed files with 41 additions and 18 deletions
13
.github/workflows/ci.yml
vendored
13
.github/workflows/ci.yml
vendored
|
@ -1,9 +1,18 @@
|
|||
name: CI
|
||||
on: [push, pull_request]
|
||||
|
||||
on:
|
||||
push:
|
||||
branches-ignore:
|
||||
- release
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
- release
|
||||
|
||||
jobs:
|
||||
ci:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
timeout-minutes: 7
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Prepare FFMpeg
|
||||
|
|
|
@ -656,23 +656,33 @@ public void Video_TranscodeInMemory()
|
|||
[TestMethod, Timeout(10000)]
|
||||
public async Task Video_Cancel_Async()
|
||||
{
|
||||
await using var resStream = new MemoryStream();
|
||||
var reader = new StreamPipeSink(resStream);
|
||||
var writer = new RawVideoPipeSource(BitmapSource.CreateBitmaps(512, System.Drawing.Imaging.PixelFormat.Format24bppRgb, 128, 128));
|
||||
var output = Input.OutputLocation(VideoType.Mp4);
|
||||
|
||||
var task = FFMpegArguments
|
||||
.FromPipeInput(writer)
|
||||
.OutputToPipe(reader, opt => opt
|
||||
.WithVideoCodec("vp9")
|
||||
.ForceFormat("webm"))
|
||||
.FromFileInput(VideoLibrary.LocalVideo)
|
||||
.OutputToFile(output, false, opt => opt
|
||||
.Resize(new Size(1000, 1000))
|
||||
.WithAudioCodec(AudioCodec.Aac)
|
||||
.WithVideoCodec(VideoCodec.LibX264)
|
||||
.WithConstantRateFactor(14)
|
||||
.WithSpeedPreset(Speed.VerySlow)
|
||||
.Loop(3))
|
||||
.CancellableThrough(out var cancel)
|
||||
.ProcessAsynchronously(false);
|
||||
|
||||
await Task.Delay(300);
|
||||
cancel();
|
||||
try
|
||||
{
|
||||
await Task.Delay(300);
|
||||
cancel();
|
||||
|
||||
var result = await task;
|
||||
Assert.IsFalse(result);
|
||||
var result = await task;
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (File.Exists(output))
|
||||
File.Delete(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,18 +51,20 @@ public bool ProcessSynchronously(bool throwOnError = true)
|
|||
|
||||
void OnCancelEvent(object sender, EventArgs args)
|
||||
{
|
||||
instance?.SendInput("q");
|
||||
instance.SendInput("q");
|
||||
cancellationTokenSource.Cancel();
|
||||
instance.Started = false;
|
||||
}
|
||||
CancelEvent += OnCancelEvent;
|
||||
instance.Exited += delegate { cancellationTokenSource.Cancel(); };
|
||||
|
||||
_ffMpegArguments.Pre();
|
||||
try
|
||||
{
|
||||
_ffMpegArguments.Pre();
|
||||
Task.WaitAll(instance.FinishedRunning().ContinueWith(t =>
|
||||
{
|
||||
errorCode = t.Result;
|
||||
cancellationTokenSource.Cancel();
|
||||
_ffMpegArguments.Post();
|
||||
}), _ffMpegArguments.During(cancellationTokenSource.Token));
|
||||
}
|
||||
|
@ -98,15 +100,17 @@ void OnCancelEvent(object sender, EventArgs args)
|
|||
{
|
||||
instance?.SendInput("q");
|
||||
cancellationTokenSource.Cancel();
|
||||
instance.Started = false;
|
||||
}
|
||||
CancelEvent += OnCancelEvent;
|
||||
|
||||
_ffMpegArguments.Pre();
|
||||
try
|
||||
{
|
||||
_ffMpegArguments.Pre();
|
||||
await Task.WhenAll(instance.FinishedRunning().ContinueWith(t =>
|
||||
{
|
||||
errorCode = t.Result;
|
||||
cancellationTokenSource.Cancel();
|
||||
_ffMpegArguments.Post();
|
||||
}), _ffMpegArguments.During(cancellationTokenSource.Token)).ConfigureAwait(false);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue