sedmelluq / lavaplayer

Audio player library for Discord
Apache License 2.0
958 stars 248 forks source link

YouTube Streams occasionally stop with TrackEndEvent, despite still running on YT #112

Open MCOfficer opened 6 years ago

MCOfficer commented 6 years ago

I've brought this up on discord before, but i wanted to make sure it's "conserved" here in case anyone has the same problem.

I run a Bot that is supposed to play livestreams 24/7. Every few hours, a TrackEndEvent will happen, despite the actual stream on YouTube still being up & running.

This seems to be independant of the stream, or the machine i host on. I couldn't find anything unusual (like a short loss of connection) in the logs either. The only thing all these streams have in common is being hosted on YouTube. The Audiobuffer size doesn't seem to affect the frequency of these events.

Example log:

04:27:41.565 [JDA RateLimit-Queue Pool - Thread 1] DEBUG net.dv8tion.jda.core.requests.Requester - Received response with following cf-rays: [41724f0fded02c3c-AMS]
04:27:42.120 [lava-daemon-pool-playback-1-thread-72] DEBUG com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioTrack - Starting track from URL: https://r4---sn-25ge7nl6.googlevideo.com/videoplayback?ei=_Q3wWoSAJozh8gS-pZngBA&c=WEB&live=1&source=yt_live_broadcast&ms=lv&fexp=23724337&mt=1525681289&mv=u&id=o5_gXqpGoSY.2&requiressl=yes&mm=32&pl=20&mn=sn-25ge7nl6&hang=1&sparams=cmbypass%2Ccompress%2Cei%2Cgcr%2Cgir%2Chang%2Cid%2Cip%2Cipbits%2Citag%2Ckeepalive%2Clive%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cnoclen%2Cpl%2Crequiressl%2Csource%2Cexpire&cmbypass=yes&gcr=us&ipbits=0&expire=1525703261&compress=yes&ip=redacted&mime=audio%2Fmp4&key=yt6&itag=140&signature=834FFE2C375CFF80BA07B37889BEC32466418D34.3A95CB05F967F176E483F13A93163D86683AFD0A&noclen=1&gir=yes&keepalive=yes
04:27:42.573 [lava-daemon-pool-playback-1-thread-72] DEBUG com.sedmelluq.discord.lavaplayer.container.mpeg.MpegAudioTrack - Starting to play track with codec mp4a
04:27:42.574 [lava-daemon-pool-playback-1-thread-72] DEBUG com.sedmelluq.discord.lavaplayer.container.mpeg.MpegAacTrackConsumer - Initialising AAC track with frequency 48000 and channel count 2.
04:41:10.991 [JDA MainWS-ReadThread] DEBUG net.dv8tion.jda.core.handle.EventCache - Received VOICE_STATE_UPDATE for a Member that has yet to be cached. JSON: {"self_deaf":false,"user_id":"413266707449249792","guild_id":"110373943822540800","deaf":false,"session_id":"a7afcd9339cdc277a94dbd50073b977e","mute":false,"suppress":false,"self_video":false,"self_mute":true,"channel_id":null}
05:08:36.616 [lava-daemon-pool-playback-1-thread-72] DEBUG com.sedmelluq.discord.lavaplayer.track.playback.LocalAudioTrackExecutor - Playing track o5_gXqpGoSY finished or was stopped.
05:08:36.616 [JDA AudioConnection Guild: 194794824371535873 Sending Thread] DEBUG com.sedmelluq.discord.lavaplayer.player.AudioPlayer - Firing an event with class TrackEndEvent
05:08:36.841 [JDA RateLimit-Queue Pool - Thread 3] DEBUG net.dv8tion.jda.core.requests.Requester - Received response with following cf-rays: [41728b017e029cb3-AMS]

sedmelluq already fixed an issue with the same symptoms for Twitch streams, but i've been told that YouTube works completely different.

Either way, i wanted to put this out there, in case anyone has an idea.

Edit: after 1 day of testing i can confirm that this still happens with 1.3.10

Bacon1661 commented 6 years ago

I have this same exact issue. YouTube live streams have always been super finicky for me; Often having long pauses where it seems it's buffering or something and I don't get this with anything else. An hour ago I had this REALLY strange occurrence where the live stream paused for five seconds and started spam adding the live stream (Which this has never ever happened before) and spat out this error:

[22:13:51] [ ERROR] [LocalAudioTrackExecutor] Error in playback of LsBrT6vbQa8
com.sedmelluq.discord.lavaplayer.tools.FriendlyException: Something went wrong when decoding the track.
        at com.sedmelluq.discord.lavaplayer.tools.ExceptionTools.wrapUnfriendlyExceptions(ExceptionTools.java:40)
        at com.sedmelluq.discord.lavaplayer.track.playback.LocalAudioTrackExecutor.executeProcessingLoop(LocalAudioTrackExecutor.java:260)
        at com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeMpegStreamAudioTrack.process(YoutubeMpegStreamAudioTrack.java:53)
        at com.sedmelluq.discord.lavaplayer.track.DelegatedAudioTrack.processDelegate(DelegatedAudioTrack.java:27)
        at com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioTrack.processStream(YoutubeAudioTrack.java:87)
        at com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioTrack.process(YoutubeAudioTrack.java:65)
        at com.sedmelluq.discord.lavaplayer.track.playback.LocalAudioTrackExecutor.execute(LocalAudioTrackExecutor.java:90)
        at com.sedmelluq.discord.lavaplayer.player.DefaultAudioPlayerManager.lambda$executeTrack$1(DefaultAudioPlayerManager.java:357)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: Not success status code: 204
        at com.sedmelluq.discord.lavaplayer.tools.io.PersistentHttpStream.validateStatusCode(PersistentHttpStream.java:80)
        at com.sedmelluq.discord.lavaplayer.tools.io.PersistentHttpStream.attemptConnect(PersistentHttpStream.java:109)
        at com.sedmelluq.discord.lavaplayer.tools.io.PersistentHttpStream.connect(PersistentHttpStream.java:98)
        at com.sedmelluq.discord.lavaplayer.tools.io.PersistentHttpStream.internalRead(PersistentHttpStream.java:141)
        at com.sedmelluq.discord.lavaplayer.tools.io.PersistentHttpStream.internalRead(PersistentHttpStream.java:151)
        at com.sedmelluq.discord.lavaplayer.tools.io.PersistentHttpStream.read(PersistentHttpStream.java:157)
        at com.sedmelluq.discord.lavaplayer.container.mpeg.reader.MpegReader.tryReadInt(MpegReader.java:133)
        at com.sedmelluq.discord.lavaplayer.container.mpeg.reader.MpegReader.nextChild(MpegReader.java:53)
        at com.sedmelluq.discord.lavaplayer.container.mpeg.reader.fragmented.MpegFragmentedFileTrackProvider.provideFrames(MpegFragmentedFileTrackProvider.java:53)
        at com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeMpegStreamAudioTrack.processSegmentStream(YoutubeMpegStreamAudioTrack.java:110)
        at com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeMpegStreamAudioTrack.processNextSegment(YoutubeMpegStreamAudioTrack.java:87)
        at com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeMpegStreamAudioTrack.execute(YoutubeMpegStreamAudioTrack.java:63)
        at com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeMpegStreamAudioTrack.lambda$process$0(YoutubeMpegStreamAudioTrack.java:54)
        at com.sedmelluq.discord.lavaplayer.track.playback.LocalAudioTrackExecutor.executeProcessingLoop(LocalAudioTrackExecutor.java:248)
        ... 9 common frames omitted
shikhir-arora commented 6 years ago

Using the above livestream as an example, here's a verbose dump of the MPEG-DASH manifest using youtube-dl: https://gist.github.com/shikhir-arora/900a3fd4fb90943beeec3dcf36ba1a10

All show an expiration of 1526203888, which 05/13/2018 @ 9:31am (UTC) (about 6 hours from now).

MCOfficer commented 6 years ago

roughly two hours later, and the expiration has been updated to 1526211794 (11:43am). apparently youtube always keeps the expiration 6 hours ahead. good idea, i'm not sure if lavaplayer checks for that or just takes the inital expiration.

(full dump: https://gist.github.com/MCOfficer/4f7d42869af6b1a1f5d8e1d5e078fa0a, thank windows for the missing line endings)

shikhir-arora commented 6 years ago

Here's the last bit of output from ffmpeg (before I force-quit); this is using verbose mode on the same stream. I let it run for a while. https://gist.github.com/shikhir-arora/5edee567fcab79cd26c29e28c1459fb8#file-ffmpeg_out-sh-L55 At line 55 there, ffmpeg did have an error in the pull function (notice a few messages before that it also seems to handle repeating messages).

screen shot 2018-05-13 at 2 53 08 am

However, it resumed back as usual as shown.

Bacon1661 commented 6 years ago

So apparently this is an issue with the live stream itself. I was playing the live stream on my bot while playing it in my browser and the live stream on both my bot and the website stopped. They even mention in chat they're having problems with their live stream. capture

When the live stream is at fault I get this error:

[11:04:43] [ WARN ] [EventEmitter] lofi hip hop radio 24/7 ? chill study / relax / gaming beats got stuck! Threshold surpassed: 10000
Bacon1661 commented 6 years ago

Hmm, I tried a different stream and I'm still having live streams end prematurely even though it's continuing to play in YouTube. I even got a new error:

[11:55:10] [ ERROR] [LocalAudioTrackExecutor] Error in playback of ilxhlnDo7_M
com.sedmelluq.discord.lavaplayer.tools.FriendlyException: Something went wrong when decoding the track.
        at com.sedmelluq.discord.lavaplayer.tools.ExceptionTools.wrapUnfriendlyExceptions(ExceptionTools.java:40)
        at com.sedmelluq.discord.lavaplayer.track.playback.LocalAudioTrackExecutor.executeProcessingLoop(LocalAudioTrackExecutor.java:260)
        at com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeMpegStreamAudioTrack.process(YoutubeMpegStreamAudioTrack.java:53)
        at com.sedmelluq.discord.lavaplayer.track.DelegatedAudioTrack.processDelegate(DelegatedAudioTrack.java:27)
        at com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioTrack.processStream(YoutubeAudioTrack.java:87)
        at com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioTrack.process(YoutubeAudioTrack.java:65)
        at com.sedmelluq.discord.lavaplayer.track.playback.LocalAudioTrackExecutor.execute(LocalAudioTrackExecutor.java:90)
        at com.sedmelluq.discord.lavaplayer.player.DefaultAudioPlayerManager.lambda$executeTrack$1(DefaultAudioPlayerManager.java:357)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: org.apache.http.ConnectionClosedException: Premature end of chunk coded message body: closing chunk expected
        at com.sedmelluq.discord.lavaplayer.container.mpeg.reader.MpegReader.nextChild(MpegReader.java:62)
        at com.sedmelluq.discord.lavaplayer.container.mpeg.reader.fragmented.MpegFragmentedFileTrackProvider.provideFrames(MpegFragmentedFileTrackProvider.java:53)
        at com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeMpegStreamAudioTrack.processSegmentStream(YoutubeMpegStreamAudioTrack.java:110)
        at com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeMpegStreamAudioTrack.processNextSegment(YoutubeMpegStreamAudioTrack.java:87)
        at com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeMpegStreamAudioTrack.execute(YoutubeMpegStreamAudioTrack.java:63)
        at com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeMpegStreamAudioTrack.lambda$process$0(YoutubeMpegStreamAudioTrack.java:54)
        at com.sedmelluq.discord.lavaplayer.track.playback.LocalAudioTrackExecutor.executeProcessingLoop(LocalAudioTrackExecutor.java:248)
        ... 9 common frames omitted
Caused by: org.apache.http.ConnectionClosedException: Premature end of chunk coded message body: closing chunk expected
        at org.apache.http.impl.io.ChunkedInputStream.getChunkSize(ChunkedInputStream.java:266)
        at org.apache.http.impl.io.ChunkedInputStream.nextChunk(ChunkedInputStream.java:225)
        at org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:184)
        at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:135)
        at java.util.zip.InflaterInputStream.fill(Unknown Source)
        at java.util.zip.InflaterInputStream.read(Unknown Source)
        at java.util.zip.GZIPInputStream.read(Unknown Source)
        at org.apache.http.client.entity.LazyDecompressingInputStream.read(LazyDecompressingInputStream.java:70)
        at java.io.BufferedInputStream.fill(Unknown Source)
        at java.io.BufferedInputStream.read(Unknown Source)
        at com.sedmelluq.discord.lavaplayer.tools.io.PersistentHttpStream.internalRead(PersistentHttpStream.java:144)
        at com.sedmelluq.discord.lavaplayer.tools.io.PersistentHttpStream.read(PersistentHttpStream.java:157)
        at com.sedmelluq.discord.lavaplayer.container.mpeg.reader.MpegReader.tryReadInt(MpegReader.java:133)
        at com.sedmelluq.discord.lavaplayer.container.mpeg.reader.MpegReader.nextChild(MpegReader.java:53)
        ... 15 common frames omitted
MCOfficer commented 6 years ago

respectfully, to me it seems like you are having a different issue. youtube streams seem to be causing problems in general

Bacon1661 commented 6 years ago

I have the same issue, but I also have a lot of additional issues lol.

MCOfficer commented 6 years ago

there's a massive difference between randomly ending the track without exception and failing to decode it, so unless i'm wrong by a mile you're hijacking this issue.

Bacon1661 commented 6 years ago

That's not what I'm intending to do at all, and I'm sorry if I conveyed that. I still have the original issue you mentioned, I'm just reporting additional issues.

MisterFixx commented 5 years ago

Can confirm i'm having the same issue. This is the livestream: https://youtu.be/HU1_KTNSj7k The stream just randomly stops constantly.

SoulSen commented 5 years ago

Any update on fixes for this, or is it still being experienced?