首页 > 解决方案 > 用于提取 Representation 标签属性的 DashManifest 解析器

问题描述

我试图通过引用https://github.com/google/ExoPlayer/issues/8577width="3200"中的示例代码来提取和height="180"提取。但是,对于'image/jpeg'却没有成功。<Representation>

清单(https://dash.akamaized.net/akamai/bbb_30fps/bbb_with_tiled_thumbnails.mpd):

<AdaptationSet id="3" mimeType="image/jpeg" contentType="image">
    <SegmentTemplate media="$RepresentationID$/tile_$Number$.jpg" duration="100" startNumber="1"/>
    <Representation bandwidth="12288" id="thumbnails_320x180" width="3200" height="180">
      <EssentialProperty schemeIdUri="http://dashif.org/thumbnail_tile" value="10x1"/>
    </Representation>
  </AdaptationSet>

我为“图像/JPEG”尝试的代码:

if("image/jpeg".equals(mimeType)){
  Representation.MultiSegmentRepresentation multiSegmentRepresentation = (Representation.MultiSegmentRepresentation) representation;
  Log.d("format.width" , String.valueOf(multiSegmentRepresentation.format.width));
  for(int l = 1; l < multiSegmentRepresentation.getSegmentCount(periodDurationUs); l++) {
    Log.d("sprite_uri" , String.valueOf(multiSegmentRepresentation.getSegmentUrl(l).resolveUri(representation.baseUrls.get(0).url)));
  }
  return;
}

“图像/JPEG”的结果:

2021-09-28 17:34:23.146 25820-25820/com.example.exoplayerdemo D/format.width: -1
2021-09-28 17:34:23.146 25820-25820/com.example.exoplayerdemo D/sprite_uri: https://dash.akamaized.net/akamai/bbb_30fps/thumbnails_320x180/tile_1.jpg
2021-09-28 17:34:23.147 25820-25820/com.example.exoplayerdemo D/sprite_uri: https://dash.akamaized.net/akamai/bbb_30fps/thumbnails_320x180/tile_2.jpg
2021-09-28 17:34:23.147 25820-25820/com.example.exoplayerdemo D/sprite_uri: https://dash.akamaized.net/akamai/bbb_30fps/thumbnails_320x180/tile_3.jpg
2021-09-28 17:34:23.147 25820-25820/com.example.exoplayerdemo D/sprite_uri: https://dash.akamaized.net/akamai/bbb_30fps/thumbnails_320x180/tile_4.jpg
2021-09-28 17:34:23.147 25820-25820/com.example.exoplayerdemo D/sprite_uri: https://dash.akamaized.net/akamai/bbb_30fps/thumbnails_320x180/tile_5.jpg
2021-09-28 17:34:23.149 25820-25820/com.example.exoplayerdemo D/sprite_uri: https://dash.akamaized.net/akamai/bbb_30fps/thumbnails_320x180/tile_6.jpg

我为“视频/mp4”尝试的代码:

if("video/mp4".equals(mimeType)){
  Representation.MultiSegmentRepresentation multiSegmentRepresentation = (Representation.MultiSegmentRepresentation) representation;
  Log.d("format.width" , String.valueOf(multiSegmentRepresentation.format.width));
  Log.d("format.height" , String.valueOf(multiSegmentRepresentation.format.height));
  for(int l = 1; l < multiSegmentRepresentation.getSegmentCount(periodDurationUs); l++){}
  return;
}

“视频/mp4”的结果:

2021-09-28 17:52:07.574 23252-23252/com.example.exoplayerdemo D/format.width: 1024
2021-09-28 17:52:07.574 23252-23252/com.example.exoplayerdemo D/format.height: 576

它适用于“视频/mp4”。“图像/JPEG”的任何解决方案?

标签: javaandroidxmlxml-parsingexoplayer

解决方案


推荐阅读