AVPlayer不在HLS视频流中播放音频

时间:2018-03-27 14:51:29

标签: ios avplayer hls shaka

我创建了HLS清单&带有shaka packager的碎片mp4段。清单在ios和Web Safari浏览器中本身可以正常播放。但是,当馈送到AVPlayer时,它只播放视频而不播放音频。

mediastreamvalidator工具验证了流,但没有显示任何错误。

hls_manifest.m3u8

#EXTM3U
## Generated with https://github.com/google/shaka-packager version 2d025da-release
#EXT-X-MEDIA:TYPE=AUDIO,URI="hls_manifest_a.m3u8",GROUP-ID="audio",LANGUAGE="en",NAME="ENGLISH",CHANNELS="2"
#EXT-X-STREAM-INF:BANDWIDTH=3264562,CODECS="avc1.42c01e,mp4a.40.2",RESOLUTION=1280x720,AUDIO="audio"
hls_manifest_v.m3u8

hls_manifest_a.m3u8

#EXTM3U
#EXT-X-VERSION:6
## Generated with https://github.com/google/shaka-packager version 2d025da-release
#EXT-X-TARGETDURATION:7
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-MAP:URI="a/seg_0.mp4"
#EXTINF:5.016,
a/seg_1.m4s
#EXTINF:4.992,
a/seg_2.m4s
#EXTINF:4.992,
a/seg_3.m4s
#EXTINF:5.016,
a/seg_4.m4s
#EXTINF:0.697,
a/seg_5.m4s
#EXT-X-ENDLIST

hls_manifest_v.m3u8

#EXTM3U
#EXT-X-VERSION:6
## Generated with https://github.com/google/shaka-packager version 2d025da-release
#EXT-X-TARGETDURATION:7
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-MAP:URI="v/seg_0.mp4"
#EXTINF:6.208,
v/seg_1.m4s
#EXTINF:4.333,
v/seg_2.m4s
#EXTINF:6.750,
v/seg_3.m4s
#EXTINF:3.375,
v/seg_4.m4s
#EXT-X-ENDLIST

我缺少什么?

1 个答案:

答案 0 :(得分:1)

在这里,我正在回答我自己的问题。出现此问题是因为Shaka Packager(生成HLS段的工具)没有将AUTOSELECT = Yes选项添加到master .m3u8文件中的音轨。因此,AVPlayer在播放视频文件时跳过了音轨。这已在里程碑v2.0中修复