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

Feature request (fade and crossfade audio)) #2

Open
prime-zs1 opened this issue Nov 1, 2021 · 5 comments
Open

Feature request (fade and crossfade audio)) #2

prime-zs1 opened this issue Nov 1, 2021 · 5 comments
Assignees

Comments

@prime-zs1
Copy link

prime-zs1 commented Nov 1, 2021

It would be extremely helpful to provide fade in/FadeOut and crossfade audio feature. Since current implementation of media3 supports only one Exoplayer, hence crossFade seems not possible.
Since this is the first release, it would be easy to fix it here and add the said feature.

@icbaker
Copy link
Collaborator

icbaker commented Nov 1, 2021

This looks like a duplicate of google/ExoPlayer#3438.

If that issue is fixed it will be fixed in both exoplayer2 and media3. However we don't have current plans to look at this.

I'll leave both issues open for now, we may in future de-dupe them.

@Tolriq
Copy link
Contributor

Tolriq commented Jun 21, 2024

Since this is still the most requested feature I get I wanted to try to provide at least fade in / out if not real crossfade, and wanted to use volumeshaper to do it right.

But I can't seem to find a way to properly access the actual audioTrack to apply it. The only solution I can imagine would be to duplicate DefaultAudioSink to make it open to be able to extend it.

Is there something obvious I'm missing?

@Samrobbo
Copy link
Contributor

You may be able to implement this through an AudioProcessor.

For fade-out, you could have an internal queue of decoded audio with a size that matches your preferred fade out duration. Once end of stream is signal to the processor, it can scale down the audio it has.

For fade-in, this might be more difficult, because AudioProcessor does not have information about whether a flush was related to a seek or a new item in the playlist.

@Tolriq
Copy link
Contributor

Tolriq commented Jun 26, 2024

Actually for fade in I can manage via the audiosink configure to know a new media starts I do that for the replaygain to pass down the metadata.

But the issue is also about how to know the durations and everything from the data the processor have, it's a lot simpler with volumeshaper and sending an event via sendMessage at proper timings.

For the fade out I also have no idea how to calculate the buffer duration and if the user want 5 seconds this means audio is delayed by 5 seconds no?

@Tolriq
Copy link
Contributor

Tolriq commented Jul 22, 2024

So I've made some tests and audioprocessor for fade out can't work for anything else than real normal end of track and pre buffering.

If you want to fade out on pause or when skipping next the processor have already processed the data and is a couple of second later and there's no way to anticipate that.

So the only way to do things in real time when needed and do it properly is the volumeShaper that needs access to the audioTrack to be created.

Since there's already an onAudioTrackInitialized does it make sense to have an official way to access the audioTrack too to be able to call audioTrack.createVolumeShaper() ? (Asking @tonihei too)

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

No branches or pull requests

4 participants