Avoid audible glitch when clipping and re-concatenating a single audio source
See original GitHub issueIt works perfect when play a single .m4a file with ProgressiveMediaSource. But it seems not sealmess when play the same audio file with ClippingMediaSource and ConcatenatingMediaSource. For example
val durations = longArrayOf(20100, 467, 11233, 7100, 6267, 10300)
var start = 0L
val audioFile = File(dir, "sample.m4a")
val audioSource = DefaultMediaSourceFactory(context)
.createMediaSource(MediaItem.fromUri(Uri.fromFile(audioFile)))
val concatAudioSource = ConcatenatingMediaSource(true)
for (i in 0 until durations.size) {
val durationUs = durations[i] * 1000
val end = start + durationUs
val clipAudio = ClippingMediaSource(audioSource, start, end)
concatAudioSource.addMediaSource(clipAudio)
start = end
}
_player?.run {
setMediaSource(concatAudioSource)
prepare()
}
then you will heard that an obvious pause(maybe glitch?, I’m not sure) between two period. It’s easy to reproduce
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:16 (9 by maintainers)
Top Results From Across the Web
pydub audio glitches when splitting/joining mp3 - Stack Overflow
I need the audio playback to be 'seamless' with no audible joins between the separate pieces. At the moment however, the joins between...
Read more >How can I troubleshoot playback issues on my device? - Audible
Skipping audio; Static or background noises. There are a few basic troubleshooting steps that may resolve these issues. Some options include:.
Read more >10 Unity Audio Tips (That You Won't Find in the Tutorials)
It's possible to force an individual Audio Source to ignore Audio Listener Pause, allowing it to play even while other audio sources are...
Read more >just_audio 0.6.8 | Flutter Package - Pub.dev
Compose complex arrangements of audio through concatenating, looping and clipping. Works with audio_session to handle phonecall and other audio interruptions.
Read more >Master Audio - AAA Sound Solution. #1 audio plugin on Asset ...
Mesh / spline audio - position audio source at the closest part of ... Fixed bug: Single song playlist that loops with Preload...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The reason is that ExoPlayer flushes the
MediaCodec
between the different audio resources. If you disable the flushing manually and keep the same codec instance, everything works smoothly without any audible glitches.We have to flush the codec in the general case because we can’t know whether feeding data from two audio sources to the same decoder consecutively is save (=doesn’t result in some other form of audible glitch). So this enhancement is tracking to either:
ClippingMediaSource
, so needed to be forwarded from this source somehow.And I tried that if I cut a resource at an exact pcm frame(I use atds as audio format), there will produce a glitch either. so I guess the reason why produce a glitch is not because ExoPlayer can not cut audio resource at an exact pcm frame but there has no pre-cache of next period when the active period is playing. But I’m not sure about that. I will read source code more deeply when I have time。