Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsupported conversion exception #1

Open
Valrog opened this issue Jun 7, 2017 · 3 comments
Open

Unsupported conversion exception #1

Valrog opened this issue Jun 7, 2017 · 3 comments
Labels

Comments

@Valrog
Copy link

Valrog commented Jun 7, 2017

Greetings, I've used this project to extend the functionality of JavaFX so that it supports the playback of Ogg files. I'm using Clip to play files instead of a SourceDataLine. However, I cannot play every Ogg file and I get the following error.

IllegalArgumentException: Unsupported conversion: PCM_SIGNED 16000.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian from VORBISENC 48000.0 Hz, unknown bits per sample, mono, 1 bytes/frame, 10000.0 frames/second

Here is my play method.

public void playAudio() { 
   
        try {

            File audioFile = getAudioFile();

            if (!audioFile.exists()) {
                logger.error("No file to play!");
                return;
            }

            AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(audioFile);

            if (audioInputStream == null) {
                logger.error("No file stream to play!");
                return;
            }

            AudioFormat format = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 16000f, 16, 1, 2, 16000f, false);

            AudioInputStream convertedAudioInputStream = AudioSystem.getAudioInputStream(format, audioInputStream);

            DataLine.Info info = new DataLine.Info(Clip.class, format);

            clip = (Clip) AudioSystem.getLine(info);
            clip.addLineListener(this);
            clip.open(convertedAudioInputStream);
            this.playCompleted = false;
            clip.start();

        } catch (LineUnavailableException | UnsupportedAudioFileException | IOException ex) {
            logger.error(StackTraceHelper.getStackTrace(ex));
        } catch (Throwable ex) {
            logger.error(StackTraceHelper.getStackTrace(ex));
        }
    }

Files differ in Sample rate and Bitrate. Those who can be played have

Sample rate: 16000 Hz
Bitrate: 48 kbps

Those who cannot be played have

Sample rate: 48000 Hz
Bitrate: 80 kbps

All are encoded with Vorbis and have a Mono channel.

@Trilarion
Copy link
Owner

I'm not actively working on the project anymore. Maybe someone else could help.

A complete stacktrace of the exception and maybe a very short example ogg file would be nice to have.

@Trilarion Trilarion added the bug label Jun 8, 2017
@Valrog
Copy link
Author

Valrog commented Jun 8, 2017

Here is the complete stack trace.

Unsupported conversion: PCM_SIGNED 16000.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian from VORBISENC 48000.0 Hz, unknown bits per sample, mono, 1 bytes/frame, 6000.0 frames/second, 
java.lang.IllegalArgumentException: Unsupported conversion: PCM_SIGNED 16000.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian from VORBISENC 48000.0 Hz, unknown bits per sample, mono, 1 bytes/frame, 6000.0 frames/second, 
	at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:974)
	at test.audioplayerdemo.AudioPlayerManager.play(AudioPlayerManager.java:58)
	at test.audioplayerdemo.FXMLController.lambda$handlePlay$0(FXMLController.java:81)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:748)

Here are the sample audio files. File Audio_Sample_16kHz_48kbps works fine, the other two throw the exception.

Sample_Audio.zip

@goxr3plus
Copy link

Maybe i can fix this , reading the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants