diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 94a858ff..91fbab69 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,23 +22,23 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [windows-latest, ubuntu-latest, macos-latest] + os: [windows-latest, ubuntu-latest, macos-13] timeout-minutes: 7 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Prepare .NET - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: - dotnet-version: '7.0.x' + dotnet-version: '8.0.x' - name: Lint with dotnet run: dotnet format FFMpegCore.sln --severity warn --verify-no-changes - name: Prepare FFMpeg - uses: FedericoCarboni/setup-ffmpeg@v2 + uses: FedericoCarboni/setup-ffmpeg@v3 with: token: ${{ secrets.GITHUB_TOKEN }} @@ -47,7 +47,8 @@ jobs: - if: matrix.os == 'windows-latest' name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v5 with: + fail_ci_if_error: true directory: FFMpegCore.Test/TestResults - fail_ci_if_error: true \ No newline at end of file + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 00a1ea7d..f832def4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,12 +8,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Prepare .NET - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: - dotnet-version: '7.0.x' + dotnet-version: '8.0.x' - name: Build solution run: dotnet pack FFMpegCore.sln -c Release diff --git a/FFMpegCore.Examples/FFMpegCore.Examples.csproj b/FFMpegCore.Examples/FFMpegCore.Examples.csproj index f4a2b9bb..1aa7d463 100644 --- a/FFMpegCore.Examples/FFMpegCore.Examples.csproj +++ b/FFMpegCore.Examples/FFMpegCore.Examples.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net8.0 false diff --git a/FFMpegCore.Extensions.SkiaSharp/FFMpegCore.Extensions.SkiaSharp.csproj b/FFMpegCore.Extensions.SkiaSharp/FFMpegCore.Extensions.SkiaSharp.csproj index 87710cc1..3b16e06e 100644 --- a/FFMpegCore.Extensions.SkiaSharp/FFMpegCore.Extensions.SkiaSharp.csproj +++ b/FFMpegCore.Extensions.SkiaSharp/FFMpegCore.Extensions.SkiaSharp.csproj @@ -9,6 +9,7 @@ ffmpeg ffprobe convert video audio mediafile resize analyze muxing skiasharp Malte Rosenbjerg, Vlad Jerca, Max Bagryantsev, Dimitri Vranken + true diff --git a/FFMpegCore.Extensions.System.Drawing.Common/FFMpegCore.Extensions.System.Drawing.Common.csproj b/FFMpegCore.Extensions.System.Drawing.Common/FFMpegCore.Extensions.System.Drawing.Common.csproj index 13cdc1ab..ebd7c9af 100644 --- a/FFMpegCore.Extensions.System.Drawing.Common/FFMpegCore.Extensions.System.Drawing.Common.csproj +++ b/FFMpegCore.Extensions.System.Drawing.Common/FFMpegCore.Extensions.System.Drawing.Common.csproj @@ -9,6 +9,7 @@ ffmpeg ffprobe convert video audio mediafile resize analyze muxing Malte Rosenbjerg, Vlad Jerca, Max Bagryantsev + true diff --git a/FFMpegCore.Test/FFMpegCore.Test.csproj b/FFMpegCore.Test/FFMpegCore.Test.csproj index 7c4b8884..22cc7dc6 100644 --- a/FFMpegCore.Test/FFMpegCore.Test.csproj +++ b/FFMpegCore.Test/FFMpegCore.Test.csproj @@ -1,25 +1,25 @@  - net6.0 + net8.0 false disable default - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + @@ -54,6 +54,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/FFMpegCore.Test/FFProbeTests.cs b/FFMpegCore.Test/FFProbeTests.cs index a5070785..fc2f2ef8 100644 --- a/FFMpegCore.Test/FFProbeTests.cs +++ b/FFMpegCore.Test/FFProbeTests.cs @@ -173,6 +173,18 @@ public async Task Probe_Success_FromStream_Async() Assert.AreEqual(3, info.Duration.Seconds); } + [TestMethod, Timeout(10000)] + public void Probe_HDR() + { + var info = FFProbe.Analyse(TestResources.HdrVideo); + + Assert.IsNotNull(info.PrimaryVideoStream); + Assert.AreEqual("tv", info.PrimaryVideoStream.ColorRange); + Assert.AreEqual("bt2020nc", info.PrimaryVideoStream.ColorSpace); + Assert.AreEqual("arib-std-b67", info.PrimaryVideoStream.ColorTransfer); + Assert.AreEqual("bt2020", info.PrimaryVideoStream.ColorPrimaries); + } + [TestMethod, Timeout(10000)] public async Task Probe_Success_Subtitle_Async() { diff --git a/FFMpegCore.Test/Resources/TestResources.cs b/FFMpegCore.Test/Resources/TestResources.cs index b958b80b..280a051d 100644 --- a/FFMpegCore.Test/Resources/TestResources.cs +++ b/FFMpegCore.Test/Resources/TestResources.cs @@ -5,6 +5,7 @@ public static class TestResources public static readonly string Mp4Video = "./Resources/input_3sec.mp4"; public static readonly string Mp4VideoRotation = "./Resources/input_3sec_rotation_90deg.mp4"; public static readonly string WebmVideo = "./Resources/input_3sec.webm"; + public static readonly string HdrVideo = "./Resources/input_hdr.mov"; public static readonly string Mp4WithoutVideo = "./Resources/input_audio_only_10sec.mp4"; public static readonly string Mp4WithoutAudio = "./Resources/input_video_only_3sec.mp4"; public static readonly string RawAudio = "./Resources/audio.raw"; diff --git a/FFMpegCore.Test/Resources/input_hdr.mov b/FFMpegCore.Test/Resources/input_hdr.mov new file mode 100644 index 00000000..3fdeea11 Binary files /dev/null and b/FFMpegCore.Test/Resources/input_hdr.mov differ diff --git a/FFMpegCore/FFMpeg/Pipes/RawAudioPipeSource.cs b/FFMpegCore/FFMpeg/Pipes/RawAudioPipeSource.cs index 653e2520..cfe31ef3 100644 --- a/FFMpegCore/FFMpeg/Pipes/RawAudioPipeSource.cs +++ b/FFMpegCore/FFMpeg/Pipes/RawAudioPipeSource.cs @@ -27,7 +27,7 @@ public string GetStreamArguments() public async Task WriteAsync(Stream outputStream, CancellationToken cancellationToken) { - if (_sampleEnumerator.Current != null) + if (_sampleEnumerator.MoveNext() && _sampleEnumerator.Current != null) { await _sampleEnumerator.Current.SerializeAsync(outputStream, cancellationToken).ConfigureAwait(false); } diff --git a/FFMpegCore/FFMpegCore.csproj b/FFMpegCore/FFMpegCore.csproj index cf17d85c..2c02502c 100644 --- a/FFMpegCore/FFMpegCore.csproj +++ b/FFMpegCore/FFMpegCore.csproj @@ -18,7 +18,7 @@ - + diff --git a/FFMpegCore/FFOptions.cs b/FFMpegCore/FFOptions.cs index 3194874f..2d4e4c98 100644 --- a/FFMpegCore/FFOptions.cs +++ b/FFMpegCore/FFOptions.cs @@ -1,4 +1,5 @@ using System.Text; +using System.Text.Json.Serialization; using FFMpegCore.Enums; namespace FFMpegCore @@ -20,10 +21,20 @@ public class FFOptions : ICloneable /// public string TemporaryFilesFolder { get; set; } = Path.GetTempPath(); + /// + /// Encoding web name used to persist encoding + /// + public string EncodingWebName { get; set; } = Encoding.Default.WebName; + /// /// Encoding used for parsing stdout/stderr on ffmpeg and ffprobe processes /// - public Encoding Encoding { get; set; } = Encoding.Default; + [JsonIgnore] + public Encoding Encoding + { + get => Encoding.GetEncoding(EncodingWebName); + set => EncodingWebName = value?.WebName ?? Encoding.Default.WebName; + } /// /// The log level to use when calling of the ffmpeg executable. diff --git a/FFMpegCore/FFProbe/FFProbeAnalysis.cs b/FFMpegCore/FFProbe/FFProbeAnalysis.cs index e88f4618..0904db63 100644 --- a/FFMpegCore/FFProbe/FFProbeAnalysis.cs +++ b/FFMpegCore/FFProbe/FFProbeAnalysis.cs @@ -94,6 +94,18 @@ public class FFProbeStream : ITagsContainer, IDispositionContainer [JsonPropertyName("side_data_list")] public List> SideData { get; set; } = null!; + + [JsonPropertyName("color_range")] + public string ColorRange { get; set; } = null!; + + [JsonPropertyName("color_space")] + public string ColorSpace { get; set; } = null!; + + [JsonPropertyName("color_transfer")] + public string ColorTransfer { get; set; } = null!; + + [JsonPropertyName("color_primaries")] + public string ColorPrimaries { get; set; } = null!; } public class Format : ITagsContainer diff --git a/FFMpegCore/FFProbe/MediaAnalysis.cs b/FFMpegCore/FFProbe/MediaAnalysis.cs index af37cf2c..ab289eb8 100644 --- a/FFMpegCore/FFProbe/MediaAnalysis.cs +++ b/FFMpegCore/FFProbe/MediaAnalysis.cs @@ -90,6 +90,10 @@ private VideoStream ParseVideoStream(FFProbeStream stream) Width = stream.Width ?? 0, Profile = stream.Profile, PixelFormat = stream.PixelFormat, + ColorRange = stream.ColorRange, + ColorSpace = stream.ColorSpace, + ColorTransfer = stream.ColorTransfer, + ColorPrimaries = stream.ColorPrimaries, Rotation = MediaAnalysisUtils.ParseRotation(stream), Language = stream.GetLanguage(), Disposition = MediaAnalysisUtils.FormatDisposition(stream.Disposition), diff --git a/FFMpegCore/FFProbe/VideoStream.cs b/FFMpegCore/FFProbe/VideoStream.cs index b41bb627..b6474897 100644 --- a/FFMpegCore/FFProbe/VideoStream.cs +++ b/FFMpegCore/FFProbe/VideoStream.cs @@ -15,6 +15,10 @@ public class VideoStream : MediaStream public string PixelFormat { get; set; } = null!; public int Rotation { get; set; } public double AverageFrameRate { get; set; } + public string ColorRange { get; set; } = null!; + public string ColorSpace { get; set; } = null!; + public string ColorTransfer { get; set; } = null!; + public string ColorPrimaries { get; set; } = null!; public PixelFormat GetPixelFormatInfo() => FFMpeg.GetPixelFormat(PixelFormat); }