Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VideoEditor reference error #31

Closed
kh411d opened this issue Oct 19, 2015 · 9 comments
Closed

VideoEditor reference error #31

kh411d opened this issue Oct 19, 2015 · 9 comments

Comments

@kh411d
Copy link

kh411d commented Oct 19, 2015

installed with this command,
cordova plugin add https://github.com/jbavari/cordova-plugin-video-editor.git

Got Reference Error issue here,
[phonegap] [console.error] ReferenceError: VideoEditor is not defined

I've tried serveral way to load,
load with deviceReady but still not resolve the issue.
"navigator.device.VideoEditor" still not resolve the issue.
"$window.plugins.VideoEditor" still not resolve the issue.
creating ngCordova plugins doesn't work either.

I really have a hard time to debug this
any help guys.. I'm using Cordova 5.2.0

@DaDanny
Copy link

DaDanny commented Oct 26, 2015

Try wrapping your code in a timeout like so:

 $timeout(function(){
        VideoEditor.transcodeVideo(
          videoTranscodeSuccess,
          videoTranscodeError,
          {
            fileUri: videoFile.fullPath,
            outputFileName: YOUR_TRANSCODED_FILE,
            quality: VideoEditorOptions.Quality.LOW_QUALITY,
            outputFileType: VideoEditorOptions.OutputFileType.MPEG4,
            optimizeForNetworkUse: VideoEditorOptions.OptimizeForNetworkUse.YES
          }
        );
      },100);

@kh411d
Copy link
Author

kh411d commented Oct 29, 2015

Thx, I got this work correctly now, the problem was on phonegap dev tools that I used to emulate android and it seems that tool is not reliable for debugging, too many false error

Anyway, are there some tips to speed up the encoding process, I got more than 2 minutes when encoding a 1 minute low quality video file, tested on android lollipop oneplus one cyanogen rom

nb: this is the app that I used to debug https://play.google.com/store/apps/details?id=com.adobe.phonegap.app

@DaDanny
Copy link

DaDanny commented Oct 30, 2015

While this might not be the exact solution you are looking for, heres what I did.

1.) I limited the video length to 10 seconds. If you really need long videos, thats fine, my second solution should help with that. But I decided 10 seconds was long enough for my needs.

2.) Do the transcoding in the background. I created a video service that takes the video file returned from the cordova media plugin, and that service handles the transcoding and uploading. This allows the user to keep using the app while in the background, their video is being processed. I also display a useful message that changes as it processes ("Transcoding video....", "Generating thumbnail..." , "Uploading Video..." etc). and that helps with the longer processing times.

The only issue I see with this is there may be some slow down as the video processes, so I limit what the user can do while its processing.

I hope that helps!

@kh411d
Copy link
Author

kh411d commented Nov 3, 2015

Do you have any tutorial to create video service like you did? I've tried red folder plugin with no luck

@DaDanny
Copy link

DaDanny commented Nov 5, 2015

Sure, I'll write something up in the next couple days.

@cameronws
Copy link

I'd also be interested in something like that @DaDanny .

@kh411d
Copy link
Author

kh411d commented Nov 5, 2015

Wow thx, I'm gonna wait your post @DaDanny.

In the meanwhile this is my temporary solution,
I tried a backgroundMode plugin https://github.com/katzer/cordova-plugin-background-mode, thus when the trancoding start, the backgroundMode will be enabled, till got disabled after transcoding finished.
I know this is not a background service but its a simple solution to notified user that there is an ongoing process for encoding the video.
The obstacle is when user exiting the app, transcoding will be killed, so then I use a "confirm to exit application" (back twice to exit) to acknowledge user that any video processing will be terminated if this app exited.

@DaDanny
Copy link

DaDanny commented Nov 6, 2015

http://codepen.io/DaDanny/pen/jbePjN

So honestly I'm not doing anything crazy. I just have a service which takes in the normal video file and transcodes that and then will upload it to AWS(not in example).

I left out a few things that were more specific to my app, but this should still work for you guys. I've tested it quite a few times and it works great for my use case.

The only issue I see is if someone kills the app while a video is being transcoded, but so far I haven't had any issues. I also limit videos to 10sec, so the longest I've had to wait for a video to process is about 20-25 seconds. If you are worried about someone taking a video then immediately killing the app, then a workaround would be like @kh411d suggested with the background plugin, but I never used it and haven't had any complaints with my current solution.

I just tested it on Android, and if the user hits the Android home button and sends the app to the background, this will still work as expected. However, if they force close out of the app, it will not work. So if you are worried about someone killing the app while they are transcoding a video, then you will need another solution which I don't have currently.

Let me know if you guys have any other questions. I'm making an app that lets people take videos and send those to their friends and it generates Thumbnails for every video, and does it pretty fast. If you guys would like to see how I did that, I've been thinking of writing an actual tutorial :)

@rossmartin
Copy link
Collaborator

This should be fixed in the latest version - https://github.com/jbavari/cordova-plugin-video-editor/tree/0.0.6

Thanks for sharing the info @DaDanny

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants