Creating a Rtsp Client for Live Audio and Video Broadcasting in Objective C

Creating a rtsp client for live audio and video broadcasting in objective C

Are you losing any packets on the client? If so, you need to leave "space." If you receive packet 1,2,3,4,6,7, You need to leave space for the missing packet (5).

The other possibility is a what is known as a clock drift problem. The clock (crystal) on your client and server are not perfectly in sync with each other.

This can be caused by environment, temperature changes, etc.

Let's say in a perfect world your server is producing audio samples 20ms audio samples at 48000 hz. Your client is playing them back using a sample rate of 48000 hz. Realistically your client and server are not exactly 48000hz. Your server might be 48000.001 and your client might be 47999.9998. So your server might be delivering faster than your client or vise versa. You would either consume packets too fast and under run the buffer or lag too far behind and overflow the client buffer. In your case, it sounds like the client is playing back too slow and slowly lagging behind the server. You might only lag a couple milliseconds per minute but the issue will keep continuing and it will look like a 1970s lip synced Kung Fu movie.

In other devices, there is often a common clock line to keep things in sync. For example, Video camera clocks, midi clocks. multitrack recorder clocks.

When you deliver data over IP, there is no common clock shared between a client and server. So your issue concerns syncing clocks between disparate devices with no. I have successfully solved this problem using this general approach:

  • A) Let the client count the rate of packets that come in over a period of time.
  • B) Let the client count the rate that the packets are consumed (played back).
  • C) Adjust the sample rate of the client based on A and B.

So your client requires that you adjust the sample rate of the playback. So yes you play it faster or slower. Note that the playback rate change will be very very subtle. You might set the sample rate to be 48000.0001 hz instead of 48000 hz. The difference in pitch would be undetectable by humans as it would only cause a fraction a cent difference in pitch. I gave an explanation of a very simplified approach. There many other nuances and edge cases that must be considered when developing such a control system. You don't just set it and forget it. You need a control system to manage the playback.

An interesting test to demonstrate this is to take two devices with the exact same file. A long recording (say 3 hours) is best. Start them at the same time. After 3 hours of playback, you will notice that one is ahead of the other.

This post explains that it is NOT a trivial task to stream audio and video.

Streaming audio from server to iPhone

Brad mentioned a post that I wrote to stream audio via HTTP. That was this one: Streaming and playing an MP3. I don't mean to be the person that links to his own blog but it does kind of address your question.

In regards to how hard the problem is to solve, you'll notice I've made 4 updates to that post (way more than I've done for anything else), fixing threading errors, memory leaks and network buffering issues. There is a lot to get precisely correct.

RTSP/RTMP Video Streaming Client iOS

DFURTSPPlayer is a working example on GitHub. Will have to double check on licensing issues, but with this it is a good place to start for RTSP.

creating app for playing RTSP streaming videos

Usually not, no one else reported it. However that framework SHOULD be in the search path if its not. Sorry about that

How to create RTMP/RTSP player using FFMpeg for ios

there's a Xcode project based on ffmpeg. It's possible to play RTSP links. Have a look at it:
https://github.com/durfu/DFURTSPPlayer

If you want to know more about RTSP, I can highly recommend you the following link:
https://www.rfc-editor.org/rfc/rfc2326



Related Topics



Leave a reply



Submit