@@ -37,16 +37,19 @@ public static bool Snapshot(string input, string output, Size? size = null, Time
3737 /// <param name="size">Thumbnail size. If width or height equal 0, the other will be computed automatically.</param>
3838 /// <param name="streamIndex">Selected video stream index.</param>
3939 /// <param name="inputFileIndex">Input file index</param>
40+ /// <param name="cancellationToken">Cancellation token</param>
4041 /// <returns>Bitmap with the requested snapshot.</returns>
4142 public static async Task < bool > SnapshotAsync ( string input , string output , Size ? size = null , TimeSpan ? captureTime = null , int ? streamIndex = null ,
42- int inputFileIndex = 0 )
43+ int inputFileIndex = 0 , CancellationToken cancellationToken = default )
4344 {
4445 CheckSnapshotOutputExtension ( output , FileExtension . Image . All ) ;
4546
46- var source = await FFProbe . AnalyseAsync ( input ) . ConfigureAwait ( false ) ;
47+ var source = await FFProbe . AnalyseAsync ( input , cancellationToken : cancellationToken ) . ConfigureAwait ( false ) ;
4748
4849 return await SnapshotProcess ( input , output , source , size , captureTime , streamIndex , inputFileIndex )
49- . ProcessAsynchronously ( ) ;
50+ . CancellableThrough ( cancellationToken )
51+ . ProcessAsynchronously ( )
52+ . ConfigureAwait ( false ) ;
5053 }
5154
5255 public static bool GifSnapshot ( string input , string output , Size ? size = null , TimeSpan ? captureTime = null , TimeSpan ? duration = null ,
@@ -61,14 +64,16 @@ public static bool GifSnapshot(string input, string output, Size? size = null, T
6164 }
6265
6366 public static async Task < bool > GifSnapshotAsync ( string input , string output , Size ? size = null , TimeSpan ? captureTime = null , TimeSpan ? duration = null ,
64- int ? streamIndex = null )
67+ int ? streamIndex = null , CancellationToken cancellationToken = default )
6568 {
6669 CheckSnapshotOutputExtension ( output , [ FileExtension . Gif ] ) ;
6770
68- var source = await FFProbe . AnalyseAsync ( input ) . ConfigureAwait ( false ) ;
71+ var source = await FFProbe . AnalyseAsync ( input , cancellationToken : cancellationToken ) . ConfigureAwait ( false ) ;
6972
7073 return await GifSnapshotProcess ( input , output , source , size , captureTime , duration , streamIndex )
71- . ProcessAsynchronously ( ) ;
74+ . CancellableThrough ( cancellationToken )
75+ . ProcessAsynchronously ( )
76+ . ConfigureAwait ( false ) ;
7277 }
7378
7479 private static FFMpegArgumentProcessor SnapshotProcess ( string input , string output , IMediaAnalysis source , Size ? size = null , TimeSpan ? captureTime = null ,
@@ -321,11 +326,15 @@ public static bool SubVideo(string input, string output, TimeSpan startTime, Tim
321326 /// <param name="output">Output video file.</param>
322327 /// <param name="startTime">The start time of when the sub video needs to start</param>
323328 /// <param name="endTime">The end time of where the sub video needs to end</param>
329+ /// <param name="cancellationToken">Cancellation token</param>
324330 /// <returns>Output video information.</returns>
325- public static async Task < bool > SubVideoAsync ( string input , string output , TimeSpan startTime , TimeSpan endTime )
331+ public static async Task < bool > SubVideoAsync ( string input , string output , TimeSpan startTime , TimeSpan endTime ,
332+ CancellationToken cancellationToken = default )
326333 {
327334 return await BaseSubVideo ( input , output , startTime , endTime )
328- . ProcessAsynchronously ( ) ;
335+ . CancellableThrough ( cancellationToken )
336+ . ProcessAsynchronously ( )
337+ . ConfigureAwait ( false ) ;
329338 }
330339
331340 /// <summary>
0 commit comments