cordova-plugin-video-editor
cordova-plugin-video-editor copied to clipboard
Error transcode video on Android
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));
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?
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.
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!
Any solution on this yet ?
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
...