如何在 iOS 上播放从套接字手动加载的视频?

发布于 2024-10-11 01:20:19 字数 437 浏览 3 评论 0原文

这是相当棘手的一个......

我正在尝试在 iOS 上通过网络传输视频(H264)。但是,我通过远程服务器的打开套接字(使用 CocoaAsyncSocket)将视频数据放入缓冲区,因此我没有可用于创建 AVAsset 或 MPMoviePlayer 的视频 URL。该视频是实时流,因此如果有任何区别,数据将不断出现(即没有设置持续时间)。

我必须这样做,因为服务器是 RTSP 服务器。我已经编写了自己的 RTSP 客户端,用于发送命令和接收响应,现在我尝试对通过连接传输的视频数据做一些有用的事情。

关于如何播放该视频有什么想法吗?我目前唯一能想到的就是以某种方式保存到文件并加载该文件(但我不知道这是如何工作的,因为我将不断加载新数据),或者以某种方式手动执行某些操作像 ffmpeg 一样。不,不幸的是我无法让服务器进行 HTTP Live Streaming。

任何帮助将不胜感激!

Rather tricky one this...

I'm trying to stream a video (H264) across a network on iOS. However, I'm getting the video data into a buffer through an open socket to the remote server (using CocoaAsyncSocket), so I don't have a URL to the video that I can use to create an AVAsset or an MPMoviePlayer. The video is a live stream, so the data will just keep coming (i.e. No set duration) if that makes any difference.

I'm having to do it this way as the server is an RTSP server. I've written my own RTSP client for the sending of commands and receiving of responses, and now I'm trying to do something useful with the video data that comes over the connection.

Any ideas on how I can play back this video? The only things I can think of currently are somehow saving to a file and loading that (but I don't see how that'll work, as I'll be continually loading new data), or resorting to doing it manually somehow with something like ffmpeg. And no, unfortunately I can't make the server do HTTP Live Streaming instead.

Any help would be greatly appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

憧憬巴黎街头的黎明 2024-10-18 01:20:19

我还没有深入研究 AVFoundation,但您也许可以通过使用 AVAssetWriter 创建一个 AVAsset 来实现它。您提供 AVAssetWriter 一个 AVAssetWriterInput 实例,它获取 CMSampleBuffer 数据并将其打包以供 AVAssetWriter 使用。

基于 文档 code>AVAssetWriterInput,它旨在从“实时源”获取数据。

我希望我能提供更多帮助,但希望这能为您指明正确的方向。

I haven't had to dig this deeply into AVFoundation yet, but you might be able to pull it off by creating an AVAsset with an AVAssetWriter. You provide AVAssetWriter an instance of AVAssetWriterInput which takes CMSampleBuffer data and packages it up for the AVAssetWriter.

Based on the docs for AVAssetWriterInput, it is designed to take data from a "real-time source".

I wish I could be of more help, but hopefully this will point you in the right direction.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文