如何在 ios 中的应用程序内播放 RTSP url [英] How to play RTSP url from within app in ios

查看:53
本文介绍了如何在 ios 中的应用程序内播放 RTSP url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在堆栈溢出中发现了许多关于 FFmpeg 的使用和 DFURTSPPlayer 的 github 链接的建议,但它没有编译.但是集成FFmpeg后我要写什么?假设我有 HTTP url 然后我写:

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:

代码

moviePath = "http:/path.mp4"movieURL = NSURL.URLWithString(moviePath!)电影播放器​​ = MPMoviePlayerController(contentURL: movieURL)moviePlayer!.play()

那么对于使用 RTSP url 我应该写什么样的代码?

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

推荐答案

这里 是另一篇文章,其中包含接收 RTSP 流的示例 FFmpeg 代码(该代码还将流解码为 YUV420,将其存储在 pic 中,然后将帧转换为 RGB24,存储在 picrgb 并将其写入文件).因此,要实现类似于 HTTP 的功能,您应该:

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) 为 FFmpeg C 代码编写一个包装器 Objective-C 类,或者只是将代码包装在您将直接从 Objective-C 代码调用的函数/函数中.您应该有一种方法可以将 RTSP url 传递给类或函数,并为新框架提供回调.在类/函数中启动一个新线程,该线程将实际执行类似于示例中的代码的内容,并为每个新解码的帧调用回调.注意: FFmpeg 有一种方法可以通过使用您自己的自定义 IO 上下文来执行异步 I/O,这实际上可以让您避免创建线程,但是如果您不熟悉 FFmpeg,则可以从基础开始然后您可以稍后改进您的代码.

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) 在回调中更新视图或您用于显示解码帧数据的任何内容.

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

这篇关于如何在 ios 中的应用程序内播放 RTSP url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆