Skip to content

Reducing the Minimum Amount of Audio Data passed into ExoPlayer for it to begin playing #6325

@peurpdapeurp

Description

@peurpdapeurp

[REQUIRED] Searched documentation and issues

  1. I've looked at the DefaultLoadControl javadoc reference.
  2. I've looked at the Customization page of the ExoPlayer developer guide (https://exoplayer.dev/customization.html).

[REQUIRED] Question

I'm currently trying to play streamed AAC ADTS audio frames through the ExoPlayer, and running into the issue that I cannot play a short audio stream using the ExoPlayer.

I am feeding AAC ADTS audio frames into the ExoPlayer through a ProgressiveMediaSource which contains an InputStreamDataSource (a custom DataSource implementation which takes in AAC ADTS frames using an InputStream). The ExoPlayer never leaves the Player.STATE_BUFFERING state when I give it 64 AAC ADTS frames (all around 90 bytes in size), but it does enter the Player.STATE_READY state and start playing back audio when I give it far more frames (by repeatedly writing the 64 AAC ADTS frames into the InputStream that the ExoPlayer is reading audio data from). From a rough test, I estimate that ExoPlayer starts playing audio when it's given around 10000 - 20000 bytes of audio data.

In order to get around this, I tried injecting a customized LoadControl using the DefaultLoadControl.Builder API as detailed in the DefaultLoadControl javadoc page, and setting the back buffer, buffer durations, and target buffer bytes all to very low values, like so:

    ExoPlayer player = ExoPlayerFactory.newSimpleInstance(ctx_, new DefaultTrackSelector(),
                                                          new DefaultLoadControl.Builder()
                                                          .setBackBuffer(600, false)
                                                          .setBufferDurationsMs(600,
                                                                                600,
                                                                          600,
                                                                600)
                                                          .setTargetBufferBytes(600)
                                                          .createDefaultLoadControl());

However, this still did not allow me to reliably playback an audio-stream of 64 ADTS AAC frames (strangely, I was able to play the short audio stream once, but it did not work again and I am not exactly sure why it succeeded in playing once).

My questions are:

  1. Am I configuring the ExoPlayer properly to do what I want, which is to reduce the amount of audio data it receives before it starts playing back the audio data it has?
  2. I would ideally like for the ExoPlayer to begin playing back audio after receiving only a few ADTS AAC frames (~ 100 - 300 bytes); is this possible with the ExoPlayer?

My code for playback is here: https://github.com/peurpdapeurp/basic_java_audio_stream_consumer/blob/exoplayer/app/src/main/java/com/example/audio_consumer/StreamPlayerTester.java

Thank you for any help on this question.

Link to test content

I am trying to play the AAC ADTS frames in the MUSIC_ADTS_FRAMES_BUFFER here: https://github.com/peurpdapeurp/basic_java_audio_stream_consumer/blob/exoplayer/app/src/main/java/com/example/audio_consumer/TestFrames.java

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions