简体   繁体   中英

AVPlayer is not playing audio in a HLS video stream

I have created HLS manifest & fragmented mp4 segments with shaka packager. The manifest plays fine in ios and web Safari browser natively. But, when fed to AVPlayer it only plays the video and not the audio.

The mediastreamvalidator tool has validated the stream and did not show any error.

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

What am i missing?

Here, i am answering my own question. This issue happened because Shaka Packager (tool to generate HLS segments), did not add the AUTOSELECT=Yes option to the audio track in master .m3u8 file. So, AVPlayer skipped the audio track when playing the video file. This was fixed in the milestone v2.0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM