在 ExoPlayer 中接收带有 H264 帧/NAL 单元的 RTP/UDP
我的 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 做错了什么?
免责声明:这不是 RTExtractor
...)
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据 THIS 问题 - 目前 ExoPlayer 不支持侧载和播放 SDP 文件,遗憾的是...
according to THIS issue - currently ExoPlayer doesn't support sideloading and playing SDP file, sadly...