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

Error transcode video on Android

Open Clemouuche opened this issue 8 years ago • 5 comments

Hi,

Your plugin is really great.

I can use getPicture() or createThumbnails fine however I got an issue with transcoding. "video transcode error, java.net.MalformedURLException: Protocol not found: /storage/emulated/0/DCIM/Camera/VID_20161210_153958.mp4"

I thought it was a problem with the URI I passed but it's the same that I use for the others functions.

Here is my code :

VideoEditor.transcodeVideo({
      fileUri: this.post.video, ///storage/emulated/0/DCIM/Camera/VID_20161210_153958.mp4
      outputFileName: 'output.mp4',
    	outputFileType: 1,
          saveToLibrary: true,
          maintainAspectRatio: true,
          width: 640,
          height: 640,
          videoBitrate: 1000000, // 1 megabit
          audioChannels: 2,
          audioSampleRate: 44100,
          audioBitrate: 128000,
    })
      .then((fileUri) => {
//do something
})
      .catch((error: any) => console.log('video transcode error', error));

Clemouuche avatar Dec 10 '16 22:12 Clemouuche

I've had success prepending "file://" to the fileUri.

so instead of /storage/emulated/etc, try file:///storage/emulated/etc

Does that solve the problem?

Redmage3555 avatar Feb 03 '17 18:02 Redmage3555

I am having this exact same problem. I am using the MediaCapture plugin from cordova to capture video, that returns a MediaFile whose properties are...

{
  end: 0,
  fullPath: "file:///storage/emulated/0/DCIM/Camera/20170906_150905.mp4",
  lastModified: null,
  lastModifiedDate: 1504735750000,
  localURL: "cdvfile://localhost/sdcard/DCIM/Camera/20170906_150905.mp4",
  name: "20170906_150905.mp4",
  size: 2676449,
  start: 0,
  type: "video/mp4"
}

I am then trying to crop the video to be the correct width with this plugin so I am using...

 this.media.captureVideo().then(videoData => {
   this.editor.transcodeVideo({
     fileUri: videoData[0].fullPath, // file:///storage/emulated/0/DCIM/Camera/20170906_150905.mp4
     outputFileName: 'justatest.mp4',
     outputFileType: this.editor.OutputFileType.MPEG4,
     saveToLibrary: false,
     height: 800,
     maintainAspectRatio: true
   }).then(fileUri => {
     //upload video
   }).catch(err => {
     console.log("caught error transcoding video");
     console.log(err);
   });
 });

And I am getting that same error

java.net.MalformedURLException: Protocol not found: file:///storage/emulated/0/DCIM/Camera/20170906_150905.mp4'

I have tried removing the "file://" before it, doesn't work. I have tried using the localURL instead of the fullPath, doesn't work. I have tried removing the cdvfile:// before the localURL, doesn't work. No matter what I do I will either get the "Protocol not found:" or "unknown protocol". Is there any fix for this, I can't get it to work and I HAVE to be able to resize teh video to a max height of 800px for my project to work. Please help. Thank you.

danwguy avatar Sep 06 '17 22:09 danwguy

Poderia ser o saveToLibrary, te bloqueando, o meu resolveu apenas tratando o caminho do arquivo que estava sem o file:// Fiz a inserção e funcionou de primeiro!

disk8ista avatar Dec 02 '17 13:12 disk8ista

Any solution on this yet ?

hardikrawal23 avatar Mar 27 '18 08:03 hardikrawal23

This worked.

this.media.captureVideo().then(videoData => {
  let fileUri = videoData[0].fullPath
  if (cordova.platformId === 'android'
    && !(new RegExp(location.protocol + '//')).test(fileUri)) {
    fileUri = location.protocol + '//' + fileUri
  }
   this.editor.transcodeVideo({
     fileUri: fileUri
     ...

amatakasap avatar May 27 '18 08:05 amatakasap