hamoid / video_export_processing

Processing library that interfaces with ffmpeg to export video files
http://funprogramming.org/VideoExport-for-Processing/
GNU General Public License v2.0
116 stars 19 forks source link

Does not work in exported Mac application #47

Closed runemadsen closed 6 years ago

runemadsen commented 6 years ago

This library works perfectly when building from the IDE, but when I run it from an application, I get:

java.lang.NoClassDefFoundError: com/sun/jna/platform/win32/Wincon
    at logogenerator.generateLogo(logogenerator.java:340)
    at logogenerator.draw(logogenerator.java:266)
    at processing.core.PApplet.handleDraw(PApplet.java:2437)
    at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1557)
    at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:316)
Caused by: java.lang.ClassNotFoundException: com.sun.jna.platform.win32.Wincon
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 5 more

I'm using Processing 3.3.6 and it crashes on the following line:

VideoExport videoExport = new VideoExport(this, fullpath, pg);

Any thoughts on this? I'm running Java version 9.0.4.

hamoid commented 6 years ago

I can reproduce this. I had not tried exporting the app. Very weird, because it mentions win32 even if you're on Mac and I'm on Linux. I'll take a look.

runemadsen commented 6 years ago

Thanks Abe! I’m a bit dumbfounded too. Let me know if there’s anything I can do to help. On Sun, 11 Feb 2018 at 7:08 PM Abe Pazos notifications@github.com wrote:

I can reproduce this. I had not tried exporting the app. Very weird, because it mentions win32 even if you're on Mac and I'm on Linux. I'll take a look.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/hamoid/video_export_processing/issues/47#issuecomment-364743118, or mute the thread https://github.com/notifications/unsubscribe-auth/AALuFVb4SGpUSWWAYRGupU5HFeCJiHdzks5tTsoqgaJpZM4SBNCQ .

hamoid commented 6 years ago

I asked in the Processing forum. I'm not an expert in Java packaging and related issues. I tried printing some debug info from the library and from the sketch, but there's no output, so I believe java is encountering this issue before starting the program.

I'll search for something like #ifdef for java, to see if I could remove code from the source when running certain platforms.

hamoid commented 6 years ago

Ok I found one workaround. Look at the launch script. In my case it's called basic. It's missing both jna.jar and jna-platforrm.jar. I added them manually and then the app can be launched.

Before (for a script called basic):

#!/bin/sh

APPDIR=$(readlink -f "$0")
APPDIR=$(dirname "$APPDIR")
java -Xms64m -Xmx2048m -Djna.nosys=true -Djava.library.path="$APPDIR:$APPDIR/lib" -cp "$APPDIR:$APPDIR/lib/basic.jar:$APPDIR/lib/core.jar:$APPDIR/lib/jogl-all.jar:$APPDIR/lib/gluegen-rt.jar:$APPDIR/lib/jogl-all-natives-linux-amd64.jar:$APPDIR/lib/gluegen-rt-natives-linux-amd64.jar:$APPDIR/lib/VideoExport.jar" basic "$@"

After:

#!/bin/sh

APPDIR=$(readlink -f "$0")
APPDIR=$(dirname "$APPDIR")
java -Xms64m -Xmx2048m -Djna.nosys=true -Djava.library.path="$APPDIR:$APPDIR/lib" -cp "$APPDIR:$APPDIR/lib/basic.jar:$APPDIR/lib/core.jar:$APPDIR/lib/jogl-all.jar:$APPDIR/lib/gluegen-rt.jar:$APPDIR/lib/jogl-all-natives-linux-amd64.jar:$APPDIR/lib/gluegen-rt-natives-linux-amd64.jar:$APPDIR/lib/jna.jar:$APPDIR/lib/jna-platform.jar:$APPDIR/lib/VideoExport.jar" basic "$@"

So I just added :$APPDIR/lib/jna.jar:$APPDIR/lib/jna-platform.jar somewhere in that long line.

UPDATE: I forgot to mention that I threw those two libraries inside the lib folder too. I'll figure out if I can automate this in the library.

hamoid commented 6 years ago

Should be fixed now. Please re-open if not :)

runemadsen commented 6 years ago

Thank you so much for the quick turnaround. Will investigate tonight!

runemadsen commented 6 years ago

It seems like the library wasn't updated in the Processing library manager. Is that something I can help make happen?

runemadsen commented 6 years ago

I just manually copied version 2.2 into my libraries folder, and I'm still having the same problem with my exported Mac application. I'm wondering whether I made a mistake or the bug is not fixed. Will poke around for a bit and update this issue.

hamoid commented 6 years ago

Hi! :) So I was having exactly the same issue you have on my Linux laptop. I figured out the reason was that the jna.jar and jna-platform.jar were not included and not referenced in the exported app.

In linux, the exported app is a folder that contains a launch script. This script now also includes references those two libraries.

runemadsen commented 6 years ago

Thanks again for being so responsive. I checked my Mac app package, and it has a ton of .jar files in its Java folder, but those two are missing. There are two core root files in the app – Pkginfo and Info.plist but they don't list .jar files at all. Hmmmm, I guess it's time for me to actually start learning about Mac app packages. If I copy the JAR's into the Java folder, it works. So Processing seems to not know about these two JAR's. @shiffman, would you know?

hamoid commented 6 years ago

You're welcome :) In the library folder you manually installed, do you see a library folder that contains jna.jar jna-platform.jar VideoExport.jar? If they are in this folder, I assume those jars should be copied when the application is exported. Do you see any of those three files in the Mac app package? In Linux these files are part of the exported application:

core.jar
gluegen-rt.jar
gluegen-rt-natives-linux-amd64.jar
interactive.jar
jna.jar
jna-platform.jar
jogl-all.jar
jogl-all-natives-linux-amd64.jar
VideoExport.jar
Mantecoder commented 6 years ago

Hi hamoid and runemadsen. I've made some tests also in windows 10 and the same problem with the Export Application in Windows 10. Downloaded new 2.2 version and copied jar files and doesn't work. Any update?

hamoid commented 6 years ago

Hi @Mantecoder, I have now access to Win 10 and OS X so I'll try them there see what I discover.

Mantecoder commented 6 years ago

Thanks a lot! If I may help you testing something just say me.

hamoid commented 6 years ago

I tried in Windows 10 and it worked fine for me.

  1. Download Processing
  2. Install Video Export Library from inside Processing
  3. Download ffmpeg binary. I placed the executable in C:/Windows/System32/
  4. Open Video Export Basic Example
  5. Export application for Windows, include Java
  6. Look at lib folder in the exported app: it contains VideoExport.jar, jna.jar, jna-platform.jar
  7. Run application. It asks for ffmpeg.exe. Choose its location
  8. Press q to quit
  9. Watch the mp4 video.

Where does it differ for you @Mantecoder ?

I'll try in OSX next.

hamoid commented 6 years ago

@runemadsen I tried on Mac OS 10.12.6 (Sierra) and it worked fine. I downloaded processing 3.3.6, ffmpeg was already installed, I added the Video Export Library, run the Basic example successfully, then I exported that example as an app, and it also run fine by double clicking on the app.

What could be the difference? Could you try with the Basic example too? Is there maybe some unexpected interaction with other parts of your project? Do you use many libraries? Different OS?

runemadsen commented 6 years ago

Hmm, interesting. Here's my import list:

import processing.svg.*;
import java.util.UUID;
import processing.pdf.*;
import com.hamoid.*;
import javax.swing.*;

I'll give it a try with the basic example, but it's good to know that this is local to my project.

runemadsen commented 6 years ago

Okay, this completely beats me, but it suddenly started working. I have not changed anything or updated neither Processing or VideoExport. Hmmm....

hamoid commented 6 years ago

Would be nice to know why, but at least we know that the passing of time has a positive effect on this one :) I'll close it until it shows up again :)

runemadsen commented 6 years ago

Deal. Thanks for being so responsive! 👍