Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stream ends at the minute mark #7

Open
noelhibbard opened this issue Mar 15, 2021 · 2 comments
Open

Stream ends at the minute mark #7

noelhibbard opened this issue Mar 15, 2021 · 2 comments

Comments

@noelhibbard
Copy link

With my iPhone the stream makes it past the minute mark but with VLC on my desktop it ends at the minute mark. I added the camera in Shinobi but when I view it in the monitor it also ends at the minute mark and then I have to hit reconnect to get another minute. What am I missing here?

@noelhibbard
Copy link
Author

So I added some debug to dump the pls that gets served up when the HLS player tries to refresh the playlist and here are the last few refreshes before playback stops and it no longer refreshes the playlist. It looks like it has one very short segment that rotates out and then it jumps from seq 30 to 32 and then Shinobi (and VLS) give up and stop refreshing. iOS seems unaffected by this though.

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-ALLOW-CACHE:NO
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:25
#EXTINF:2.00000,
/frontporch/latest42430002141025.ts
#EXTINF:2.00000,
/frontporch/latest42430002141026.ts
--------------
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-ALLOW-CACHE:NO
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:26
#EXTINF:2.00000,
/frontporch/latest42430002141026.ts
#EXTINF:2.00000,
/frontporch/latest42430002141027.ts
--------------
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-ALLOW-CACHE:NO
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:27
#EXTINF:2.00000,
/frontporch/latest42430002141027.ts
#EXTINF:2.00000,
/frontporch/latest42430002141028.ts
--------------
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-ALLOW-CACHE:NO
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:28
#EXTINF:2.00000,
/frontporch/latest42430002141028.ts
#EXTINF:2.00000,
/frontporch/latest42430002141029.ts
--------------
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-ALLOW-CACHE:NO
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:29
#EXTINF:2.00000,
/frontporch/latest42430002141029.ts
#EXTINF:0.05000,
/frontporch/latest42430002141030.ts
--------------
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-ALLOW-CACHE:NO
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:29
#EXTINF:2.00000,
/frontporch/latest42430002141029.ts
#EXTINF:0.05000,
/frontporch/latest42430002141030.ts
--------------
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-ALLOW-CACHE:NO
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:30
#EXTINF:0.05000,
/frontporch/latest42430002141030.ts
#EXTINF:2.00000,
/frontporch/latest4320002142000.ts
--------------
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-ALLOW-CACHE:NO
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:32
#EXTINF:2.00000,
/frontporch/latest4320002142001.ts
#EXTINF:2.00000,
/frontporch/latest4320002142002.ts

@noelhibbard
Copy link
Author

Problem solved! My code is a big mess right now but I will clone a new copy of your repo and then do a proper fix and submit a pull request. In a nutshell, if the last segment of the minute is less than 2 secs it breaks the stream. To fix this you simply check the duration of the previous segment and if it was less than expected then you inset the "#EXT-X-DISCONTINUITY" tag just before inserting the next segment. So for example you would have a playlist that looks like this:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-ALLOW-CACHE:NO
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:29
#EXTINF:2.00000,
/frontporch/latest1470001700029.ts
#EXTINF:0.05000,
/frontporch/latest1470001700030.ts
#EXT-X-DISCONTINUITY
#EXTINF:2.00000,
/frontporch/latest250001701000.ts

I also got audio working by adding -c:a aac to the ffmpeg command line. I made a few other command line changes but now that I found the real fix I'm not sure any of them are actually needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant