stream video and audios with seperate remote urls on iOS

I need to stream a video and 4 audio from a remote url and play the in sync. I'm new to complex audio/ video playback and processing.


I tried using AVAudioEngine, but AVAudioPlayerNode doesn't play with a remote url. Also AVAudioPlayerNode doesn't support video format (.mp4). It crashed and threw an errer

[avae] AVAEInternal.h:103:_AVAE_CheckNoErr: [AVAudioFile.mm:133:AVAudioFileImpl: (ExtAudioFileOpenURL((CFURLRef)fileURL, &_extAudioFile)): error 1685348671


Please guide me how can I achieve this?

Replies

In principle, you can do this by constructing an AVComposition. Each track of the composition is one of your assets (total of 5) specified via an AVAsset with a URL to the remote media.


The AVComposition is itself a subclass of AVAsset, so you can then use it to create an AVPlayerItem that refers to the composition.


Then you give the AVPlayerItem to an AVPlayer to play all of the tracks on the same timeline.


If you approach this methodically, it should be pretty straightforward to do.