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

Expose properties for skipSilence #6705

Closed
yak27 opened this issue Nov 27, 2019 · 4 comments
Closed

Expose properties for skipSilence #6705

yak27 opened this issue Nov 27, 2019 · 4 comments
Assignees

Comments

@yak27
Copy link

yak27 commented Nov 27, 2019

#5165 # [REQUIRED] Use case description
I was using an app that had a "skip silence" feature and while using it I thought to myself "This is very useful but I would like to adjust the replacement silence as it's a bit too abrupt. This seems like a simple fix and if it were open source I just might do it myself." Turns out it is open source and uses ExoPlayer.
So this feature request is if those properties can be exposed to change the properties of skip silence.

This description is a little long-winded but I want to it make clear how I'm not actively involved in ExoPlayer and not to come off seeming I know more than I do.

Proposed solution

I checked SilenceSkippingAudioProcessor.java and it has PADDING_SILENCE_US which seems to be what I was looking for, also it declared as static so I'm not sure if it can be changed realtime. There are also useful properties such as what's considered silence.
So a system where this:
SkipSilenceProperties skipSilence = new PlaybackParameters.SkipSilenceProperties(200, 300, .5); // Padding in ms, Length Detection in ms, Threshold declared as a float from 0-1 player.setPlaybackParameters(skipSilence);
code can be executed, or something like it.

Alternatives considered

Ignoring this issue by saying who would want to make such changes to skip silence. Our presets are golden and to say otherwise is akin to blasphemy. Let's put this in the bin where we put that proposal those folks suggested for performance improvements.

-yak27

@Samrobbo
Copy link
Contributor

Hi, the above referenced commit has added the functionality you were hoping to see.

To use this, you would have to pass a custom SilenceSkippingAudioProcessor to the DefaultAudioSink. However to do this, you will need to override the DefaultRenderersFactory, changing the buildAudioRenderers method (which is where the DefaultAudioSink is created).

The following snippet is an example of how you would create a DefaultRenderersFactory with this change.

RenderersFactory renderersFactory =
          new DefaultRenderersFactory(/* context= */ this) {
            @Override
            protected void buildAudioRenderers(
                Context context,
                int extensionRendererMode,
                MediaCodecSelector mediaCodecSelector,
                boolean enableDecoderFallback,
                AudioProcessor[] audioProcessors,
                Handler eventHandler,
                AudioRendererEventListener eventListener,
                ArrayList<Renderer> out) {
              MediaCodecAudioRenderer audioRenderer =
                  new MediaCodecAudioRenderer(
                      context,
                      mediaCodecSelector,
                      enableDecoderFallback,
                      eventHandler,
                      eventListener,
                      new DefaultAudioSink(
                          AudioCapabilities.getCapabilities(context),
                          new DefaultAudioProcessorChain(
                              audioProcessors,
                              new SilenceSkippingAudioProcessor(
                                  /* minimumSilenceDurationUs= */ 150000,
                                  /* paddingSilenceUs= */ 20000,
                                  /* silenceThresholdLevel= */ (short) 1024),
                              new SonicAudioProcessor()),
                          false));
              out.add(audioRenderer);
            }
          };

ojw28 pushed a commit that referenced this issue May 28, 2020
andrewlewis pushed a commit that referenced this issue Jun 1, 2020
@yak27
Copy link
Author

yak27 commented Jun 4, 2020

Is it on the roadmap for these parameters to be applied from the SimpleExoPlayer class rather than it being set with the factory?

@Samrobbo
Copy link
Contributor

Samrobbo commented Jun 8, 2020

Yes, but it's a low priority enhancement.

@yak27
Copy link
Author

yak27 commented Jun 8, 2020

Thank you, and thanks for your work.

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

No branches or pull requests

3 participants