当前,当我将视频文件从客户端(reactjs)发送到本地托管的服务器(烧瓶)时,该文件作为视频Blob进入。我正在尝试使用opencv库在服务器上读取此文件。如何将Blob转换为opencv可以读取的内容?
我发送了Blob的axios请求(通过MediaRecorder API从媒体数组转换)。在服务器上,我可以接收该文件,但是它以“ <文件存储>”格式出现。我尝试将文件作为“文件”类型发送,还尝试将服务器上的Blob转换为Uint8数组。为了获得更多信息,我发送的视频文件是我的网络摄像头的录制内容,因此视频的顶部长为5-10秒。
# localhost:5000/video route (FLASK SERVER)
@APP.route('/video', methods=['GET', 'POST'])
@cross_origin(supports_credentials=True)
def new_func():
if request.method == 'GET':
return 'Hello, World!'
else:
# uses request.files becuase what I am sending over is in blob format
print('this is files', request.files['video'])
return 'received it'
sendVideo() {
// here is the post request with axios client side
let data = new FormData();
data.append('video', this.state.video)
// this.state.video is a video blob
const config = {
headers: {
'content-type': 'multipart/form-data'
}
}
axios.post('http://localhost:5000/video', data, config)
}
// here is the conversion of the buffer array (all the video recording) //into a blob
// creating new blob (binary large obj) defining it as an mp4 file
let blob = new Blob(buffer, { 'type': 'video/mp4' });
t.setState({ video: blob }, () => {
t.sendVideo() // this function is the above js snippet
})
我希望服务器接收到一个文件(已经完成了),并能够使用openCV(python)读取文件。目前,我无法读取从客户端收到的文件