Add Uri support for Frame Analysis,

skipped Stream support as this cannot support MP4's with moov atom in the end of the file, and input pipes do not support seek.
This commit is contained in:
jeroenvanderschoot 2022-11-13 08:41:30 +01:00 committed by Malte Rosenbjerg
parent 4617f89560
commit 31b93b3ed6

View file

@ -89,6 +89,15 @@ public static async Task<IMediaAnalysis> AnalyseAsync(string filePath, FFOptions
return ParseOutput(result); return ParseOutput(result);
} }
public static FFProbeFrames GetFrames(Uri uri, FFOptions? ffOptions = null)
{
var instance = PrepareFrameAnalysisInstance(uri.AbsoluteUri, ffOptions ?? GlobalFFOptions.Current);
var result = instance.StartAndWaitForExit();
ThrowIfExitCodeNotZero(result);
return ParseFramesOutput(result);
}
public static async Task<FFProbeFrames> GetFramesAsync(string filePath, FFOptions? ffOptions = null, CancellationToken cancellationToken = default) public static async Task<FFProbeFrames> GetFramesAsync(string filePath, FFOptions? ffOptions = null, CancellationToken cancellationToken = default)
{ {
ThrowIfInputFileDoesNotExist(filePath); ThrowIfInputFileDoesNotExist(filePath);
@ -141,6 +150,13 @@ public static async Task<IMediaAnalysis> AnalyseAsync(Stream stream, FFOptions?
return ParseOutput(result); return ParseOutput(result);
} }
public static async Task<FFProbeFrames> GetFramesAsync(Uri uri, FFOptions? ffOptions = null, CancellationToken cancellationToken = default)
{
var instance = PrepareFrameAnalysisInstance(uri.AbsoluteUri, ffOptions ?? GlobalFFOptions.Current);
var result = await instance.StartAndWaitForExitAsync(cancellationToken).ConfigureAwait(false);
return ParseFramesOutput(result);
}
private static IMediaAnalysis ParseOutput(IProcessResult instance) private static IMediaAnalysis ParseOutput(IProcessResult instance)
{ {
var json = string.Join(string.Empty, instance.OutputData); var json = string.Join(string.Empty, instance.OutputData);