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

java.io.IOException

Open gusgoose opened this issue 8 years ago • 11 comments

Hi,

While using this plugin in an android app in ionic (1), I'm getting an error "java.io.IOException" (which comes through the error promise) no matter what I try. The VideoEditor object appears fine in the window.

Any help or suggestions about how to get more info on the error would be VERY much appreciated.

setTimeout(function(){

                console.log("full path to current video is:" + transPath);  // e.g. file:/storage.../20160808_172011.mp4
                console.log("new vid name will be: " + videoFileName); // ( randomly set every time)


               window.VideoEditor.transcodeVideo(
                    videoTranscodeSuccess,
                    videoTranscodeError,
                    {
                        fileUri: transPath,
                        outputFileName: videoFileName, 
                        outputFileType: window.VideoEditorOptions.OutputFileType.MPEG4,
                        optimizeForNetworkUse: window.VideoEditorOptions.OptimizeForNetworkUse.YES,
                        saveToLibrary: true,
                        maintainAspectRatio: true,
                        width: 640,
                        height: 640,
                        videoBitrate: 1000000, // 1 megabit
                        audioChannels: 2,
                        audioSampleRate: 44100,
                        audioBitrate: 128000, // 128 kilobits
                        progress: function(info) {
                            console.log('transcodeVideo progress callback, info: ' + info);
                        }
                    }
                );

                }, 2000);

   function videoTranscodeSuccess(result) {
                      // tested code here
                    }

   function videoTranscodeError(err) {
                        console.log('videoTranscodeError, err: ' + err);
                    }

gusgoose avatar Aug 08 '16 16:08 gusgoose

It is also occurring with the createThumbnail method, so I'm assuming this is something to do with actually accessing the file (as the error suggests). Latest android operating system, etc.

gusgoose avatar Aug 11 '16 22:08 gusgoose

I am also getting error java.io.IOException when I capture image.

ayyazzafar avatar Aug 28 '16 18:08 ayyazzafar

I am using samsung galaxy s5 with android version 6.0.1

ayyazzafar avatar Aug 28 '16 18:08 ayyazzafar

Hi, i'm facing the same issue. I manage to restore plugin functionalities downgrading targetSdkVersion to"22" from "23" in my AndroidManifest.xml. It seems that from api 23 you need to declare the permission in activity even if you have already declared in manifest. Here is a link which can explain the issue and how to resolve it. http://stackoverflow.com/questions/33030933/android-6-0-open-failed-eacces-permission-denied If you can please solve it, i will like to restore the API 23 for my project which is using this plugin. Thank you.

ghost avatar Sep 08 '16 14:09 ghost

I found reason and solution of this issue. Reason: New versions like marshmallow has new permission rules. They have different logic as compared to old android versions.

Marshmallow needs app to request required permissions on run time but lower versions don't need permissions on run time.

So because of this difference most of the plugins are getting this type of error.

Solution: You have to ask for permissions in run time. I am using this plugin to check and request for permissions: cordova-plugin-android-permissions With this plugin if you run command to request for permission then it will show a popup in marshmallow to allow for that specific permission. If user accepts permission then let them use app otherwise close app with some warning.

I hope this will help many people because It helped me after spending several days on this issue.

ayyazzafar avatar Sep 08 '16 14:09 ayyazzafar

As posted by ayyazzafar asking permissions with cordova-plugin-android-permissions should solve the issue. Anyway the request for permissions should be integrated in this plugin methods, so we should not install another plugin.

Is there any chance this will be considered (and done) or we should use cordova-plugin-android-permissions to avoid this issue? @rossmartin @jbavari @lsilvs (just tagging who has made last commits on this plugin)

ghost avatar Sep 09 '16 08:09 ghost

@ayyazzafar What permission name have you requested for this to work ?

scopsy avatar Oct 30 '16 15:10 scopsy

@scopsy I requested this permission: WRITE_EXTERNAL_STORAGE Because cordova-plugin-video-editor needs that permission to perform its functions. Here you can see list of all permissions which you can request on runtime: https://developer.android.com/reference/android/Manifest.permission.html

ayyazzafar avatar Oct 30 '16 15:10 ayyazzafar

same problem get error message of VideoEditor.getVideoInfo

subhash8108 avatar Feb 22 '17 14:02 subhash8108

To try and find a solution, I used cordova-plugin-android-permissions to give my app every permission listed here, but it still receives a java.io.IOException

return self.videoEditor.transcodeVideo({
    fileUri: 'file:///storage/emulated/0/DCIM/Camera/VID_20170718_193213.mp4',
    outputFileName: targetFileName || 'output-mobile',
    outputFileType: self.videoEditor.OutputFileType.MPEG4,
    saveToLibrary: false,
    deleteInputFile: true,    
    maintainAspectRatio: true,
    width: 720,                 
    height: 480,              
    progress: fnProgress || undefined
});

I've checked the file and it does exist on the Android device.

danielflippance avatar Jul 19 '17 02:07 danielflippance

Turns out that on Android, recording video greater than 640x360 causes a failure which may be related to this issue. See https://github.com/jbavari/cordova-plugin-video-editor/issues/95

danielflippance avatar Jul 19 '17 08:07 danielflippance