@@ -12,7 +12,6 @@ namespace TensorStack.Video
1212 /// </summary>
1313 public class VideoInput : VideoTensor
1414 {
15- private readonly string _videoCodec ;
1615 private string _filename ;
1716
1817 /// <summary>
@@ -23,8 +22,8 @@ public class VideoInput : VideoTensor
2322 /// <param name="height">The height.</param>
2423 /// <param name="frameRate">The frame rate.</param>
2524 /// <param name="videoCodec">The video codec.</param>
26- public VideoInput ( string filename , int ? widthOverride = default , int ? heightOverride = default , float ? frameRateOverride = default , ResizeMode resizeMode = ResizeMode . Crop , string videoCodec = "mp4v" )
27- : this ( VideoService . LoadVideoTensor ( filename , widthOverride , heightOverride , frameRateOverride , resizeMode ) , videoCodec )
25+ public VideoInput ( string filename , int ? widthOverride = default , int ? heightOverride = default , float ? frameRateOverride = default , ResizeMode resizeMode = ResizeMode . Crop )
26+ : this ( VideoService . LoadVideoTensor ( filename , widthOverride , heightOverride , frameRateOverride , resizeMode ) )
2827 {
2928 _filename = filename ;
3029 }
@@ -33,11 +32,7 @@ public VideoInput(string filename, int? widthOverride = default, int? heightOver
3332 /// Initializes a new instance of the <see cref="VideoInput"/> class.
3433 /// </summary>
3534 /// <param name="videoTensor">The video tensor.</param>
36- public VideoInput ( VideoTensor videoTensor , string videoCodec = "mp4v" )
37- : base ( videoTensor , videoTensor . FrameRate )
38- {
39- _videoCodec = videoCodec ;
40- }
35+ public VideoInput ( VideoTensor videoTensor ) : base ( videoTensor , videoTensor . FrameRate ) { }
4136
4237 /// <summary>
4338 /// Gets the filename.
@@ -53,34 +48,29 @@ public VideoInput(VideoTensor videoTensor, string videoCodec = "mp4v")
5348 /// <param name="framerateOverride">The framerate.</param>
5449 /// <param name="cancellationToken">The cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
5550 /// <returns>A Task representing the asynchronous operation.</returns>
56- public async Task SaveAsync ( string filename , float ? frameRateOverride = default , CancellationToken cancellationToken = default )
51+ public async Task SaveAsync ( string filename , string videoCodec = "mp4v" , float ? frameRateOverride = default , CancellationToken cancellationToken = default )
5752 {
58- await VideoService . SaveVideoTensorAync ( filename , this , frameRateOverride , _videoCodec , cancellationToken ) ;
53+ await VideoService . SaveVideoTensorAync ( filename , this , videoCodec , frameRateOverride , cancellationToken ) ;
5954 }
6055
6156
6257 /// <summary>
63- /// Load as VideoInput asynchronously
58+ /// Creates the stream.
6459 /// </summary>
65- /// <param name="filename">The filename.</param>
66- /// <param name="widthOverride">The width.</param>
67- /// <param name="heightOverride">The height.</param>
68- /// <param name="frameRateOverride ">The frame rate.</param>
69- /// <param name="cancellationToken">The cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
70- /// <returns>A Task<VideoInput> representing the asynchronous operation.</returns>
71- public static async Task < VideoInput > LoadAsync ( string filename , int ? widthOverride = default , int ? heightOverride = default , float ? frameRateOverride = default , ResizeMode resizeMode = ResizeMode . Crop , CancellationToken cancellationToken = default )
60+ /// <returns>VideoStream.</returns>
61+ public VideoInputStream CreateStream ( )
7262 {
73- return new VideoInput ( await VideoService . LoadVideoTensorAsync ( filename , widthOverride , heightOverride , frameRateOverride , resizeMode , cancellationToken ) ) ;
63+ return new VideoInputStream ( _filename ) ;
7464 }
7565
7666
7767 /// <summary>
78- /// Creates the stream.
68+ /// Creates the stream asynchronously .
7969 /// </summary>
80- /// <returns>VideoStream .</returns>
81- public VideoInputStream CreateStream ( )
70+ /// <returns>Task<VideoInputStream> .</returns>
71+ public Task < VideoInputStream > CreateStreamAsync ( )
8272 {
83- return new VideoInputStream ( _filename , _videoCodec ) ;
73+ return VideoInputStream . CreateAsync ( _filename ) ;
8474 }
8575
8676
@@ -93,5 +83,19 @@ public void SetFilename(string filename)
9383 _filename = filename ;
9484 }
9585
86+
87+ /// <summary>
88+ /// Create a VideoInput asynchronously
89+ /// </summary>
90+ /// <param name="filename">The filename.</param>
91+ /// <param name="widthOverride">The width.</param>
92+ /// <param name="heightOverride">The height.</param>
93+ /// <param name="frameRateOverride ">The frame rate.</param>
94+ /// <param name="cancellationToken">The cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
95+ /// <returns>A Task<VideoInput> representing the asynchronous operation.</returns>
96+ public static async Task < VideoInput > CreateAsync ( string filename , int ? widthOverride = default , int ? heightOverride = default , float ? frameRateOverride = default , ResizeMode resizeMode = ResizeMode . Crop , CancellationToken cancellationToken = default )
97+ {
98+ return new VideoInput ( await VideoService . LoadVideoTensorAsync ( filename , widthOverride , heightOverride , frameRateOverride , resizeMode , cancellationToken ) ) ;
99+ }
96100 }
97101}
0 commit comments