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..ad3209b 100644 --- a/FFMpegCore.Test/FFMpegCore.Test.csproj +++ b/FFMpegCore.Test/FFMpegCore.Test.csproj @@ -27,6 +27,9 @@ PreserveNewest + + Always + 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