Skip to content

Commit b11efdb

Browse files
committed
Update FFProbe URI overload to handle file based URIs
1 parent b238e45 commit b11efdb

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

FFMpegCore.Test/FFProbeTests.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@ public void FrameAnalysis_FromStream_Sync()
4343
Assert.IsTrue(frameAnalysis.Frames.All(f => f.MediaType == "video"));
4444
}
4545

46+
[TestMethod]
47+
public void FrameAnalysis_FromUri_Sync()
48+
{
49+
var frameAnalysis = FFProbe.GetFrames(new Uri(Path.GetFullPath(TestResources.WebmVideo)));
50+
51+
Assert.HasCount(90, frameAnalysis.Frames);
52+
Assert.IsTrue(frameAnalysis.Frames.All(f => f.PixelFormat == "yuv420p"));
53+
Assert.IsTrue(frameAnalysis.Frames.All(f => f.Height == 360));
54+
Assert.IsTrue(frameAnalysis.Frames.All(f => f.Width == 640));
55+
Assert.IsTrue(frameAnalysis.Frames.All(f => f.MediaType == "video"));
56+
}
57+
4658
[TestMethod]
4759
public async Task FrameAnalysis_Async()
4860
{

FFMpegCore/FFProbe/FFProbe.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Diagnostics;
1+
using System.Diagnostics;
22
using System.Text.Json;
33
using System.Text.Json.Serialization;
44
using FFMpegCore.Arguments;
@@ -36,7 +36,7 @@ public static async Task<IMediaAnalysis> AnalyseAsync(string filePath, FFOptions
3636
public static async Task<IMediaAnalysis> AnalyseAsync(Uri uri, FFOptions? ffOptions = null, CancellationToken cancellationToken = default,
3737
string? customArguments = null)
3838
{
39-
return await AnalyseCoreAsync(uri.AbsoluteUri, ffOptions, cancellationToken, customArguments).ConfigureAwait(false);
39+
return await AnalyseCoreAsync(uri.IsFile ? uri.LocalPath : uri.AbsoluteUri, ffOptions, cancellationToken, customArguments).ConfigureAwait(false);
4040
}
4141

4242
public static async Task<IMediaAnalysis> AnalyseAsync(Stream stream, FFOptions? ffOptions = null, CancellationToken cancellationToken = default,
@@ -88,7 +88,7 @@ public static async Task<FFProbeFrames> GetFramesAsync(string filePath, FFOption
8888
public static async Task<FFProbeFrames> GetFramesAsync(Uri uri, FFOptions? ffOptions = null, CancellationToken cancellationToken = default,
8989
string? customArguments = null)
9090
{
91-
return await GetFramesCoreAsync(uri.AbsoluteUri, ffOptions, cancellationToken, customArguments).ConfigureAwait(false);
91+
return await GetFramesCoreAsync(uri.IsFile ? uri.LocalPath : uri.AbsoluteUri, ffOptions, cancellationToken, customArguments).ConfigureAwait(false);
9292
}
9393

9494
public static async Task<FFProbeFrames> GetFramesAsync(Stream stream, FFOptions? ffOptions = null, CancellationToken cancellationToken = default,

0 commit comments

Comments
 (0)