hendriks73 / ffsampledsp

FFmpeg based service provider for javax.sound.sampled.
GNU Lesser General Public License v2.1
24 stars 5 forks source link

Support for Amazon linux 2/2023 #18

Closed jkothamb closed 10 months ago

jkothamb commented 11 months ago

Hi Hendrik,

I want to use ffsampledsp-complete version 0.9.53 on amazon linux, but it fails with below error for mp3 as well as for other audio format files. Not sure how do I go about debugging this. Any help is appreciated

javax.sound.sampled.UnsupportedAudioFileException: File of unsupported format
java.desktop/javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:1066)
hendriks73 commented 11 months ago

I would set a breakpoint in AudioSystem.getAudioInputStream(...), right in the first line of that method and step through it. Take note of which AudioFileReaders are installed/found on your system. FFAudioFileReader should be one of them. Are there any messages in std out or the like?

However, to get some more info from FFSampled, turn on java.util.logging. See for example https://stackoverflow.com/a/73227419/942774

jkothamb commented 11 months ago

Hi @hendriks73 : thanks for getting back. It works perfectly fine on mac (development environment), but not on amazon linux where we deploy our application to run as a k8s container. It would be difficult to breakpoint there, but can certainly turn on more logging.

jkothamb commented 11 months ago

Hi, after changing the log level for com.tagtraum.ffsampledsp to TRACE, still no logs

Exception in thread "main" javax.sound.sampled.UnsupportedAudioFileException: File of unsupported format at java.desktop/javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:1066) at ai.XXXX.privaci.utils.audio.AudioUtils.readAudioFile(AudioUtils.java:62) at ai.XXXX.privaci.utils.audio.WhisperTest.main(WhisperTest.java:16)

hendriks73 commented 11 months ago

Are you certain it's in the class path? Try calling com.tagtraum.ffsampledsp.FFNativeLibraryLoader.loadLibrary(). It should produce some log output.

jkothamb commented 11 months ago

hi @hendriks73 : I was able to get the necessary logs

`Oct 27, 2023 5:01:40 PM com.tagtraum.ffsampledsp.FFNativeLibraryLoader arch INFO: Using arch=x86_64

Oct 27, 2023 5:01:40 PM com.tagtraum.ffsampledsp.FFNativeLibraryLoader FINE: NATIVE_LIBRARY_EXTENSION: so

Oct 27, 2023 5:01:40 PM com.tagtraum.ffsampledsp.FFNativeLibraryLoader FINE: NATIVE_LIBRARY_PREFIX: lib

Oct 27, 2023 5:01:40 PM com.tagtraum.ffsampledsp.FFNativeLibraryLoader loadLibrary FINEST: loadLibrary("ffsampledsp", class com.tagtraum.ffsampledsp.FFNativeLibraryLoader)

Oct 27, 2023 5:01:40 PM com.tagtraum.ffsampledsp.FFNativeLibraryLoader loadLibrary FINE: packagedNativeLib: ffsampledsp-x86_64-linux.so

Oct 27, 2023 5:01:40 PM com.tagtraum.ffsampledsp.FFNativeLibraryLoader loadLibrary FINE: Trying Runtime.getRuntime().load("/tmp/ffsampledsp-x86_64-linux-0.9.53.so")

Oct 27, 2023 5:01:40 PM com.tagtraum.ffsampledsp.FFNativeLibraryLoader loadLibrary FINE: Failed to load /tmp/ffsampledsp-x86_64-linux-0.9.53.so (will try other ways): java.lang.UnsatisfiedLinkError: /tmp/ffsampledsp-x86_64-linux-0.9.53.so: libbz2.so.1.0: cannot open shared object file: No such file or directory

Oct 27, 2023 5:01:40 PM com.tagtraum.ffsampledsp.FFNativeLibraryLoader loadLibrary FINE: Trying System.loadLibrary("ffsampledsp-x86_64-linux")

Oct 27, 2023 5:01:40 PM com.tagtraum.ffsampledsp.FFNativeLibraryLoader loadLibrary FINE: Trying System.loadLibrary("ffsampledsp")

Oct 27, 2023 5:01:40 PM com.tagtraum.ffsampledsp.FFNativeLibraryLoader loadLibrary SEVERE: Failed to load native library 'ffsampledsp'. Please check your library path. FFSampledSP will be dysfunctional.`

hendriks73 commented 10 months ago

It seems, ffsampledsp is dynamically linked to bzip2.

Can you please try to install bzip2-dev on your Amazon system?

sudo yum install libbz2-dev

or

sudo dnf install libbz2-dev

Should do the trick. Does it fix the issue? (there may be a similar issue with libz)

And I guess I should consider statically linking both compression libraries.

hendriks73 commented 10 months ago

Or perhaps

sudo yum install bzip2

or

sudo dnf install bzip2

Don't know.

jkothamb commented 10 months ago

hi @hendriks73 : installing libbz2 certainly fixed the issue. I am able to load audio files of different formats. Had to add a symlink for libbz2.so file to make it work. Thanks for all the help.

hendriks73 commented 10 months ago

No problem.

Can you say which link you created? The exact statement? For others who run into the same issue?

jkothamb commented 10 months ago

it was below ln -snf /usr/lib64/libbz2.so.1.0.8 /usr/lib64/libbz2.so.1.0