1
+ using OnnxStack . Core . Video ;
2
+ using System . Collections . Generic ;
3
+ using System . IO ;
4
+ using System . Threading ;
5
+ using System . Threading . Tasks ;
6
+
7
+ namespace OnnxStack . Core . Services
8
+ {
9
+ /// <summary>
10
+ /// Service with basic handling of video for use in OnnxStack, Frame->Video and Video->Frames
11
+ /// </summary>
12
+ public interface IVideoService
13
+ {
14
+ /// <summary>
15
+ /// Gets the video information asynchronous.
16
+ /// </summary>
17
+ /// <param name="videoBytes">The video bytes.</param>
18
+ /// <param name="cancellationToken">The cancellation token.</param>
19
+ /// <returns></returns>
20
+ Task < VideoInfo > GetVideoInfoAsync ( byte [ ] videoBytes , CancellationToken cancellationToken = default ) ;
21
+
22
+ /// <summary>
23
+ /// Gets the video information asynchronous.
24
+ /// </summary>
25
+ /// <param name="videoStream">The video stream.</param>
26
+ /// <param name="cancellationToken">The cancellation token.</param>
27
+ /// <returns></returns>
28
+ Task < VideoInfo > GetVideoInfoAsync ( Stream videoStream , CancellationToken cancellationToken = default ) ;
29
+
30
+ /// <summary>
31
+ /// Gets the video information, Size, FPS, Duration etc.
32
+ /// </summary>
33
+ /// <param name="videoInput">The video input.</param>
34
+ /// <param name="cancellationToken">The cancellation token.</param>
35
+ /// <returns></returns>
36
+ /// <exception cref="ArgumentException">No video data found</exception>
37
+ Task < VideoInfo > GetVideoInfoAsync ( VideoInput videoInput , CancellationToken cancellationToken = default ) ;
38
+
39
+
40
+ /// <summary>
41
+ /// Creates a collection of PNG frames from a video source
42
+ /// </summary>
43
+ /// <param name="videoBytes">The video bytes.</param>
44
+ /// <param name="videoFPS">The video FPS.</param>
45
+ /// <param name="cancellationToken">The cancellation token.</param>
46
+ /// <returns></returns>
47
+ Task < VideoFrames > CreateFramesAsync ( byte [ ] videoBytes , float videoFPS , CancellationToken cancellationToken = default ) ;
48
+
49
+
50
+ /// <summary>
51
+ /// Creates a collection of PNG frames from a video source
52
+ /// </summary>
53
+ /// <param name="videoStream">The video stream.</param>
54
+ /// <param name="videoFPS">The video FPS.</param>
55
+ /// <param name="cancellationToken">The cancellation token.</param>
56
+ /// <returns></returns>
57
+ Task < VideoFrames > CreateFramesAsync ( Stream videoStream , float videoFPS , CancellationToken cancellationToken = default ) ;
58
+
59
+
60
+ /// <summary>
61
+ /// Creates a collection of PNG frames from a video source
62
+ /// </summary>
63
+ /// <param name="videoInput">The video input.</param>
64
+ /// <param name="videoFPS">The video FPS.</param>
65
+ /// <param name="cancellationToken">The cancellation token.</param>
66
+ /// <returns></returns>
67
+ /// <exception cref="NotSupportedException">VideoTensor not supported</exception>
68
+ /// <exception cref="ArgumentException">No video data found</exception>
69
+ Task < VideoFrames > CreateFramesAsync ( VideoInput videoInput , float videoFPS , CancellationToken cancellationToken = default ) ;
70
+
71
+
72
+ /// <summary>
73
+ /// Creates and MP4 video from a collection of PNG images.
74
+ /// </summary>
75
+ /// <param name="videoFrames">The video frames.</param>
76
+ /// <param name="videoFPS">The video FPS.</param>
77
+ /// <param name="cancellationToken">The cancellation token.</param>
78
+ /// <returns></returns>
79
+ Task < VideoResult > CreateVideoAsync ( IEnumerable < byte [ ] > videoFrames , float videoFPS , CancellationToken cancellationToken = default ) ;
80
+
81
+
82
+ /// <summary>
83
+ /// Creates and MP4 video from a collection of PNG images.
84
+ /// </summary>
85
+ /// <param name="videoFrames">The video frames.</param>
86
+ /// <param name="cancellationToken">The cancellation token.</param>
87
+ /// <returns></returns>
88
+ Task < VideoResult > CreateVideoAsync ( VideoFrames videoFrames , CancellationToken cancellationToken = default ) ;
89
+
90
+
91
+ /// <summary>
92
+ /// Streams frames as PNG as they are processed from a video source
93
+ /// </summary>
94
+ /// <param name="videoBytes">The video bytes.</param>
95
+ /// <param name="targetFPS">The target FPS.</param>
96
+ /// <param name="cancellationToken">The cancellation token.</param>
97
+ /// <returns></returns>
98
+ IAsyncEnumerable < byte [ ] > StreamFramesAsync ( byte [ ] videoBytes , float targetFPS , CancellationToken cancellationToken = default ) ;
99
+ }
100
+ }
0 commit comments