How to play RTSP url from app in ios

I found many suggestions on Stack Overflow regarding using FFmpeg and the github link for DFURTSPPlayer, but it doesn't compile. But after integrating FFmpeg should I write? suppose I have HTTP urls, I write:

code

moviePath = "http:/path.mp4" movieURL = NSURL.URLWithString(moviePath!) moviePlayer = MPMoviePlayerController(contentURL: movieURL) moviePlayer!.play()

So, in order to use RTSP URLs, what code should I write?

+3


source to share


1 answer


Here is another post that has some sample FFmpeg code that receives an RTSP stream (this one also decodes the stream to YUV420, saves it to pic

, then converts the frame to RGB24, saves to picrgb

and writes it to a file). To achieve something similar to what you have for HTTP, you must:

1) Write an Objective-C wrapper class for FFmpeg C code, or just wrap the code with functions / functions that you call directly from Objective-C code. You must have a way to pass the RTSP url to the class or function and provide a callback for the new frame. In the class / function, start a new thread which will actually execute something similar to the code in the example and call a callback for each new decoded frame. NOTE. FFmpeg has a way to do asynchronous I / O using its own custom I / O context and that will actually allow you to avoid creating a stream, but if you're new to FFmpeg maybe start with the basics and then you can improve your code later.



2) In the update callback, the view or whatever you use to display with the decoded frame data.

+1


source







All Articles