mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2025-01-18 12:36:44 +00:00
Merge branch 'main' into main
This commit is contained in:
commit
c44170ba8e
18 changed files with 226 additions and 15 deletions
17
.github/workflows/ci.yml
vendored
17
.github/workflows/ci.yml
vendored
|
@ -3,19 +3,25 @@ name: CI
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- main
|
||||||
paths:
|
paths:
|
||||||
- .github/workflows/ci.yml
|
- .github/workflows/ci.yml
|
||||||
|
- Directory.Build.props
|
||||||
- FFMpegCore/**
|
- FFMpegCore/**
|
||||||
- FFMpegCore.Test/**
|
- FFMpegCore.Test/**
|
||||||
|
- FFMpegCore.Extensions.SkiaSharp/**
|
||||||
|
- FFMpegCore.Extensions.System.Drawing.Common/**
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- release
|
- release
|
||||||
paths:
|
paths:
|
||||||
- .github/workflows/ci.yml
|
- .github/workflows/ci.yml
|
||||||
- FFMpegCore/**
|
- Directory.Build.props
|
||||||
- FFMpegCore.Test/**
|
- FFMpegCore/**
|
||||||
|
- FFMpegCore.Test/**
|
||||||
|
- FFMpegCore.Extensions.SkiaSharp/**
|
||||||
|
- FFMpegCore.Extensions.System.Drawing.Common/**
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ci:
|
ci:
|
||||||
|
@ -47,8 +53,9 @@ jobs:
|
||||||
|
|
||||||
- if: matrix.os == 'windows-latest'
|
- if: matrix.os == 'windows-latest'
|
||||||
name: Upload coverage reports to Codecov
|
name: Upload coverage reports to Codecov
|
||||||
uses: codecov/codecov-action@v5
|
uses: codecov/codecov-action@v4
|
||||||
with:
|
with:
|
||||||
fail_ci_if_error: true
|
fail_ci_if_error: true
|
||||||
directory: FFMpegCore.Test/TestResults
|
directory: FFMpegCore.Test/TestResults
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
os: windows
|
||||||
|
|
|
@ -13,5 +13,14 @@
|
||||||
<PackageProjectUrl>https://github.com/rosenbjerg/FFMpegCore</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/rosenbjerg/FFMpegCore</PackageProjectUrl>
|
||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
<NeutralLanguage>en</NeutralLanguage>
|
<NeutralLanguage>en</NeutralLanguage>
|
||||||
|
|
||||||
|
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
||||||
|
<IncludeSymbols>true</IncludeSymbols>
|
||||||
|
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||||
|
<EmbedUntrackedSources>true</EmbedUntrackedSources>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
|
||||||
|
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
|
||||||
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -3,7 +3,7 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<Description>Image extension for FFMpegCore using SkiaSharp</Description>
|
<Description>Image extension for FFMpegCore using SkiaSharp</Description>
|
||||||
<PackageVersion>5.0.0</PackageVersion>
|
<PackageVersion>5.0.1</PackageVersion>
|
||||||
<PackageOutputPath>../nupkg</PackageOutputPath>
|
<PackageOutputPath>../nupkg</PackageOutputPath>
|
||||||
<PackageReleaseNotes>
|
<PackageReleaseNotes>
|
||||||
</PackageReleaseNotes>
|
</PackageReleaseNotes>
|
||||||
|
@ -13,8 +13,8 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="SkiaSharp" Version="2.88.6" />
|
<PackageReference Include="SkiaSharp" Version="3.116.0" />
|
||||||
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.88.6" />
|
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="3.116.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<Description>Image extension for FFMpegCore using System.Common.Drawing</Description>
|
<Description>Image extension for FFMpegCore using System.Common.Drawing</Description>
|
||||||
<PackageVersion>5.0.0</PackageVersion>
|
<PackageVersion>5.0.1</PackageVersion>
|
||||||
<PackageOutputPath>../nupkg</PackageOutputPath>
|
<PackageOutputPath>../nupkg</PackageOutputPath>
|
||||||
<PackageReleaseNotes>
|
<PackageReleaseNotes>
|
||||||
</PackageReleaseNotes>
|
</PackageReleaseNotes>
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="System.Drawing.Common" Version="7.0.0"/>
|
<PackageReference Include="System.Drawing.Common" Version="9.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -9,6 +9,7 @@ namespace FFMpegCore.Test
|
||||||
public class ArgumentBuilderTest
|
public class ArgumentBuilderTest
|
||||||
{
|
{
|
||||||
private readonly string[] _concatFiles = { "1.mp4", "2.mp4", "3.mp4", "4.mp4" };
|
private readonly string[] _concatFiles = { "1.mp4", "2.mp4", "3.mp4", "4.mp4" };
|
||||||
|
private readonly string[] _multiFiles = { "1.mp3", "2.mp3", "3.mp3", "4.mp3" };
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Builder_BuildString_IO_1()
|
public void Builder_BuildString_IO_1()
|
||||||
|
@ -611,5 +612,86 @@ public void Builder_BuildString_TeeOutput()
|
||||||
-i "input.mp4" -f tee "[movflags=faststart]output.mp4|[f=mpegts:select=\'0:v:0\']http://server/path"
|
-i "input.mp4" -f tee "[movflags=faststart]output.mp4|[f=mpegts:select=\'0:v:0\']http://server/path"
|
||||||
""", str);
|
""", str);
|
||||||
}
|
}
|
||||||
|
[TestMethod]
|
||||||
|
public void Builder_BuildString_MultiInput()
|
||||||
|
{
|
||||||
|
var audioStreams = string.Join("", _multiFiles.Select((item, index) => $"[{index}:0]"));
|
||||||
|
var mixFilter = $"{audioStreams}amix=inputs={_multiFiles.Length}:duration=longest:dropout_transition=1:normalize=0[final]";
|
||||||
|
var ffmpegArgs = $"-filter_complex \"{mixFilter}\" -map \"[final]\"";
|
||||||
|
var str = FFMpegArguments
|
||||||
|
.FromFileInput(_multiFiles)
|
||||||
|
.OutputToFile("output.mp3", overwrite: true, options => options
|
||||||
|
.WithCustomArgument(ffmpegArgs)
|
||||||
|
.WithAudioCodec(AudioCodec.LibMp3Lame) // Set the audio codec to MP3
|
||||||
|
.WithAudioBitrate(128) // Set the bitrate to 128kbps
|
||||||
|
.WithAudioSamplingRate(48000) // Set the sample rate to 48kHz
|
||||||
|
.WithoutMetadata() // Remove metadata
|
||||||
|
.WithCustomArgument("-ac 2 -write_xing 0 -id3v2_version 0")) // Force 2 Channels
|
||||||
|
.Arguments;
|
||||||
|
Assert.AreEqual($"-i \"1.mp3\" -i \"2.mp3\" -i \"3.mp3\" -i \"4.mp3\" -filter_complex \"[0:0][1:0][2:0][3:0]amix=inputs=4:duration=longest:dropout_transition=1:normalize=0[final]\" -map \"[final]\" -c:a libmp3lame -b:a 128k -ar 48000 -map_metadata -1 -ac 2 -write_xing 0 -id3v2_version 0 \"output.mp3\" -y", str);
|
||||||
|
}
|
||||||
|
[TestMethod]
|
||||||
|
public void Pre_VerifyExists_AllFilesExist()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var filePaths = new List<string>
|
||||||
|
{
|
||||||
|
Path.GetTempFileName(),
|
||||||
|
Path.GetTempFileName(),
|
||||||
|
Path.GetTempFileName()
|
||||||
|
};
|
||||||
|
var argument = new MultiInputArgument(true, filePaths);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Act & Assert
|
||||||
|
argument.Pre(); // No exception should be thrown
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// Cleanup
|
||||||
|
foreach (var filePath in filePaths)
|
||||||
|
{
|
||||||
|
File.Delete(filePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void Pre_VerifyExists_SomeFilesNotExist()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var filePaths = new List<string>
|
||||||
|
{
|
||||||
|
Path.GetTempFileName(),
|
||||||
|
"file2.mp4",
|
||||||
|
"file3.mp4"
|
||||||
|
};
|
||||||
|
var argument = new MultiInputArgument(true, filePaths);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Act & Assert
|
||||||
|
Assert.ThrowsException<FileNotFoundException>(() => argument.Pre());
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// Cleanup
|
||||||
|
File.Delete(filePaths[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void Pre_VerifyExists_NoFilesExist()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var filePaths = new List<string>
|
||||||
|
{
|
||||||
|
"file1.mp4",
|
||||||
|
"file2.mp4",
|
||||||
|
"file3.mp4"
|
||||||
|
};
|
||||||
|
var argument = new MultiInputArgument(true, filePaths);
|
||||||
|
// Act & Assert
|
||||||
|
Assert.ThrowsException<FileNotFoundException>(() => argument.Pre());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
|
||||||
<PackageReference Include="MSTest.TestAdapter" Version="3.6.4" />
|
<PackageReference Include="MSTest.TestAdapter" Version="3.6.4" />
|
||||||
<PackageReference Include="MSTest.TestFramework" Version="3.6.4" />
|
<PackageReference Include="MSTest.TestFramework" Version="3.6.4" />
|
||||||
<PackageReference Include="SkiaSharp" Version="2.88.6" />
|
<PackageReference Include="SkiaSharp" Version="3.116.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -52,6 +52,9 @@
|
||||||
<None Update="Resources\input_3sec_rotation_90deg.mp4">
|
<None Update="Resources\input_3sec_rotation_90deg.mp4">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
<None Update="Resources\input_3sec_rotation_negative_90deg.mp4">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
<None Update="Resources\input_audio_only_10sec.mp4">
|
<None Update="Resources\input_audio_only_10sec.mp4">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
|
|
@ -146,6 +146,13 @@ public void Probe_Rotation()
|
||||||
Assert.AreEqual(90, info.PrimaryVideoStream.Rotation);
|
Assert.AreEqual(90, info.PrimaryVideoStream.Rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void Probe_Rotation_Negative_Value()
|
||||||
|
{
|
||||||
|
var info = FFProbe.Analyse(TestResources.Mp4VideoRotationNegative);
|
||||||
|
Assert.AreEqual(-90, info.PrimaryVideoStream.Rotation);
|
||||||
|
}
|
||||||
|
|
||||||
[TestMethod, Timeout(10000)]
|
[TestMethod, Timeout(10000)]
|
||||||
public async Task Probe_Async_Success()
|
public async Task Probe_Async_Success()
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,6 +4,7 @@ public static class TestResources
|
||||||
{
|
{
|
||||||
public static readonly string Mp4Video = "./Resources/input_3sec.mp4";
|
public static readonly string Mp4Video = "./Resources/input_3sec.mp4";
|
||||||
public static readonly string Mp4VideoRotation = "./Resources/input_3sec_rotation_90deg.mp4";
|
public static readonly string Mp4VideoRotation = "./Resources/input_3sec_rotation_90deg.mp4";
|
||||||
|
public static readonly string Mp4VideoRotationNegative = "./Resources/input_3sec_rotation_negative_90deg.mp4";
|
||||||
public static readonly string WebmVideo = "./Resources/input_3sec.webm";
|
public static readonly string WebmVideo = "./Resources/input_3sec.webm";
|
||||||
public static readonly string HdrVideo = "./Resources/input_hdr.mov";
|
public static readonly string HdrVideo = "./Resources/input_hdr.mov";
|
||||||
public static readonly string Mp4WithoutVideo = "./Resources/input_audio_only_10sec.mp4";
|
public static readonly string Mp4WithoutVideo = "./Resources/input_audio_only_10sec.mp4";
|
||||||
|
|
BIN
FFMpegCore.Test/Resources/input_3sec_rotation_negative_90deg.mp4
Normal file
BIN
FFMpegCore.Test/Resources/input_3sec_rotation_negative_90deg.mp4
Normal file
Binary file not shown.
|
@ -480,6 +480,21 @@ public void Video_Snapshot_PersistSnapshot()
|
||||||
Assert.AreEqual("png", analysis.PrimaryVideoStream!.CodecName);
|
Assert.AreEqual("png", analysis.PrimaryVideoStream!.CodecName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||||
|
public void Video_Snapshot_Rotated_PersistSnapshot()
|
||||||
|
{
|
||||||
|
using var outputPath = new TemporaryFile("out.png");
|
||||||
|
|
||||||
|
var size = new Size(360, 0); // half the size of original video, keeping height 0 for keeping aspect ratio
|
||||||
|
FFMpeg.Snapshot(TestResources.Mp4VideoRotationNegative, outputPath, size);
|
||||||
|
|
||||||
|
var analysis = FFProbe.Analyse(outputPath);
|
||||||
|
Assert.AreEqual(size.Width, analysis.PrimaryVideoStream!.Width);
|
||||||
|
Assert.AreEqual(1280 / 2, analysis.PrimaryVideoStream!.Height);
|
||||||
|
Assert.AreEqual(0, analysis.PrimaryVideoStream!.Rotation);
|
||||||
|
Assert.AreEqual("png", analysis.PrimaryVideoStream!.CodecName);
|
||||||
|
}
|
||||||
|
|
||||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||||
public void Video_GifSnapshot_PersistSnapshot()
|
public void Video_GifSnapshot_PersistSnapshot()
|
||||||
{
|
{
|
||||||
|
|
22
FFMpegCore/FFMpeg/Arguments/CropArgument.cs
Normal file
22
FFMpegCore/FFMpeg/Arguments/CropArgument.cs
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
|
namespace FFMpegCore.Arguments
|
||||||
|
{
|
||||||
|
public class CropArgument : IArgument
|
||||||
|
{
|
||||||
|
public readonly Size? Size;
|
||||||
|
public readonly int Top;
|
||||||
|
public readonly int Left;
|
||||||
|
|
||||||
|
public CropArgument(Size? size, int top, int left)
|
||||||
|
{
|
||||||
|
Size = size;
|
||||||
|
Top = top;
|
||||||
|
Left = left;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CropArgument(int width, int height, int top, int left) : this(new Size(width, height), top, left) { }
|
||||||
|
|
||||||
|
public string Text => Size == null ? string.Empty : $"-vf crop={Size.Value.Width}:{Size.Value.Height}:{Left}:{Top}";
|
||||||
|
}
|
||||||
|
}
|
47
FFMpegCore/FFMpeg/Arguments/MultiInputArgument.cs
Normal file
47
FFMpegCore/FFMpeg/Arguments/MultiInputArgument.cs
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
namespace FFMpegCore.Arguments
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents input parameters for multiple files
|
||||||
|
/// </summary>
|
||||||
|
public class MultiInputArgument : IInputArgument
|
||||||
|
{
|
||||||
|
public readonly bool VerifyExists;
|
||||||
|
public readonly IEnumerable<string> FilePaths;
|
||||||
|
|
||||||
|
public MultiInputArgument(bool verifyExists, IEnumerable<string> filePaths)
|
||||||
|
{
|
||||||
|
VerifyExists = verifyExists;
|
||||||
|
FilePaths = filePaths;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MultiInputArgument(IEnumerable<string> filePaths, bool verifyExists) : this(verifyExists, filePaths) { }
|
||||||
|
|
||||||
|
public void Pre()
|
||||||
|
{
|
||||||
|
if (VerifyExists)
|
||||||
|
{
|
||||||
|
var missingFiles = new List<string>();
|
||||||
|
foreach (var filePath in FilePaths)
|
||||||
|
{
|
||||||
|
if (!File.Exists(filePath))
|
||||||
|
{
|
||||||
|
missingFiles.Add(filePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (missingFiles.Any())
|
||||||
|
{
|
||||||
|
throw new FileNotFoundException($"The following input files were not found: {string.Join(", ", missingFiles)}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task During(CancellationToken cancellationToken = default) => Task.CompletedTask;
|
||||||
|
public void Post() { }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Generates a combined input argument text for all file paths
|
||||||
|
/// </summary>
|
||||||
|
public string Text => string.Join(" ", FilePaths.Select(filePath => $"-i \"{filePath}\""));
|
||||||
|
}
|
||||||
|
}
|
|
@ -28,6 +28,8 @@ public static class AudioCodec
|
||||||
public static Codec Ac3 => FFMpeg.GetCodec("ac3");
|
public static Codec Ac3 => FFMpeg.GetCodec("ac3");
|
||||||
public static Codec Eac3 => FFMpeg.GetCodec("eac3");
|
public static Codec Eac3 => FFMpeg.GetCodec("eac3");
|
||||||
public static Codec LibMp3Lame => FFMpeg.GetCodec("libmp3lame");
|
public static Codec LibMp3Lame => FFMpeg.GetCodec("libmp3lame");
|
||||||
|
public static Codec Copy => new Codec("copy", CodecType.Audio);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class VideoType
|
public static class VideoType
|
||||||
|
|
|
@ -16,7 +16,10 @@ internal FFMpegArgumentOptions() { }
|
||||||
public FFMpegArgumentOptions WithVariableBitrate(int vbr) => WithArgument(new VariableBitRateArgument(vbr));
|
public FFMpegArgumentOptions WithVariableBitrate(int vbr) => WithArgument(new VariableBitRateArgument(vbr));
|
||||||
public FFMpegArgumentOptions Resize(int width, int height) => WithArgument(new SizeArgument(width, height));
|
public FFMpegArgumentOptions Resize(int width, int height) => WithArgument(new SizeArgument(width, height));
|
||||||
public FFMpegArgumentOptions Resize(Size? size) => WithArgument(new SizeArgument(size));
|
public FFMpegArgumentOptions Resize(Size? size) => WithArgument(new SizeArgument(size));
|
||||||
|
public FFMpegArgumentOptions Crop(Size? size, int left, int top) => WithArgument(new CropArgument(size, top, left));
|
||||||
|
public FFMpegArgumentOptions Crop(int width, int height, int left, int top) => WithArgument(new CropArgument(new Size(width, height), top, left));
|
||||||
|
public FFMpegArgumentOptions Crop(Size? size) => WithArgument(new CropArgument(size, 0, 0));
|
||||||
|
public FFMpegArgumentOptions Crop(int width, int height) => WithArgument(new CropArgument(new Size(width, height), 0, 0));
|
||||||
public FFMpegArgumentOptions WithBitStreamFilter(Channel channel, Filter filter) => WithArgument(new BitStreamFilterArgument(channel, filter));
|
public FFMpegArgumentOptions WithBitStreamFilter(Channel channel, Filter filter) => WithArgument(new BitStreamFilterArgument(channel, filter));
|
||||||
public FFMpegArgumentOptions WithConstantRateFactor(int crf) => WithArgument(new ConstantRateFactorArgument(crf));
|
public FFMpegArgumentOptions WithConstantRateFactor(int crf) => WithArgument(new ConstantRateFactorArgument(crf));
|
||||||
public FFMpegArgumentOptions CopyChannel(Channel channel = Channel.Both) => WithArgument(new CopyArgument(channel));
|
public FFMpegArgumentOptions CopyChannel(Channel channel = Channel.Both) => WithArgument(new CopyArgument(channel));
|
||||||
|
|
|
@ -21,6 +21,7 @@ private string GetText()
|
||||||
public static FFMpegArguments FromConcatInput(IEnumerable<string> filePaths, Action<FFMpegArgumentOptions>? addArguments = null) => new FFMpegArguments().WithInput(new ConcatArgument(filePaths), addArguments);
|
public static FFMpegArguments FromConcatInput(IEnumerable<string> filePaths, Action<FFMpegArgumentOptions>? addArguments = null) => new FFMpegArguments().WithInput(new ConcatArgument(filePaths), addArguments);
|
||||||
public static FFMpegArguments FromDemuxConcatInput(IEnumerable<string> filePaths, Action<FFMpegArgumentOptions>? addArguments = null) => new FFMpegArguments().WithInput(new DemuxConcatArgument(filePaths), addArguments);
|
public static FFMpegArguments FromDemuxConcatInput(IEnumerable<string> filePaths, Action<FFMpegArgumentOptions>? addArguments = null) => new FFMpegArguments().WithInput(new DemuxConcatArgument(filePaths), addArguments);
|
||||||
public static FFMpegArguments FromFileInput(string filePath, bool verifyExists = true, Action<FFMpegArgumentOptions>? addArguments = null) => new FFMpegArguments().WithInput(new InputArgument(verifyExists, filePath), addArguments);
|
public static FFMpegArguments FromFileInput(string filePath, bool verifyExists = true, Action<FFMpegArgumentOptions>? addArguments = null) => new FFMpegArguments().WithInput(new InputArgument(verifyExists, filePath), addArguments);
|
||||||
|
public static FFMpegArguments FromFileInput(IEnumerable<string> filePath, bool verifyExists = true, Action<FFMpegArgumentOptions>? addArguments = null) => new FFMpegArguments().WithInput(new MultiInputArgument(verifyExists, filePath), addArguments);
|
||||||
public static FFMpegArguments FromFileInput(FileInfo fileInfo, Action<FFMpegArgumentOptions>? addArguments = null) => new FFMpegArguments().WithInput(new InputArgument(fileInfo.FullName, false), addArguments);
|
public static FFMpegArguments FromFileInput(FileInfo fileInfo, Action<FFMpegArgumentOptions>? addArguments = null) => new FFMpegArguments().WithInput(new InputArgument(fileInfo.FullName, false), addArguments);
|
||||||
public static FFMpegArguments FromUrlInput(Uri uri, Action<FFMpegArgumentOptions>? addArguments = null) => new FFMpegArguments().WithInput(new InputArgument(uri.AbsoluteUri, false), addArguments);
|
public static FFMpegArguments FromUrlInput(Uri uri, Action<FFMpegArgumentOptions>? addArguments = null) => new FFMpegArguments().WithInput(new InputArgument(uri.AbsoluteUri, false), addArguments);
|
||||||
public static FFMpegArguments FromDeviceInput(string device, Action<FFMpegArgumentOptions>? addArguments = null) => new FFMpegArguments().WithInput(new InputDeviceArgument(device), addArguments);
|
public static FFMpegArguments FromDeviceInput(string device, Action<FFMpegArgumentOptions>? addArguments = null) => new FFMpegArguments().WithInput(new InputDeviceArgument(device), addArguments);
|
||||||
|
@ -35,6 +36,7 @@ public FFMpegArguments WithGlobalOptions(Action<FFMpegGlobalArguments> configure
|
||||||
public FFMpegArguments AddConcatInput(IEnumerable<string> filePaths, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new ConcatArgument(filePaths), addArguments);
|
public FFMpegArguments AddConcatInput(IEnumerable<string> filePaths, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new ConcatArgument(filePaths), addArguments);
|
||||||
public FFMpegArguments AddDemuxConcatInput(IEnumerable<string> filePaths, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new DemuxConcatArgument(filePaths), addArguments);
|
public FFMpegArguments AddDemuxConcatInput(IEnumerable<string> filePaths, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new DemuxConcatArgument(filePaths), addArguments);
|
||||||
public FFMpegArguments AddFileInput(string filePath, bool verifyExists = true, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new InputArgument(verifyExists, filePath), addArguments);
|
public FFMpegArguments AddFileInput(string filePath, bool verifyExists = true, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new InputArgument(verifyExists, filePath), addArguments);
|
||||||
|
public FFMpegArguments AddFileInput(IEnumerable<string> filePath, bool verifyExists = true, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new MultiInputArgument(verifyExists, filePath), addArguments);
|
||||||
public FFMpegArguments AddFileInput(FileInfo fileInfo, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new InputArgument(fileInfo.FullName, false), addArguments);
|
public FFMpegArguments AddFileInput(FileInfo fileInfo, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new InputArgument(fileInfo.FullName, false), addArguments);
|
||||||
public FFMpegArguments AddUrlInput(Uri uri, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new InputArgument(uri.AbsoluteUri, false), addArguments);
|
public FFMpegArguments AddUrlInput(Uri uri, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new InputArgument(uri.AbsoluteUri, false), addArguments);
|
||||||
public FFMpegArguments AddDeviceInput(string device, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new InputDeviceArgument(device), addArguments);
|
public FFMpegArguments AddDeviceInput(string device, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new InputDeviceArgument(device), addArguments);
|
||||||
|
|
|
@ -64,7 +64,7 @@ public static (FFMpegArguments, Action<FFMpegArgumentOptions> outputOptions) Bui
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentSize = new Size(source.PrimaryVideoStream.Width, source.PrimaryVideoStream.Height);
|
var currentSize = new Size(source.PrimaryVideoStream.Width, source.PrimaryVideoStream.Height);
|
||||||
if (source.PrimaryVideoStream.Rotation == 90 || source.PrimaryVideoStream.Rotation == 180)
|
if (IsRotated(source.PrimaryVideoStream.Rotation))
|
||||||
{
|
{
|
||||||
currentSize = new Size(source.PrimaryVideoStream.Height, source.PrimaryVideoStream.Width);
|
currentSize = new Size(source.PrimaryVideoStream.Height, source.PrimaryVideoStream.Width);
|
||||||
}
|
}
|
||||||
|
@ -88,4 +88,10 @@ public static (FFMpegArguments, Action<FFMpegArgumentOptions> outputOptions) Bui
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool IsRotated(int rotation)
|
||||||
|
{
|
||||||
|
var absRotation = Math.Abs(rotation);
|
||||||
|
return absRotation == 90 || absRotation == 180;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<Description>A .NET Standard FFMpeg/FFProbe wrapper for easily integrating media analysis and conversion into your .NET applications</Description>
|
<Description>A .NET Standard FFMpeg/FFProbe wrapper for easily integrating media analysis and conversion into your .NET applications</Description>
|
||||||
<PackageVersion>5.1.0</PackageVersion>
|
<PackageVersion>5.1.1</PackageVersion>
|
||||||
<PackageOutputPath>../nupkg</PackageOutputPath>
|
<PackageOutputPath>../nupkg</PackageOutputPath>
|
||||||
<PackageReleaseNotes>
|
<PackageReleaseNotes>
|
||||||
</PackageReleaseNotes>
|
</PackageReleaseNotes>
|
||||||
|
@ -20,5 +20,7 @@
|
||||||
<PackageReference Include="Instances" Version="3.0.0" />
|
<PackageReference Include="Instances" Version="3.0.0" />
|
||||||
<PackageReference Include="System.Text.Json" Version="9.0.0" />
|
<PackageReference Include="System.Text.Json" Version="9.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -30,9 +30,12 @@ private MediaFormat ParseFormat(Format analysisFormat)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string GetValue(string tagName, Dictionary<string, string>? tags, string defaultValue) =>
|
||||||
|
tags == null ? defaultValue : tags.TryGetValue(tagName, out var value) ? value : defaultValue;
|
||||||
|
|
||||||
private ChapterData ParseChapter(Chapter analysisChapter)
|
private ChapterData ParseChapter(Chapter analysisChapter)
|
||||||
{
|
{
|
||||||
var title = analysisChapter.Tags.FirstOrDefault(t => t.Key == "title").Value;
|
var title = GetValue("title", analysisChapter.Tags, "TitleValueNotSet");
|
||||||
var start = MediaAnalysisUtils.ParseDuration(analysisChapter.StartTime);
|
var start = MediaAnalysisUtils.ParseDuration(analysisChapter.StartTime);
|
||||||
var end = MediaAnalysisUtils.ParseDuration(analysisChapter.EndTime);
|
var end = MediaAnalysisUtils.ParseDuration(analysisChapter.EndTime);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue