@@ -135,7 +135,7 @@ public async Task<VideoOutput> CreateVideoAsync(IEnumerable<byte[]> videoFrames,
135135 /// <returns></returns>
136136 /// <exception cref="NotSupportedException">VideoTensor not supported</exception>
137137 /// <exception cref="ArgumentException">No video data found</exception>
138- public async Task < VideoFrames > CreateFramesAsync ( VideoInput videoInput , float videoFPS , CancellationToken cancellationToken = default )
138+ public async Task < VideoFrames > CreateFramesAsync ( VideoInput videoInput , float ? videoFPS = default , CancellationToken cancellationToken = default )
139139 {
140140
141141 if ( videoInput . VideoBytes is not null )
@@ -158,11 +158,12 @@ public async Task<VideoFrames> CreateFramesAsync(VideoInput videoInput, float vi
158158 /// <param name="videoFPS">The video FPS.</param>
159159 /// <param name="cancellationToken">The cancellation token.</param>
160160 /// <returns></returns>
161- public async Task < VideoFrames > CreateFramesAsync ( byte [ ] videoBytes , float videoFPS , CancellationToken cancellationToken = default )
161+ public async Task < VideoFrames > CreateFramesAsync ( byte [ ] videoBytes , float ? videoFPS = default , CancellationToken cancellationToken = default )
162162 {
163163 var videoInfo = await GetVideoInfoAsync ( videoBytes , cancellationToken ) ;
164- var videoFrames = await CreateFramesInternalAsync ( videoBytes , videoFPS , cancellationToken ) . ToListAsync ( cancellationToken ) ;
165- videoInfo = videoInfo with { FPS = videoFPS } ;
164+ var targetFPS = videoFPS ?? videoInfo . FPS ;
165+ var videoFrames = await CreateFramesInternalAsync ( videoBytes , targetFPS , cancellationToken ) . ToListAsync ( cancellationToken ) ;
166+ videoInfo = videoInfo with { FPS = targetFPS } ;
166167 return new VideoFrames ( videoInfo , videoFrames ) ;
167168 }
168169
@@ -174,14 +175,16 @@ public async Task<VideoFrames> CreateFramesAsync(byte[] videoBytes, float videoF
174175 /// <param name="videoFPS">The video FPS.</param>
175176 /// <param name="cancellationToken">The cancellation token.</param>
176177 /// <returns></returns>
177- public async Task < VideoFrames > CreateFramesAsync ( Stream videoStream , float videoFPS , CancellationToken cancellationToken = default )
178+ public async Task < VideoFrames > CreateFramesAsync ( Stream videoStream , float ? videoFPS = default , CancellationToken cancellationToken = default )
178179 {
179180 using ( var memoryStream = new MemoryStream ( ) )
180181 {
181182 await memoryStream . CopyToAsync ( videoStream , cancellationToken ) . ConfigureAwait ( false ) ;
182183 var videoBytes = memoryStream . ToArray ( ) ;
183184 var videoInfo = await GetVideoInfoAsync ( videoBytes , cancellationToken ) ;
184- var videoFrames = await CreateFramesInternalAsync ( videoBytes , videoFPS , cancellationToken ) . ToListAsync ( cancellationToken ) ;
185+ var targetFPS = videoFPS ?? videoInfo . FPS ;
186+ var videoFrames = await CreateFramesInternalAsync ( videoBytes , targetFPS , cancellationToken ) . ToListAsync ( cancellationToken ) ;
187+ videoInfo = videoInfo with { FPS = targetFPS } ;
185188 return new VideoFrames ( videoInfo , videoFrames ) ;
186189 }
187190 }
0 commit comments