@@ -156,7 +156,7 @@ void Video::_getDecoderParams(
156156
157157} // _get decoder params
158158
159- Video::Video (std::string videoPath, std::string stream, int64_t numThreads) {
159+ void Video::_init ( std::string stream, int64_t numThreads) {
160160 C10_LOG_API_USAGE_ONCE (" torchvision.csrc.io.video.video.Video" );
161161 // set number of threads global
162162 numThreads_ = numThreads;
@@ -173,13 +173,6 @@ Video::Video(std::string videoPath, std::string stream, int64_t numThreads) {
173173 numThreads_ // global number of Threads for decoding
174174 );
175175
176- std::string logMessage, logType;
177-
178- // TODO: add read from memory option
179- params.uri = videoPath;
180- logType = " file" ;
181- logMessage = videoPath;
182-
183176 // locals
184177 std::vector<double > audioFPS, videoFPS;
185178 std::vector<double > audioDuration, videoDuration, ccDuration, subsDuration;
@@ -232,7 +225,18 @@ Video::Video(std::string videoPath, std::string stream, int64_t numThreads) {
232225 << " Stream index set to " << std::get<1 >(current_stream)
233226 << " . If you encounter trouble, consider switching it to automatic stream discovery. \n " ;
234227 }
235- } // video
228+ } // Video::Init
229+
230+
231+ Video::Video (torch::Tensor videoData, std::string stream, int64_t numThreads) {
232+ callback = MemoryBuffer::getCallback (videoData.data_ptr <uint8_t >(), videoData.size (0 ));
233+ Video::_init (stream, numThreads);
234+ }
235+
236+ Video::Video (std::string videoPath, std::string stream, int64_t numThreads) {
237+ params.uri = videoPath;
238+ Video::_init (stream, numThreads);
239+ }
236240
237241bool Video::setCurrentStream (std::string stream = " video" ) {
238242 if ((!stream.empty ()) && (_parseStream (stream) != current_stream)) {
0 commit comments