MPEG-TS H.264与ExoPlayer

5

我有两个mpeg-ts + h.264视频文件,我尝试在一台安卓设备(三星平板电脑A 10.1寸)上使用ExoPlayer进行读取:

SimpleExoPlayerView view = new SimpleExoPlayerView(this);
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveVideoTrackSelection.Factory(new DefaultBandwidthMeter());
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
SimpleExoPlayer mediaPlayer = ExoPlayerFactory.newSimpleInstance(this, trackSelector, new DefaultLoadControl());
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this, Util.getUserAgent(this, getString(R.string.app_name)));
ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
MediaSource source = new ExtractorMediaSource(uri, dataSourceFactory, extractorsFactory, null, null);
view.setPlayer(mediaPlayer);
mediaPlayer.setPlayWhenReady(true);
mediaPlayer.prepare(source);

第一个视频成功了(图像正确显示),但第二个失败了(没有图像显示),尽管它们在视频特性方面非常相似。我想知道为什么。

我使用mediainfo提取视频编码细节。

第一个视频(成功):

General
ID                                       : 0 (0x0)
Complete name                            : 1080i.ts
Format                                   : MPEG-TS
File size                                : 56.7 MiB
Duration                                 : 47s 456ms
Overall bit rate mode                    : Constant
Overall bit rate                         : 10.0 Mbps

Video
ID                                       : 256 (0x100)
Menu ID                                  : 1 (0x1)
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L4.0
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 2 frames
Codec ID                                 : 27
Duration                                 : 47s 282ms
Bit rate                                 : 9 185 Kbps
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Frame rate                               : 29.970 fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : MBAFF
Bits/(Pixel*Frame)                       : 0.148
Stream size                              : 51.8 MiB (91%)

第二个视频(失败):
General
ID                                       : 1 (0x1)
Complete name                            : fr5.ts
Format                                   : MPEG-TS
File size                                : 13.8 MiB
Duration                                 : 32s 270ms
Overall bit rate mode                    : Variable
Overall bit rate                         : 3 557 Kbps

Video
ID                                       : 420 (0x1A4)
Menu ID                                  : 1045 (0x415)
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L4.0
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 4 frames
Codec ID                                 : 27
Duration                                 : 31s 760ms
Bit rate                                 : 3 252 Kbps
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Frame rate                               : 25.000 fps
Standard                                 : Component
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : MBAFF
Bits/(Pixel*Frame)                       : 0.063
Stream size                              : 12.3 MiB (89%)
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709

这两个流之间唯一的区别是所支持的参考帧数量。这很不可能成为问题,因为播放器将拥有通用解码器,但仍然可以通过尝试仅使用2个参考帧的其他序列来检查。 - prashanthns
1个回答

1
突出的两个文件之间的区别在于比特率。工作正常的文件具有更高的比特率,并且它是恒定的,而损坏的文件具有相同的高分辨率,但比特率较低且不稳定。仅凭所提供的统计数据,我会怀疑编码视频所使用的工具。也许配置方面的某些问题导致编码器输出黑帧。您是否尝试在其他设备上使用相同的文件?您能否使用稍微不同的设置重新编码?

我尝试在几个不同的设备上运行程序,但结果总是相同的。第一个文件是我在网上找到的样本文件。第二个文件来自 IPTV 流(我无法配置任何内容),我的最终目标是能够读取该第二个流。 - sdabet
你在日志中看到任何错误吗?这些错误可能会指示出这是什么类型的错误。如果你播放的是你没有拥有的流媒体,那可能是受到数字版权管理(DRM)保护的。 - Jschools

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接