在 ExoPlayer 中接收带有 H264 帧/NAL 单元的 RTP/UDP

发布于 2025-01-16 03:54:03 字数 2314 浏览 2 评论 0原文

我的 SDP 如下所示(IP 和端口可能会更改),仅视频,包含 SPS/PPS 和配置文件/级别(真实的,不是硬编码的)

v=0
o=- 0 0 IN IP4 null
s=Unnamed
i=N/A
c=IN IP4 192.168.18.26
t=0 0
a=recvonly
m=video 5006 RTP/AVP 96
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1;profile-level-id=42c029;sprop-parameter-sets=Z0LAKY1oB4AiflgHhEI1,aM4BqDXI;
a=control:trackID=1

我的 ExoPlayer 实现是最新的

implementation 'com.google.android.exoplayer:exoplayer-core:2.17.1'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.17.1'
implementation 'com.google.android.exoplayer:exoplayer-rtsp:2.17.1'

加载上面的 SDP

        Uri uri = Uri.fromFile(file);
        exoPlayer.setMediaItem(MediaItem.fromUri(uri));
        exoPlayer.prepare();
        exoPlayer.setPlayWhenReady(true);

我正在尝试使用此代码 给我

ExoPlayerImplInternal: Playback error
  com.google.android.exoplayer2.ExoPlaybackException: Source error
    at com.google.android.exoplayer2.ExoPlayerImplInternal.handleIoException(ExoPlayerImplInternal.java:641)
    at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:611)
    at android.os.Handler.dispatchMessage(Handler.java:103)
    at android.os.Looper.loop(Looper.java:214)
    at android.os.HandlerThread.run(HandlerThread.java:67)
 Caused by: com.google.android.exoplayer2.source.UnrecognizedInputFormatException: None of the available extractors (FlvExtractor, FlacExtractor, WavExtractor, FragmentedMp4Extractor, Mp4Extractor, AmrExtractor, PsExtractor, OggExtractor, TsExtractor, MatroskaExtractor, AdtsExtractor, Ac3Extractor, Ac4Extractor, Mp3Extractor, JpegExtractor) could read the stream.
    at com.google.android.exoplayer2.source.BundledExtractorsAdapter.init(BundledExtractorsAdapter.java:92)
    at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1020)
....

这个SDP可以通过桌面上的VLC(常见的播放器Windows和Linux,以及.NET lib实现)或移动设备(使用Android的官方LibVLC实现)打开。 我对 ExoPlayer 做错了什么?

免责声明:这不是 RTP。只是将纯 RTP 与原始 NAL 单元推送到某个 ip:port 上。根据文档 ExoPlayer 应该支持 RTP/UDP 和 H264 (但我没有看到任何Extractor...)

My SDP looks like below (IP and port may change ofc), video only, contains SPS/PPS and profile/level (real ones, not hardcoded)

v=0
o=- 0 0 IN IP4 null
s=Unnamed
i=N/A
c=IN IP4 192.168.18.26
t=0 0
a=recvonly
m=video 5006 RTP/AVP 96
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1;profile-level-id=42c029;sprop-parameter-sets=Z0LAKY1oB4AiflgHhEI1,aM4BqDXI;
a=control:trackID=1

My ExoPlayer implementation is current

implementation 'com.google.android.exoplayer:exoplayer-core:2.17.1'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.17.1'
implementation 'com.google.android.exoplayer:exoplayer-rtsp:2.17.1'

And I'm trying to load above SDP using this code

        Uri uri = Uri.fromFile(file);
        exoPlayer.setMediaItem(MediaItem.fromUri(uri));
        exoPlayer.prepare();
        exoPlayer.setPlayWhenReady(true);

which gives me

ExoPlayerImplInternal: Playback error
  com.google.android.exoplayer2.ExoPlaybackException: Source error
    at com.google.android.exoplayer2.ExoPlayerImplInternal.handleIoException(ExoPlayerImplInternal.java:641)
    at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:611)
    at android.os.Handler.dispatchMessage(Handler.java:103)
    at android.os.Looper.loop(Looper.java:214)
    at android.os.HandlerThread.run(HandlerThread.java:67)
 Caused by: com.google.android.exoplayer2.source.UnrecognizedInputFormatException: None of the available extractors (FlvExtractor, FlacExtractor, WavExtractor, FragmentedMp4Extractor, Mp4Extractor, AmrExtractor, PsExtractor, OggExtractor, TsExtractor, MatroskaExtractor, AdtsExtractor, Ac3Extractor, Ac4Extractor, Mp3Extractor, JpegExtractor) could read the stream.
    at com.google.android.exoplayer2.source.BundledExtractorsAdapter.init(BundledExtractorsAdapter.java:92)
    at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1020)
....

This SDP can be opened by VLC on desktop (common player Windows and Linux, and .NET lib implementation) or mobile (using official LibVLC implementation for Android). What I'm doing wrong with ExoPlayer?

Disclaimer: thats not RT<any_letter>P. Just pure RTP with raw NAL units pushed on some ip:port. According to doc ExoPlayer should support RTP/UDP and H264 (but I'm not seeing any Extractor...)

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

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

发布评论

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

评论(1

一刻暧昧 2025-01-23 03:54:03

根据 THIS 问题 - 目前 ExoPlayer 不支持侧载和播放 SDP 文件,遗憾的是...

according to THIS issue - currently ExoPlayer doesn't support sideloading and playing SDP file, sadly...

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