chromecast - Chromecast 是否支持从 Reddit 转换视频? (HLS 和 Dash 视频)

标签 chromecast google-cast http-live-streaming mpeg-dash google-cast-sdk

使用 URL 调用代理 http://192.168.xx.xx:8080/3hyw7hwoajn21/HLSPlaylist.m3u8
使用 URL 调用代理 http://192.168.xx.xx:8080/3hyw7hwoajn21/HLS_540_v4.m3u8
使用 URL 调用代理 http://192.168.xx.xx:8080/3hyw7hwoajn21/HLS_AUDIO_160_K_v4.m3u8
使用 URL 调用代理 http://192.168.xx.xx:8080/3hyw7hwoajn21/HLS_224_v4.m3u8

以下是 Reddit 视频示例:https://www.reddit.com/r/me_irl/comments/b3vrs4/me_irl

翻阅 the JSON ,它有几个视频源选项:

"reddit_video": {
    "dash_url": "https://v.redd.it/3hyw7hwoajn21/DASHPlaylist.mpd",
    "duration": 76,
    "fallback_url": "https://v.redd.it/3hyw7hwoajn21/DASH_720?source=fallback",
    "height": 720,
    "hls_url": "https://v.redd.it/3hyw7hwoajn21/HLSPlaylist.m3u8",
    "is_gif": false,
    "scrubber_media_url": "https://v.redd.it/3hyw7hwoajn21/DASH_240",
    "transcoding_status": "completed",
    "width": 1280
}

虽然我似乎可以让其他 HLS/m3u8 视频与 Chromecast SDK 一起使用(例如 Google's own example HLS video ),但我似乎无法让这些来源中的任何一个工作。

我试过 https://v.redd.it/3hyw7hwoajn21/HLSPlaylist.m3u8将流类型设置为“live”或“buffered”,我尝试将内容类型设置为“application/x-mpegURL”,我对破折号 URL 尝试了相同的方法 https://v.redd.it/3hyw7hwoajn21/DASHPlaylist.mpd内容类型为“application/dash+xml”也无济于事。我找到了 this question这似乎表明某种可能性?

我还注意到 DASH 文件有一个单独的视频和音频流( https://v.redd.it/3hyw7hwoajn21/DASH_720https://v.redd.it/3hyw7hwoajn21/audio )最坏的情况是有没有办法在 Chromecast 上播放带有单独音频流的视频流?

Chromecast 不能播放这些视频类型吗?

更新

Jesse 和 aergistal 认为这与缺少 CORS header 有关。我构建了一个自定义接收器应用程序,以便能够获得更好的调试日志,这确实是(第一个)问题; Chromecast 提示 CORS。

在我使用 nginx 构建了一个本地反向代理,它添加了所有 CORS header ,然后我给 Chromecast 那个代理 URL,这个 CORS 错误就消失了。

但是,使用 HLS/m3u8 链接它仍然不会流式传输。现在它提示以下内容:

[cast.player.hls.PackedAudioParser] Neither ID3 nor ADTS header was found at 0





[cast.player.api.Host] error: cast.player.api.ErrorCode.NETWORK/315





[cast.receiver.MediaManager] Load metadata error: Error



完整日志:

enter image description here

这导致它仍然无法播放。有任何想法吗?

添加 CORS 问题允许加载 DASHPlaylist.mpd 变体(以前不会),这很好,但同时不是很好,因为反向代理要求您首先下载整个响应,以及 DASH URL 的位置只是一个完整的 MP4(而 HLS 是字节范围)这意味着反向代理必须先下载整个 DASH 视频,然后才能显示它,与 HLS 相比,这需要很长时间。

因此,由于速度的原因,让 HLS 工作仍然是最佳选择,但是由于 Chromecast 上的播放问题,它是否注定无法工作?

最佳答案

结论

最合乎道德的答案是与 Reddit 合作以确保他们设置正确的 CORS header 。 Google 文档中需要 CORS header 。

模拟您的问题

使用此测试仪:

https://developer.jwplayer.com/tools/stream-tester/

它模拟了您在使用 Chromecast SDK 的代码中获得的一些相同体验。谷歌视频在没有 Playready DRM 设置的情况下播放,但 reddit 视频没有(在大多数浏览器中)。

MS EDGE 和 jwplayer

如果您选择 Playready 并为 Playready url 放置任何内容,即使将其留空,它也适用于 M3U8。

Internet Explorer 和 jwplayer

Error, 232011 A manifest request was made without proper crossdomain credentials. Cannot load M3U8: Crossdomain access denied. This video cannot be played because of a technical error.



这表明可能在 reddit 服务器上未启用 CORS。更多关于下面的内容。

Firefox 和 jwplayer

jwplayer 似乎没有任何效果。

Chrome 和 jwplayer

不适用于 jwplayer。

Safari 和 jwplayer 播放器

您表示它无需设置任何 DRM 设置即可工作。

iPhone/Apple TV

我试过了,m3u8 视频可以直接使用 AirPlay 从我的手机转换到 Apple TV (4K)。

仿真总结

所有的 M3U8 视频都可以通过 Airplay 从 iPhone 流式传输到 AppleTV。它似乎在 Edge 和 Safari 中都可以使用,所以它可能只是因为 Reddit 接受了 Apple 流媒体播放服务,而不是 Chromecast。那里不太确定,但还能怎么解释呢?来自某人的更多澄清会很棒。

根本原因分析

请注意,您分享的 google 链接包含以下标题:
Access-Control-Allow-Origin

并且它被设置为 * (aka. all),这意味着服务器将与 Internet 上的任何域共享请求的资源。

https://tools.geekflare.com/report/cors-test/https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/hls/DesigningForGoogleCast.m3u8

reddit 链接没有那个标题,这意味着 CORS 没有被启用以允许资源共享,这意味着它不能正常工作。

CORS header 的说明
https://www.codecademy.com/articles/what-is-cors

The Access-Control-Allow-Origin header allows servers to specify how their resources are shared with external domains. When a GET request is made to access a resource on Server A, Server A will respond with a value for the Access-Control-Allow-Origin header. Many times, this value will be *, meaning that Server A will share the requested resources with any domain on the Internet. Other times, the value of this header may be set to a particular domain (or list of domains), meaning that Server A will share its resources with that specific domain (or list of domains). The Access-Control-Allow-Origin header is critical to resource security.



有几个资源表明必须从服务器端启用 CORS:

https://stackoverflow.com/a/28360045/9105725

https://help.ooyala.com/video-platform/concepts/cors_enablement.html

甚至谷歌也说需要设置这些标题:
https://developers.google.com/cast/docs/chrome_sender/advanced

CORS requirements For adaptive media streaming, Google Cast requires the presence of CORS headers, but even simple mp4 media streams require CORS if they include Tracks. If you want to enable Tracks for any media, you must enable CORS for both your track streams and your media streams. So, if you do not have CORS headers available for your simple mp4 media on your server, and you then add a simple subtitle track, you will not be able to stream your media unless you update your server to include the appropriate CORS header. In addition, you need to allow at least the following headers: Content-Type, Accept-Encoding, and Range. Note that the last two headers are additional headers that you may not have needed previously.

关于chromecast - Chromecast 是否支持从 Reddit 转换视频? (HLS 和 Dash 视频),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55224639/

相关文章:

google-cast - 我可以转换在竖屏上吗?

android - 更改 Chromecast 转换图标颜色

ssl - Chromecast 自签名 SSL 证书

ffmpeg - 构建一个直播页面,用户将通过 ip 地址输入一个 rtsp 流媒体源

encryption - 如何为我的加密子播放列表(使用 ffmpeg 创建)创建主 m3u8 播放列表?

ffmpeg - HLS 不连续性卡在缓冲区中

javascript - 如何实现对 html5 播放器的 chromecast 支持

android - 按住按钮时限速功能

ios - 使用 chrome cast 我可以直接从我的 iPhone 流式传输吗?

google-cast - 找不到 Chromecast 序列号来注册我的设备