HTML5 audio tag - Handling of m3u8 in chrome/firefox

橙三吉。 提交于 2021-01-29 01:41:55

问题


I'm facing issues with m3u8 playlists on chrome and firefox (edge works like a charm)

I'm trying to send data converted with ffmpeg the line I use for conversion is the following making the m3u8 file at same time:

ffmpeg -i .\european-anthem-2012.mp3 -c:a aac -b:a 64k -f segment -segment_time 15 -segment_time_delta 3 -segment_list_type m3u8 -segment_list playlist_aac.m3u8 outfile_aac-%03d.aac

As destination formats I've tried also mp3: -c:a mp3 -b:a 64k and vorbis: -c:a libvorbis -b:a 64k

the m3u8 file looks like this:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOW-CACHE:YES
#EXT-X-TARGETDURATION:16
#EXTINF:12.004717,
outfile_aac-000.aac
#EXTINF:15.000091,
outfile_aac-001.aac
#EXTINF:15.000091,
outfile_aac-002.aac
#EXTINF:15.000091,
outfile_aac-003.aac
#EXTINF:15.000091,
outfile_aac-004.aac
#EXTINF:15.000091,
outfile_aac-005.aac
#EXTINF:15.000091,
outfile_aac-006.aac
#EXTINF:15.000091,
outfile_aac-007.aac
#EXTINF:10.495420,
outfile_aac-008.aac
#EXT-X-ENDLIST

the file I use is this: EU Anathem

The HTML I use is this:

<html>
<audio  id="track2" 
        src="playlist_aac.m3u8" 
        type="audio/x-mpegurl"
        >

    <p>Your browser does not support the audio element</p>

</audio>
<button onclick="document.getElementById('track2').play();">Play</button>

</html>

the files (audio pieces, playlist and html) used are in the same local folder as the html page

When I run this code on edge (double clicking the HTML) everything works on chrome as soon as I click the button the console logs audiotag.html:61 Uncaught (in promise) DOMException: The element has no supported sources

On Firefox the error is this: NotSupportedError: The media resource indicated by the src attribute or assigned media provider object was not suitable.

(Expected behavior is file playing)

来源:https://stackoverflow.com/questions/59666681/html5-audio-tag-handling-of-m3u8-in-chrome-firefox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!