How to change permission in terminal I cannot use VideoExport Library.

edited October 2016 in Library Questions

Hi guys,

I have a problem trying to use any of the code from the library of Video Export that they get the same error.

Even with the code from the website itself here > http://funprogramming.org/VideoExport-for-Processing/#examples ,

I also get error with permission thing.

say:

java.io.IOException: Cannot run program "/Users/Tuang/Desktop/DMA_WORKS/Work1_Facial Muscles/Cam_Rec/sketch_161027a/sketch_161027a.pde": error=13, Permission denied
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
    at com.hamoid.VideoExport.startFfmpeg(Unknown Source)
    at com.hamoid.VideoExport.initialize(Unknown Source)
    at com.hamoid.VideoExport.saveFrame(Unknown Source)
    at sketch_161027b.draw(sketch_161027b.java:51)
    at processing.core.PApplet.handleDraw(PApplet.java:2412)
    at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1540)
    at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:316)
Caused by: java.io.IOException: error=13, Permission denied
    at java.lang.UNIXProcess.forkAndExec(Native Method)
    at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
    at java.lang.ProcessImpl.start(ProcessImpl.java:134)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
    ... 7 more
VideoExport error: Ffmpeg failed. Study /var/folders/nq/xsfvm25d249181txfc2_c39c0000gn/T/untitled6197566133901091867sketches/sketch_161027b/camera.mp4.txt for more details.
Could not run the sketch (Target VM failed to initialize).
For more information, read revisions.txt and Help → Troubleshooting.

So I google

1) how to change permission -> which I found that my Mac cannot find the file it said there is no such file.

2) how to find a file in Mac with terminal -> later I found that it is about the space bar in a folder name, so I changed it.

Then, I was able to find a file and I guess I've already changed the permission with chmod 777, since I typed it in and has no error with finding the file thing. However, back to the Processing the same error still there.

3) Do I have FFmpeg ->Terminal said, it cann't find it so I download two versions and installed one but didn't work so try installed another, still didn't work.

Now.. I don't know what to do. Please help! The error still here.

Answers

  • Your problem seems to be installing the required video tool ffmpeg on Mac.

    If you can't figure it out then I recommend installing Homebrew and then installing ffmpeg with brew install ffmpeg

    Once that is done, close a Terminal, reopen a Terminal, and type ffmpeg to test.

    Now, as per the Video Export library README, reset its ffmpeg location.

    Add videoExport.forgetFfmpegPath() to your setup(), run your program once, then remove that line. This will trigger the library asking for the location of ffmpeg again, so you can point to the new location of ffmpeg.

    Back in your new Terminal, type which ffmpeg to find that location.

  • edited October 2016

    I now have complete installed ffmpeg and the terminal can find it. Thank you very much. You helped this community so much.

    However, now I get new error = 2. And what is weird is that they new processing file keep asking for the file that named with the original processing start-up name

    java.io.IOException: Cannot run program "/Users/Tuang/Desktop/DMA_WORKS/Work1_Facial Muscles/Cam_Rec/sketch_161027a/sketch_161027a.pde": error=2, No such file or directory at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) at com.hamoid.VideoExport.startFfmpeg(Unknown Source) at com.hamoid.VideoExport.initialize(Unknown Source) at com.hamoid.VideoExport.saveFrame(Unknown Source) at sketch_161028d.draw(sketch_161028d.java:32) at processing.core.PApplet.handleDraw(PApplet.java:2412) at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1540) at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:316) Caused by: java.io.IOException: error=2, No such file or directory at java.lang.UNIXProcess.forkAndExec(Native Method) at java.lang.UNIXProcess.(UNIXProcess.java:247) at java.lang.ProcessImpl.start(ProcessImpl.java:134) at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) ... 7 more VideoExport error: Ffmpeg failed. Study /var/folders/nq/xsfvm25d249181txfc2_c39c0000gn/T/untitled4236849063551470462sketches/sketch_161028d/basic.mp4.txt for more details. Could not run the sketch (Target VM failed to initialize). For more information, read revisions.txt and Help → Troubleshooting.


    Work1_Facial Muscles/Cam_Rec/sketch_161027a/sketch_161027a.pde is not existed for real. I don't know why the program still asking for this may be I have mass up with the terminal too much !!!

    "sketch_161027a.pde" Is the name that always happen on the error line in every files whether I have created a new file or the file that has changed the name. Any advice?

  • Just guesses:

    1. Try trashing Processing and reinstalling? Might have bad permissions, settings. Make sure to back up your sketches if you need to.
    2. After installing, Open a brand new sketch and run some provided Example code. Does it work normally?
    3. Then import and configure videoExport with a sketch. Try saving and naming the sketch before running, just in case.
    4. Then try your sketch. Save it and give it a real name.
  • edited October 2016

    Also, part of your error says:

    Study /var/folders/nq/xsfvm25d249181txfc2_c39c0000gn/T/untitled4236849063551470462sketches/sketch_161028d/basic.mp4.txt for more details.

    Did you do that? Were there any details?

  • No, I didn't the basic.mp4.txt is the name of the mp4 that can not be created completely. but the other folder, I have no idea what it is.

  • Ok. I have tried it to another mac computer and everything works perfectly. So the problem is about my macbook. I delete the program and delete the folder on document where the program stores the library, then dl the new Processing from the website. Started over again. And the problem is still the same.

    Also, I found that the long folder name you asked is the sketchbook of Processing that the program created in the hidden private folder. Is this helpful in anyway for you to guess something for me to solve the problem???

  • edited October 2016

    Updated. I found another error when completed giving permission to the problem file. (I did create a fake file to giving a permission through Terminal.) It said " java.io.IOException: Stream Closed"

    However, later, my friend only changed the line of videoExport.forgetFfmpegPath() to be AFTER videoExport = new VideoExport(...); , and everything runs smoothly. The End. T_T"

    In conclusion, the trouble of non-programmers is sometimes we misplace the code line. -_-^

  • Glad to hear that you resolved it.

    If I'm understanding, the reason you had that problem was that you must first initialize your videoExport object before you can call its .forgetFfmpegPath() method.

    So the technique for resetting the ffmpeg path should be running a sketch something like this:

    VideoExport videoExport;
    
    void setup(){
      videoExport = new VideoExport();
      videoExport.forgetFfmpegPath()
    }
    
  • edited October 2016

    YES, it is! Hey! Thank you again for your help!

    And... just wondering if you have any suggestion on videoExport.setQuality(); I understand that it should be after declared the videoExport = VideoExport();. The out file seemed work. I can see the icon and size of the file but it doesn't completely export so I cannot play it. I have tried change the line and put it around but no way to make it work!? (I tried out it after dispose() and the file is playable , but I think it is not doing the line, just pass through, because the size is not increased.

      >  import com.hamoid.*;
    > import processing.video.*;
    > 
    > 
    > Movie myMovie;
    > Movie myMovie1;
    > 
    > VideoExport videoExport;
    > boolean recording = false;
    > boolean End = false;
    > Capture cam;
    > int crf = 100;
    > int i = 1;
    > 
    > void setup() {
    >    size(600,400);
    >    frameRate(30);
    >    noStroke();
    >    smooth();
    > 
    >   
    >      String[] cameras = Capture.list();
    >     // The camera can be initialized directly using an 
    >     // element from the array returned by list():
    >             /*if (cameras.length == 0) {
    >             println("There are no cameras available for capture.");
    >             exit();
    >             } else {
    >             println("Available cameras:");
    >             for (int i = 0; i < cameras.length; i++) {
    >               println(cameras[i]);
    >               }
    >             }*/
    >       //When the list come out in line, each lines is a number of camera [i]
    >       //Mostly, first 15 is a built-in camera of the laptop
    >     
    >     cam = new Capture(this, cameras[3]); //built in mac cam "isight"    
    >     //cam = new Capture(this,1280,720, "Live! Cam Sync HD VF0770"); // Stalgia's Live wemcab name
    >     //cam = new Capture(this, cameras[16]); Stalgia's Live wemcab number
    >     cam.start();
    >   
    >   textFont(createFont("SanSerif", 12));
    >   println("Press R to audio and video on nemen.Press again R to stop recording and press S to save it and press Z to proceed.");
    >   videoExport = new VideoExport(this, "data/video" + i + ".mp4");
    >   videoExport.dontSaveDebugInfo();
    >   //videoExport.setQuality(crf);
    >     //println("Set up quality");
    >   println("Movie"+i+" "+"is ready.");
    > }
    > 
    > void draw() {
    >    background(0);
    >    
    >    drawScreenZero(); //camera display 
    >  }
    > 
    > void drawScreenZero() {
    >  //println("drawScreenZero camera");
    >  if (cam.available() == true) {
    >     cam.read();
    >     
    >   }
    >   image(cam, 0,0,width, height);
    >    if (recording) {
    >     videoExport.saveFrame();
    >     println("Record Movie"+" "+i);
    >   }
    > }
    > 
    > void keyPressed() {
    >   if (key == 'r' || key == 'R') {
    >     recording = !recording;  
    >     println("Recording is " + (recording ? "ON" : "OFF"));
    >     
    >     
    > 
    >   } else   if (key == 's' || key == 'S') {  
    >     videoExport.dispose();
    >     println("Done saving movie"+i);
    >     i++;
    >     println("movie"+i+" "+"is next."); 
    >     
    >     videoExport = new VideoExport(this, "data/video" + i + ".mp4");
    >     videoExport.dontSaveDebugInfo();
    >     //videoExport.setQuality(crf);
    >     //println("Set up quality");
    >     }
    >   } 
    
  • edited October 2016 Answer ✓

    @TuangPing -- sorry, I'm not sure.

    Have you tried running the simple options example sketch and and setting the quality to 0, 50, 70, 100? Perhaps there is some specific problem with the fact that you are setting it to 100.

    Also, try checking out other threads about the library, or talking to @hamoid .

  • @Jeremedouglass That's what I was trying to do, to talk to @hamoid. But anyway, I didn't and I figure it out what exactly you just said! it cannot be 100, the best resulotion you can go is 90.

  • Answer ✓

    I missed all this discussion! Thanks for helping Jeremy :)

    So the export fails when you set a quality higher that 90? In which way does it fail?

    I updated the library with one important change. Now you need to call .beginMovie() and .endMovie(). I tried doing this automatically to avoid people typing two more lines of code, but it did not work in all systems (Processing does not always call .dispose()).

    This may help in those cases where the resulting video file was corrupted.

    BTW. Now it's also possible to attach sound to the video :) I hope it works for everyone.

    Cheers!

  • Thanks for the update, @hamoid, and for all your work on this useful library.

  • edited December 2016

    Thank you, everyone! I have made it this far with my program becuase of this supportive community. :D

    To answer @hamoid question, If I do not remember it wrong, the file has been interrupted after done saveframes() in a time limited when tried to compress them out as .mp4 by dispose() . Like, I have set the time to 120000, after this time let the program export the video. But, it didn't export, the program just stop and I got error.

  • However, I will go back to that program and see what happen. Because It is a bit long time ago. I'll tell you later.

  • @hamoid I went back to see the old .pde and the error was when set to 100 the exported file could not be played. The file was compressed and I could see the .mp4 but it said the file is damaged. But, when set to 90 the file was playable. I have tested the same .pde with the new update VideoExport version 0.1.5., same thing happened.

  • Thank you @TuangPing I created an issue and will find out why this happens https://github.com/hamoid/video_export_processing/issues/33

Sign In or Register to comment.