简体   繁体   English

在Android中同时流式传输多个OGG

[英]Streaming multiple OGG simultaneously in Android

I need to be able to play two or more (let's say, up to 5) short ogg files simultaneously. 我需要能够同时播放两个或更多(例如,最多5个)简短的ogg文件。 And by simultaneously I mean in perfect synchrony. 同时,我的意思是完全同步。 I am able to load them to SoundPool and play, but this sometimes creates a noticeable difference in playback start time, which I want to get rid of. 我可以将它们加载到SoundPool并进行播放,但这有时会在播放开始时间上产生明显的差异,我想摆脱它。

From my understanding this can be avoided if mixing PCMs into one buffer and playing. 据我了解,如果将PCM混合到一个缓冲区中并进行播放,可以避免这种情况。 But OGG's are not PCMs and need to be somehow efficiently decoded before playing and latency must be very low, ideally as soon as user presses the button. 但是OGG不是PCM,需要以某种方式有效地解码才能播放,并且延迟必须非常低,最好是在用户按下按钮后立即延迟。 So I figured I need a way to stream OGG into PCM and as I receive buffers I would mix them and feed to AudioTrack. 所以我想我需要一种将OGG流式传输到PCM的方法,当我接收缓冲区时,我将它们混合并馈送到AudioTrack。 My requirement is Android 2.3.3+, so I cannot use any new codecs provided in Jelly Bean. 我的要求是Android 2.3.3+,因此我不能使用Jelly Bean中提供的任何新编解码器。

Also although OGGs themselves are small, there is a lot of them. 同样,尽管OGG本身很小,但数量很多。 So keeping them all decoded in memory (SoundPool or some pre-decoding) may case problems too. 因此,将它们全部解码后保存在内存中(SoundPool或某些预解码)也可能会遇到问题。

Can someone give me a tip where to dig? 有人可以给我小费在哪里挖吗? Can OpenSL ES do that for me? OpenSL ES可以为我做到吗? Or should I think about integrating ffmpeg? 还是我应该考虑集成ffmpeg? And is it even possible to stream simultaneus files with low latency? 甚至可以以低延迟流式传输同时文件吗?

Thanks 谢谢

You can play sounds using AssetPlayers, but this sometimes creates a noticeable difference in playback start time, yeh... 您可以使用AssetPlayers播放声音,但这有时会在播放开始时间上产生明显差异,是的。

So, i recomend to decode ogg using Ogg Vorbis (like here ) and then using this PCM buffer for BufferPlayer. 因此,我建议使用Ogg Vorbis(如此 )对ogg进行解码,然后将此PCM缓冲区用于BufferPlayer。

Btw, check this OpenSL ES wrappers 顺便说一句,检查此OpenSL ES包装器

https://github.com/Suvitruf/Android-ndk/tree/master/OpenSLES https://github.com/Suvitruf/Android-ndk/tree/master/OpenSLES

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM