cordova-plugin-video-editor icon indicating copy to clipboard operation
cordova-plugin-video-editor copied to clipboard

Converting thumbnail into base 64 provides error

Open jayzyaj opened this issue 6 years ago • 0 comments

I used the Ionic native camera plugin to take the video or select from the user library base from my options then I used this package to generate some thumbnail. Here is the full code below.

` this.camera.getPicture(options).then((vidData) => { console.log(vidData) // if (vidData == '' || vidData == undefined) { // this.mediaReady = false // console.log(this.mediaReady) // } else { this.mediaReady = false console.log(this.mediaReady) // } let fileStart: string = 'file://' let filePath = fileStart + vidData // separate the absolute path and the filename let path = filePath.substring(0, filePath.lastIndexOf("/") + 1) // get the file path except the file name let fileName = decodeURIComponent(filePath.split('/').pop()) // get only the file name

  this.generateThumbnail(filePath, fileName)`

And the generateThumbnail function.

async generateThumbnail(vidData, fileName) {
    try {
      const thumbnailOptions:CreateThumbnailOptions = {
        atTime: 1,
        quality: 50,
        fileUri: vidData,
        width: 320,
        height: 480,
        outputFileName: fileName
      }
      const thumbnail = await this.video.createThumbnail(thumbnailOptions)
      console.log(thumbnail)
      const base64ThumbNail = await this.file.readAsDataURL(thumbnail, null)
      console.log(base64ThumbNail)
      this.thumbnailVideo.push(base64ThumbNail)
    } catch(e) {
      console.log(e)
    }
  }

Here is my log in my thumbnail path from the createThumbnail function

/storage/emulated/0/Android/data/io.luckyah.com/files/files/videos/MOV_0021.mp4.jpg

Any thoughts?

jayzyaj avatar Aug 31 '18 07:08 jayzyaj