'Combining audio and video streams in m3u8 playlist, audio stops working
I need to combine separate audio and video streams into one playlist. I did it, but I have a problem. After a random time, the audio stops playing, or very rarely, the audio is OK, but freezes the video. Audio and video sources are links to a third-party server, and when I test the sources separately, everything works fine.
Here are my playlist files:
audio.m3u8
#EXTM3U
#EXTINF:190,audio
https://third-party-server.com/audio-url
#EXT-X-ENDLIST
video.m3u8
#EXTM3U
#EXTINF:190,video
https://third-party-server.com/video-url
#EXT-X-ENDLIST
main.m3u8
#EXTM3U
#EXT-X-VERSION:5
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",NAME="merge",DEFAULT=YES,AUTOSELECT=YES,URI="audio.m3u8"
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=646043,CODECS="opus,avc1.4d401e,mp4a.40.2",RESOLUTION=640x360,AUDIO="audio"
video.m3u8
#EXT-X-ENDLIST
Information about the sources:
audio: bitrate: 144209, audioSampleRate: 48000, codecs: "opus",
video: resolution: 640x360, bitrate: 646043, codecs: "avc1.4d401e",
Both sources have the same duration: 190 seconds
I experimented a lot. I used sources with other qualities (the server allows you to get many formats), I changed "BANDWIDTH", tried other codecs. But nothing helped, my audio still stops working. Also, when I test one source, I can use rewind, but the combined playlist stops working when I try to rewind.
It all looks like a buffering problems, but I haven't found a way how to configure this in m3u8.
I will be glad to hear your advice.
Solution 1:[1]
TL;DR You're missing the tag #EXT-X-TARGETDURATION:190
in the audio and video playlists. I'm not sure if this would fix your issue, but it fixed mine. See below for more info.
Long answer
Although this question is more than 2 years old, I was trying to do the same thing. I downloaded Apple's HLS Tools and used their validator tool and kept getting the error Error: Max extinf duration of 1746 more than 2 * target duration 0
. I didn't know what to do with that error message, so I got video file and ran the mediafilesegmenter
which splits the video file into smaller files and generates a m3u8 playlist.
I saw that the new playlist had the #EXT-X-TARGETDURATION
tag and I figured I'd try it and it worked.
Hopefully that helps anyone else having issues with this.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | derickito |