0

I'm successfully capturing a video stream with the below code:

        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}
        );

What I can't figure out is how to grab the blob data of the saved video. I have the filepath to the locally-saved file, but I need to save the data out to a remote server so I need its data.

The success callback is passed a MediaFile object encapsulating the captured video, but the docs don't discuss any means of getting its raw data. Anyone know how this can be achieved?

Mitya
  • 33,629
  • 9
  • 60
  • 107

1 Answers1

1

Because MediaFile will give you information about the File itself such as

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 will give access to

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)

And not the content of the video. If you wanna read its content, load it using MediaFile.fullPath.

To load a video, check out this post that might put you on the right track.

Eric
  • 9,870
  • 14
  • 66
  • 102
  • Thanks. "load it using MediaFile.fullPath" - that's precisely what I'm asking how to do. I have the full path, but I don't know how to read the the content of the file the path points to into a blob. – Mitya Aug 15 '17 at 19:37
  • See https://stackoverflow.com/questions/37327992/cordova-file-plugin-to-load-video-source-from-ios-cache – Eric Aug 15 '17 at 19:38
  • Thanks. I'll investigate that - though the question has no accepted answer and the comments suggest the OP never resolved the issue. – Mitya Aug 15 '17 at 19:40
  • No joy - the code in that question seems to target different from the one my captured video file lives in. Please see new question - thanks: https://stackoverflow.com/questions/45716487/cordova-video-capture-how-can-i-save-file-it-out-to-server – Mitya Aug 16 '17 at 14:36
  • Commented there – Eric Aug 16 '17 at 14:41