bytedeco / javacv

Java interface to OpenCV, FFmpeg, and more
Other
7.51k stars 1.58k forks source link

FFmpegFrameGrabber.load(myFile) .. start() crashes in Version 1.5.8 when using a filename with special characters #1945

Closed HagiHagi closed 1 year ago

HagiHagi commented 1 year ago

If i try to load a filename with special characters (excample: Mic Macs Raphael Beau 07 Ca déroule_44100_16_2.wav) my java program crashes without a comment. In version 1.5.7 all is fine. I use java 8.202 and I packaged the software with oracles's jpackager. When the software runs inside the IDE (Netbeans 8) everything works, but if I run the installed software on Windows 10 it crashes without a comment. If I do the same but using javacv_platform-1.5.7 all works fine.

The crash occurs at the code sequence: FFmpegFrameGrabber myGrabber = FFmpegFrameGrabber.load(Mic Macs Raphael Beau 07 Ca déroule_44100_16_2.wav); myGrabber.start();

saudet commented 1 year ago

There's nothing in JavaCPP or JavaCV that changed with regards to strings, but it's possible FFmpeg changed something. Could you try to see if you can open files with avformat_open_input() and a BytePointer using different encodings? It's possible they standardized on UTF-8 or something.

saudet commented 1 year ago

Yes, it looks like they standardized on UTF-8: http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=37787f261639c53998487400e874741c17e85fc6 Please try to use UTF-8 encoding for the filename instead of the platform default.

HagiHagi commented 1 year ago

Thank you very much.

Yes, the problem is the encoding.

I use Oracle's JDK 8.202 When I start the software in the IDE (Netbeans UTF-8 is set) file.encoding is UTF-8! When I pack, install and run the software with Oracle Packager on Windows, the file.encoding is the Windows OS encoding cp.... (ansii). The solution is to make sure the file encoding is UTF-8, this is done by starting the jar with:

java -Dfile.encoding=UTF-8 and and -Dsun.jnu.encoding=UTF-8 mySoftware.jar

Now it works fine!

saudet commented 1 year ago

I've pushed a fix for this in commit https://github.com/bytedeco/javacpp-presets/commit/ae2a14efb7c747661ca198f2e01e1c8665d4dc72. With that, you shouldn't need to modify the encoding for the whole application. Please give it a try with the snapshots and let me know if you are still having any issues: http://bytedeco.org/builds/

saudet commented 1 year ago

Version 1.5.9 has been released with the fix! Thanks for reporting