gpt4 book ai didi

javascript - Cordova 视频捕获 - 如何获取 blob 数据?

转载 作者:行者123 更新时间:2023-12-03 03:39:31 28 4
gpt4 key购买 nike

我使用以下代码成功捕获视频流:

        navigator.device.capture.captureVideo(

//...after recorded vid
function(mediaFiles) {
var i, path, len;
for (i = 0, len = mediaFiles.length; i < len; i += 1) {
path = mediaFiles[i].fullPath;
app.f7.alert(path);
}
},

//...couldn't get camera
function() { app.f7.alert('Sorry - your recording device could not be accessed', 'Error'); },

//...config
{limit:2}
);

我不知道如何获取已保存视频的 blob 数据。我有本地保存文件的文件路径,但我需要将数据保存到远程服务器,因此我需要它的数据。

成功回调会传递一个封装捕获视频的 MediaFile 对象,但是 the docs don't discuss获取其原始数据的任何方式。有人知道如何实现这一点吗?

最佳答案

因为MediaFile将为您提供有关文件本身的信息,例如

name: The name of the file, without path information. (DOMString)
fullPath: The full path of the file, including the name. (DOMString)
type: The file's mime type (DOMString)
lastModifiedDate: The date and time when the file was last modified. (Date)
size: The size of the file, in bytes. (Number)

MediaFileData 将授予访问权限

codecs: The actual format of the audio and video content. (DOMString)
bitrate: The average bitrate of the content. The value is zero for images. (Number)
height: The height of the image or video in pixels. The value is zero for audio clips. (Number)
width: The width of the image or video in pixels. The value is zero for audio clips. (Number)
duration: The length of the video or sound clip in seconds. The value is zero for images. (Number)

而不是视频的内容。如果您想阅读其内容,请使用 MediaFile.fullPath 加载它。

要加载视频,请查看this post这可能会让您走上正轨。

关于javascript - Cordova 视频捕获 - 如何获取 blob 数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45700081/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com