How to play RTSP url from within app in ios

Deadly 提交于 2019-12-12 09:52:45

问题


I have found many suggestion in stack overflow regarding usage of FFmpeg and link of github for DFURTSPPlayer but it is not compiling. But after integrating FFmpeg what I have to write? suppose i am having HTTP urls then I write:

code

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

So for using RTSP urls what kind of code should i write?


回答1:


Here is another post that has an example FFmpeg code that receives an RTSP stream (this one also decodes the stream to YUV420, stores it in pic, then converts the frame to RGB24, stores in picrgb and writes it to a file). So to achieve something similar to what you have for HTTP you should:

1) Write a wrapper Objective-C class for the FFmpeg C code, or just wrap the code in functions/functions that you will call directly from Objective-C code. You should have a way to pass the RTSP url to the class or function and provide a callback for a new frame. In the class/function start a new thread that 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 perform asynchronous I/O by using your own custom IO context and that would actually allow you to avoid creating the thread, but if you are new to FFmpeg maybe start with the basics and then you can improve your code later on.

2) In the callback update the view or whatever you are using for display with the decoded frame data.



来源:https://stackoverflow.com/questions/26376215/how-to-play-rtsp-url-from-within-app-in-ios

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!