mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-10 08:34:12 +01:00
Merge branch 'master' into refactor-tests
This commit is contained in:
commit
7fd7ae369d
8 changed files with 44 additions and 21 deletions
16
.github/workflows/ci.yml
vendored
16
.github/workflows/ci.yml
vendored
|
@ -11,15 +11,15 @@ on:
|
|||
|
||||
jobs:
|
||||
ci:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 7
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [windows-latest, ubuntu-latest]
|
||||
timeout-minutes: 4
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Checkout
|
||||
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
|
||||
uses: FedericoCarboni/setup-ffmpeg@v1-beta
|
||||
- name: Test with dotnet
|
||||
run: dotnet test --logger GitHubActions
|
||||
|
|
11
.github/workflows/release.yml
vendored
11
.github/workflows/release.yml
vendored
|
@ -7,13 +7,10 @@ jobs:
|
|||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Setup .NET Core
|
||||
uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: 3.1
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v1
|
||||
- name: Build solution
|
||||
run: dotnet build --output build
|
||||
run: dotnet build --output build -c Release
|
||||
- name: Publish NuGet package
|
||||
run: dotnet nuget push "build/*.nupkg" --skip-duplicate --source nuget.org --api-key ${{ secrets.NUGET_TOKEN }}
|
||||
run: dotnet nuget push "build/*.nupkg" --source nuget.org --api-key ${{ secrets.NUGET_TOKEN }}
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using FFMpegCore.Pipes;
|
||||
|
||||
namespace FFMpegCore.Test
|
||||
{
|
||||
|
@ -33,7 +35,23 @@ public void Audio_Save()
|
|||
Assert.IsTrue(!analysis.VideoStreams.Any());
|
||||
Assert.IsTrue(analysis.AudioStreams.Any());
|
||||
}
|
||||
|
||||
[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()
|
||||
{
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
<None Update="Resources\input_video_only_3sec.mp4">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Resources\audio.raw">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -37,7 +40,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="GitHubActionsTestLogger" Version="1.1.2" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
|
||||
</ItemGroup>
|
||||
|
|
BIN
FFMpegCore.Test/Resources/audio.raw
Normal file
BIN
FFMpegCore.Test/Resources/audio.raw
Normal file
Binary file not shown.
|
@ -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,9 +41,12 @@ 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");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,8 @@ public static Bitmap Snapshot(IMediaAnalysis source, Size? size = null, TimeSpan
|
|||
.ProcessSynchronously();
|
||||
|
||||
ms.Position = 0;
|
||||
return new Bitmap(ms);
|
||||
using var bitmap = new Bitmap(ms);
|
||||
return bitmap.Clone(new Rectangle(0, 0, bitmap.Width, bitmap.Height), bitmap.PixelFormat);
|
||||
}
|
||||
/// <summary>
|
||||
/// Saves a 'png' thumbnail to an in-memory bitmap
|
||||
|
|
|
@ -9,10 +9,9 @@
|
|||
<Version>3.0.0.0</Version>
|
||||
<AssemblyVersion>3.0.0.0</AssemblyVersion>
|
||||
<FileVersion>3.0.0.0</FileVersion>
|
||||
<PackageReleaseNotes>- Updated dependencies
|
||||
- Additional StreamPipeSink constructor</PackageReleaseNotes>
|
||||
<PackageReleaseNotes>- Fix NullReferenceException on Disconnect after Dispose</PackageReleaseNotes>
|
||||
<LangVersion>8</LangVersion>
|
||||
<PackageVersion>3.2.0</PackageVersion>
|
||||
<PackageVersion>3.2.1</PackageVersion>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<Authors>Malte Rosenbjerg, Vlad Jerca</Authors>
|
||||
<PackageTags>ffmpeg ffprobe convert video audio mediafile resize analyze muxing</PackageTags>
|
||||
|
|
Loading…
Reference in a new issue