在 ExoPlayer 中以 H264 frames/NAL 单位接收 RTP/UDP
Receive RTP/UDP with H264 frames/NAL units in ExoPlayer
我的 SDP 如下所示(IP 和端口可能会更改),仅视频,包含 SPS/PPS 和 profile/level(真实的,未硬编码)
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 可以在桌面(普通播放器 Windows 和 Linux,以及 .NET lib 实现)或移动设备(使用 Android 的官方 LibVLC 实现)上通过 VLC 打开。 我在使用 ExoPlayer 时做错了什么?
免责声明:那不是 RTP。只是带有原始 NAL 单元的纯 RTP 推送到一些 ip:port。根据文档 ExoPlayer 应该支持 RTP/UDP 和 H264(但我没有看到任何 Extractor
...)
根据 THIS 问题 - 目前 ExoPlayer 不支持侧载和播放 SDP 文件,遗憾的是...
我的 SDP 如下所示(IP 和端口可能会更改),仅视频,包含 SPS/PPS 和 profile/level(真实的,未硬编码)
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 可以在桌面(普通播放器 Windows 和 Linux,以及 .NET lib 实现)或移动设备(使用 Android 的官方 LibVLC 实现)上通过 VLC 打开。 我在使用 ExoPlayer 时做错了什么?
免责声明:那不是 RTExtractor
...)
根据 THIS 问题 - 目前 ExoPlayer 不支持侧载和播放 SDP 文件,遗憾的是...