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:
|
jobs:
|
||||||
ci:
|
ci:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ${{ matrix.os }}
|
||||||
timeout-minutes: 7
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [windows-latest, ubuntu-latest]
|
||||||
|
timeout-minutes: 4
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v1
|
||||||
- name: Prepare FFMpeg
|
- name: Prepare FFMpeg
|
||||||
run: sudo apt-get update && sudo apt-get install -y ffmpeg
|
uses: FedericoCarboni/setup-ffmpeg@v1-beta
|
||||||
- name: Setup .NET Core
|
|
||||||
uses: actions/setup-dotnet@v1
|
|
||||||
with:
|
|
||||||
dotnet-version: 3.1.101
|
|
||||||
- name: Test with dotnet
|
- name: Test with dotnet
|
||||||
run: dotnet test --logger GitHubActions
|
run: dotnet test --logger GitHubActions
|
||||||
|
|
11
.github/workflows/release.yml
vendored
11
.github/workflows/release.yml
vendored
|
@ -7,13 +7,10 @@ jobs:
|
||||||
release:
|
release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- name: Checkout
|
||||||
- name: Setup .NET Core
|
uses: actions/checkout@v1
|
||||||
uses: actions/setup-dotnet@v1
|
|
||||||
with:
|
|
||||||
dotnet-version: 3.1
|
|
||||||
- name: Build solution
|
- name: Build solution
|
||||||
run: dotnet build --output build
|
run: dotnet build --output build -c Release
|
||||||
- name: Publish NuGet package
|
- 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 Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using FFMpegCore.Pipes;
|
||||||
|
|
||||||
namespace FFMpegCore.Test
|
namespace FFMpegCore.Test
|
||||||
{
|
{
|
||||||
|
@ -33,7 +35,23 @@ public void Audio_Save()
|
||||||
Assert.IsTrue(!analysis.VideoStreams.Any());
|
Assert.IsTrue(!analysis.VideoStreams.Any());
|
||||||
Assert.IsTrue(analysis.AudioStreams.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]
|
[TestMethod]
|
||||||
public void Audio_Add()
|
public void Audio_Add()
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,6 +27,9 @@
|
||||||
<None Update="Resources\input_video_only_3sec.mp4">
|
<None Update="Resources\input_video_only_3sec.mp4">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
<None Update="Resources\audio.raw">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -37,7 +40,7 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="GitHubActionsTestLogger" Version="1.1.2" />
|
<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.TestAdapter" Version="2.1.2" />
|
||||||
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
|
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
|
||||||
</ItemGroup>
|
</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;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO.Pipes;
|
using System.IO.Pipes;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -30,6 +31,7 @@ public void Pre()
|
||||||
|
|
||||||
public void Post()
|
public void Post()
|
||||||
{
|
{
|
||||||
|
Debug.WriteLine($"Disposing NamedPipeServerStream on {GetType().Name}");
|
||||||
Pipe?.Dispose();
|
Pipe?.Dispose();
|
||||||
Pipe = null!;
|
Pipe = null!;
|
||||||
}
|
}
|
||||||
|
@ -39,9 +41,12 @@ public async Task During(CancellationToken cancellationToken = default)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await ProcessDataAsync(cancellationToken);
|
await ProcessDataAsync(cancellationToken);
|
||||||
|
Debug.WriteLine($"Disconnecting NamedPipeServerStream on {GetType().Name}");
|
||||||
|
Pipe?.Disconnect();
|
||||||
}
|
}
|
||||||
catch (TaskCanceledException)
|
catch (TaskCanceledException)
|
||||||
{
|
{
|
||||||
|
Debug.WriteLine($"ProcessDataAsync on {GetType().Name} cancelled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,8 @@ public static Bitmap Snapshot(IMediaAnalysis source, Size? size = null, TimeSpan
|
||||||
.ProcessSynchronously();
|
.ProcessSynchronously();
|
||||||
|
|
||||||
ms.Position = 0;
|
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>
|
/// <summary>
|
||||||
/// Saves a 'png' thumbnail to an in-memory bitmap
|
/// Saves a 'png' thumbnail to an in-memory bitmap
|
||||||
|
|
|
@ -9,10 +9,9 @@
|
||||||
<Version>3.0.0.0</Version>
|
<Version>3.0.0.0</Version>
|
||||||
<AssemblyVersion>3.0.0.0</AssemblyVersion>
|
<AssemblyVersion>3.0.0.0</AssemblyVersion>
|
||||||
<FileVersion>3.0.0.0</FileVersion>
|
<FileVersion>3.0.0.0</FileVersion>
|
||||||
<PackageReleaseNotes>- Updated dependencies
|
<PackageReleaseNotes>- Fix NullReferenceException on Disconnect after Dispose</PackageReleaseNotes>
|
||||||
- Additional StreamPipeSink constructor</PackageReleaseNotes>
|
|
||||||
<LangVersion>8</LangVersion>
|
<LangVersion>8</LangVersion>
|
||||||
<PackageVersion>3.2.0</PackageVersion>
|
<PackageVersion>3.2.1</PackageVersion>
|
||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
<Authors>Malte Rosenbjerg, Vlad Jerca</Authors>
|
<Authors>Malte Rosenbjerg, Vlad Jerca</Authors>
|
||||||
<PackageTags>ffmpeg ffprobe convert video audio mediafile resize analyze muxing</PackageTags>
|
<PackageTags>ffmpeg ffprobe convert video audio mediafile resize analyze muxing</PackageTags>
|
||||||
|
|
Loading…
Reference in a new issue