hamoid / video_export_processing

Processing library that interfaces with ffmpeg to export video files

Home Page:http://funprogramming.org/VideoExport-for-Processing/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NoSuchMethodError when calling endMovie()

lasagnaphil opened this issue · comments

A weird exception is thrown when calling endMovie(), and I haven't been able to figure out the problem.

Stack Trace:
java.lang.NoSuchMethodError: com.sun.jna.platform.win32.WinNT$FILE_NOTIFY_INFORMATION.createFieldsOrder([Ljava/lang/String;)Ljava/util/List;
at com.sun.jna.platform.win32.WinNT$FILE_NOTIFY_INFORMATION.(WinNT.java:886)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.sun.proxy.$Proxy43.(Unknown Source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:739)
at com.sun.jna.Native.loadLibrary(Native.java:506)
at com.sun.jna.platform.win32.Kernel32.(Kernel32.java:42)
at com.hamoid.VideoExport.endMovie(Unknown Source)
at PControlWindow.lambda$setup$1(PControlWindow.java:58)
at CaptureState.stopCapture(CaptureState.java:94)
at CaptureState.update(CaptureState.java:102)
at PControlWindow.draw(PControlWindow.java:65)
at processing.core.PApplet.handleDraw(PApplet.java:2439)
at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1547)
at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:316)

Note: using Windows 10 (x64) and IntelliJ IDEA.

Hi, this error is happening in JNA. It is used only on Windows to send a CTRL+C to the ffmpeg process to tell it to stop gracefully. It can't find the createFieldsOrder() method (which is called internally, not by my code).

I include jna 4.4.0 in my library, which is the latest version available. I don't know why this is happening. Maybe the JNA library needs to be updated for Windows 10.

Have you tried in other Windows versions? (just to know if it there's a pattern).

Mmm... I wonder if I forgot to add a Windows specific component. Could you please try download from https://github.com/java-native-access/jna/tree/master/dist the win32-x86-64.jar file and put it in the VideoExport/library/ folder, together with jna-4.4.0.jar, jna-platform-4.4.0.jar and VideoExport.jar?

Reminder to self: if this doesn't work, ask at https://groups.google.com/forum/#!forum/jna-users

Don't know if it helps, but I get the same mistake but only if I try to record the image of my webcam with the capture library...

Thanks, every detail can help :) So every example works except when involving the webcam? Do webcam examples (without recording) work?

Yes they do (also the examples with recording work but not if I try to use the endMovie() method in any combination with webcam recording)- I even tried to narrow down the problem by starting over new and taking the example sketch "multipleMovies" and include my stuff and switching on and off certain parts. If you like here is my entire (fast written) code.

import processing.video.*;
import com.hamoid.*;

Capture cam;
VideoExport videoExport;


boolean recording = false;

void setup() {
  size(640, 480);
  cam = new Capture(this, 640, 480, "USB2.0 0.3M UVC WebCam", 15);    //avalableCam[camNum] was not present?!?
  cam.start();

  videoExport = new VideoExport(this, "camera.mp4", cam);
  videoExport.setDebugging(false);
}
void draw() {
  if (oncam) {
    if (cam.available()) {
      cam.read();
      image(cam, 0, 0);
    }
    if (recording) {
      videoExport.saveFrame();
    }
  }
}
int bla=0;
void mousePressed() {
  recording = true;
  videoExport.setMovieFileName(bla++ + ".mp4");
  videoExport.startMovie();
  println("Start movie.");
}
void mouseReleased() {
}

boolean oncam=false;
void keyPressed() {
  if (key == 'q') {
    oncam=true;
  }
  if (key=='w') {
    oncam=false;
    cam.stop();
  }
    if (key=='e') {
  recording = false;
  }
    if (key=='r') {
  videoExport.endMovie();
  }
}

I don't know if it makes sense but I can create a empty file if I do not switch on the cam. The only combination that works is the example sketch "webcamSaving" where the endMovie() method is followed by an exit();

Just to let you know: My aim was to make different video files with different names within one sketch (in my real code).

@Myrikum Hi, assuming you're on windows, could you try what I proposed above three days ago? (downloading a jar file and trying again).

Seems that I have found the problem... I was using both the Video and VideoExport libraries, which each had their own version of the jna jar file. After deleting the jna.jar included in the Video library, the problem disappeared. Maybe there was a collision between the two jars....
Anyways, thanks for the reply! :)

Happy to hear! Thanks for sharing, I can tell others if this happens and mention it on the page.

commented

@lasagnaphil thanks, I first tried renaming this file in the directory but it didn't work. Deleting like you did worked for me. 👍

jna and jna-platform jar files needs to be of same version , I have faced the same issue which was resolved with same version of Jar i.e 4.5.0

@reddy1990 I see Processing uses 4.2.0 at the moment ( https://github.com/processing/processing/tree/master/app/lib ), so I guess it would be best that I track what they use, and use the same in this library, right?

Even better, I could just remove jna from this repo, and use Processing's jna files directly...