diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 994a569..c20f9f1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,9 +17,5 @@ jobs: - uses: actions/checkout@v1 - name: Prepare FFMpeg run: sudo apt-get update && sudo apt-get install -y ffmpeg - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 3.1.101 - name: Test with dotnet run: dotnet test --logger GitHubActions diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5f7efcd..7bb80ce 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,10 +8,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 3.1 - name: Build solution run: dotnet build --output build - name: Publish NuGet package diff --git a/FFMpegCore.Test/AudioTest.cs b/FFMpegCore.Test/AudioTest.cs index 552ca24..51d02ab 100644 --- a/FFMpegCore.Test/AudioTest.cs +++ b/FFMpegCore.Test/AudioTest.cs @@ -3,6 +3,8 @@ using FFMpegCore.Test.Resources; using Microsoft.VisualStudio.TestTools.UnitTesting; using System.IO; +using System.Threading.Tasks; +using FFMpegCore.Pipes; namespace FFMpegCore.Test { @@ -40,7 +42,23 @@ public void Audio_Save() if (File.Exists(output)) File.Delete(output); } } - + [TestMethod] + public async Task Audio_FromRaw() + { + await using var file = File.Open(VideoLibrary.LocalAudioRaw.FullName, FileMode.Open); + var memoryStream = new MemoryStream(); + await FFMpegArguments + .FromPipeInput(new StreamPipeSource(file), options => options.ForceFormat("s16le")) + .OutputToPipe(new StreamPipeSink(memoryStream), options => + { + options.WithAudioSamplingRate(48000); + options.WithAudioCodec("libopus"); + options.WithCustomArgument("-ac 2"); + options.ForceFormat("opus"); + }) + .ProcessAsynchronously(); + } + [TestMethod] public void Audio_Add() { diff --git a/FFMpegCore.Test/FFMpegCore.Test.csproj b/FFMpegCore.Test/FFMpegCore.Test.csproj index 59f2645..b232270 100644 --- a/FFMpegCore.Test/FFMpegCore.Test.csproj +++ b/FFMpegCore.Test/FFMpegCore.Test.csproj @@ -27,6 +27,9 @@ PreserveNewest + + Always + @@ -37,7 +40,7 @@ - + diff --git a/FFMpegCore.Test/Resources/VideoLibrary.cs b/FFMpegCore.Test/Resources/VideoLibrary.cs index 8bb0139..7e1da33 100644 --- a/FFMpegCore.Test/Resources/VideoLibrary.cs +++ b/FFMpegCore.Test/Resources/VideoLibrary.cs @@ -21,6 +21,7 @@ public static class VideoLibrary public static readonly FileInfo LocalVideoAudioOnly = new FileInfo($".{Path.DirectorySeparatorChar}Resources{Path.DirectorySeparatorChar}input_audio_only_10sec.mp4"); public static readonly FileInfo LocalVideoNoAudio = new FileInfo($".{Path.DirectorySeparatorChar}Resources{Path.DirectorySeparatorChar}input_video_only_3sec.mp4"); public static readonly FileInfo LocalAudio = new FileInfo($".{Path.DirectorySeparatorChar}Resources{Path.DirectorySeparatorChar}audio.mp3"); + public static readonly FileInfo LocalAudioRaw = new FileInfo($".{Path.DirectorySeparatorChar}Resources{Path.DirectorySeparatorChar}audio.raw"); public static readonly FileInfo LocalCover = new FileInfo($".{Path.DirectorySeparatorChar}Resources{Path.DirectorySeparatorChar}cover.png"); public static readonly FileInfo ImageDirectory = new FileInfo($".{Path.DirectorySeparatorChar}Resources{Path.DirectorySeparatorChar}images"); public static readonly FileInfo ImageJoinOutput = new FileInfo($".{Path.DirectorySeparatorChar}Resources{Path.DirectorySeparatorChar}images{Path.DirectorySeparatorChar}output.mp4"); diff --git a/FFMpegCore.Test/Resources/audio.raw b/FFMpegCore.Test/Resources/audio.raw new file mode 100644 index 0000000..c1811e9 Binary files /dev/null and b/FFMpegCore.Test/Resources/audio.raw differ diff --git a/FFMpegCore/FFMpeg/Arguments/PipeArgument.cs b/FFMpegCore/FFMpeg/Arguments/PipeArgument.cs index 4a6113a..3d451e9 100644 --- a/FFMpegCore/FFMpeg/Arguments/PipeArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/PipeArgument.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using System.IO.Pipes; using System.Threading; using System.Threading.Tasks; @@ -30,6 +31,7 @@ public void Pre() public void Post() { + Debug.WriteLine($"Disposing NamedPipeServerStream on {GetType().Name}"); Pipe?.Dispose(); Pipe = null!; } @@ -39,11 +41,13 @@ public async Task During(CancellationToken cancellationToken = default) try { await ProcessDataAsync(cancellationToken); + Debug.WriteLine($"Disconnecting NamedPipeServerStream on {GetType().Name}"); + Pipe.Disconnect(); } catch (TaskCanceledException) { + Debug.WriteLine($"ProcessDataAsync on {GetType().Name} cancelled"); } - Pipe.Disconnect(); } protected abstract Task ProcessDataAsync(CancellationToken token); diff --git a/FFMpegCore/FFMpegCore.csproj b/FFMpegCore/FFMpegCore.csproj index 54afd94..93c6d4e 100644 --- a/FFMpegCore/FFMpegCore.csproj +++ b/FFMpegCore/FFMpegCore.csproj @@ -9,10 +9,9 @@ 3.0.0.0 3.0.0.0 3.0.0.0 - - Updated dependencies -- Additional StreamPipeSink constructor + - Fix NullReferenceException on Disconnect after Dispose 8 - 3.2.0 + 3.2.1 MIT Malte Rosenbjerg, Vlad Jerca ffmpeg ffprobe convert video audio mediafile resize analyze muxing