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