如何确保 YouTube API 只返回可在 iPhone 上流式传输的视频?

发布于 08-28 03:25 字数 476 浏览 9 评论 0原文

我正在将一些 YouTube 搜索功能构建到 iPhone 应用程序中,并希望确保我只收到可在设备上播放的结果。根据API 参考文档中的搜索视频部分这似乎相对简单:

格式参数指定视频必须以特定视频格式提供。您的请求可以指定以下任意格式:

我已尝试设置“format=1”以限制为:

用于移动视频播放的 RTSP 流媒体 URL。 H.263 视频(高达 176x144)和 AMR 音频。

这提供了很高比例的可播放视频,但有些仍然无法播放,我担心它不会返回其他可播放的视频。

当我将格式字段留空时,我会收到更高比例的不可流式 URL。

I'm building some YouTube search functionality into an iPhone app and want to ensure that I only receive results that will be playable on the device. According to the Searching for videos section in the API reference doc this seems to be relatively straightforward:

The format parameter specifies that videos must be available in a particular video format. Your request can specify any of the following formats:

I've tried setting "format=1" to limit to:

RTSP streaming URL for mobile video playback. H.263 video (up to 176x144) and AMR audio.

This provides a high proportion of playable videos but some are still unplayable and I'm worried that it's not returning others that would be playable.

When I leave the format field blank I receive an even higher proportion of non-streamable URLs.

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

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

发布评论

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

评论(2

胡渣熟男2024-09-04 03:25:20

这听起来不太合适。我的理解是,iPhone 不流式传输 RTSP,而是支持 Apple 的分段文件的 HTTP 流式传输,以通过范围请求进行直播和 MPEG4 视频文件的 HTTP 流式传输。我还希望视频是 H.264 和 AAC 音频。

您的设置听起来适合低端手机。特别是,176x144 是非智能手机上常用的 QCIF 分辨率。

This does not sound appropriate. My understanding is that iPhone does not stream RTSP rather it supports Apple's HTTP Streaming of segmented files for live and HTTP streaming of MPEG4 video files via range requests. I'd also expect the video to be H.264 and AAC audio.

Your setting sounds appropriate for low-end cellphones In particular, the 176x144 is a QCIF resolution commonly used on non-smartphones.

恋竹姑娘2024-09-04 03:25:20

当您查看调用返回的 XML 文件时,

http://gdata.youtube.com/feeds/api/videos/<your video id>

您会注意到无法在 iPhone 上播放的视频将具有以下标签:

<yt:state name='restricted' reasonCode='limitedSyndication'>Syndication of this video was restricted by its owner.</yt:state>

只需确保查找上述标签,如果存在该标签,则忽略该视频。

When you look at the XML file returned by a call to

http://gdata.youtube.com/feeds/api/videos/<your video id>

then you will notice that videos which are not playable on the iPhone will have the following tag:

<yt:state name='restricted' reasonCode='limitedSyndication'>Syndication of this video was restricted by its owner.</yt:state>

Just make sure to look for the above tag and ignore the video if the tag is present.

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