I can't seem to load live YouTube videos. Other videos all work but live streams just fail instantly but doesn't throw any errors. I can fetch info but not load the stream.
Same issue here, however in my case the stream will play for about 5 seconds and then will stop. After outputting the audio to a file instead of a Discord voice channel I also found that it stopped outputting after 5 seconds. (I'm on the latest version - v0.29.0)
Also seeing this. having some other strange issues with resolved urls as well (even non livestreams) (fixed) More info later as I get it @fent
Same issue here. It's strange. When we play the music, then the bot is joined. Playing the music, then 5 seconds just stop without any error.
Same. Normal(non livestream) links play for about 1 minute or so, and end. Livestreams don't even start to play. That's when using .playStream with discord.js. However when outputting audio stream into a file with fs, it outputs correctly, and you can hear whole stream. Strange. I'm on latest version, there are also no errors in console whatsoever.
Reopening because of #407 claiming this issue is still apparent.
So there are no errors but here is what's happening
Update: Sometimes it plays for about 10-30 seconds becomes very glitchy and stops streaming
Im having the same issue
I also use ytdl-core to play YouTube videos on a Discord Bot, I'm using Eris lib.
So, before I was doing something like this:
// info is a youtube video info gotten from ytdl.getInfo()
const stream = () => ytdl.downloadFromInfo(info, { filter: 'audioonly' });
connection.play(stream());
With this setup, I noticed through stream().on("info", (info, format) => { console.log(format) }) that the format itag ytdl was picking was 140. This is not a livestream itag, so this will likely be a small audio file with just a few seconds, which is proven by how the Discord bot proceeded to play the livestream for just a few seconds, much like @MayorChano demonstrated in this video.
Then, I changed to something like this:
const stream = () => ytdl.downloadFromInfo(info, info.livestream ? { quality: [128,127,120,96,95,94,93] } : { filter: 'audioonly' });
connection.play(stream());
With this I check if the video is a livestream and if so I make ytdl pick a format itag from [128,127,120,96,95,94,93] which are a few livestream "compatible" itags. This time ytdl picked the format with itag 94. Unfortunately, the bot did not play the livestream at all, not even a few seconds, it stopped immediately. Then I got the url of this format (again through .on("info")) which was
https://manifest.googlevideo.com/api/manifest/hls_playlist/expire/1557566613/ei/NUDWXPnmJ8OAhAfGuYSgBw/ip/188.37.241.72/id/OkwonUHvJf4.0/itag/94/source/yt_live_broadcast/requiressl/yes/ratebypass/yes/live/1/cmbypass/yes/goi/160/sgoap/gir%3Dyes%3Bitag%3D140/sgovp/gir%3Dyes%3Bitag%3D135/hls_chunk_host/r1---sn-8vq54vox2u-v2ve.googlevideo.com/gcr/pt/playlist_type/LIVE/initcwndbps/9900/mm/32/mn/sn-8vq54vox2u-v2ve/ms/lv/mv/m/pl/18/dover/11/keepalive/yes/mt/1557544941/sparams/expire,ei,ip,id,itag,source,requiressl,ratebypass,live,cmbypass,goi,sgoap,sgovp,gcr,playlist_type/sig/ALgxI2wwRgIhAMnsPURHKD3s6d-sU0lgVDjboOn6Lt-dX1AmwdcqMNoPAiEA06zQ7GeThaEWbmBMu3_gfpvE7joel52dBLGjr6A5CjE%3D/lsparams/hls_chunk_host,initcwndbps,mm,mn,ms,mv,pl/lsig/AHylml4wRQIhAIQw32VP8zAYPVNAlcu69N4A5ItlnDMnoi_WRNKbr1GzAiBBdxe3ulN6SpUQ77YvSVzL75w2C_tDpmX3SJRF8NnlAQ%3D%3D/playlist/index.m3u8
I tried to play directly from this url, which I know Eris can do, so... something like this:
connection.play("insert that huge url here");
// Edit: the code below is now my "workaround" until the issue is fixed.
const stream = () => {
if (info.livestream) {
const format = ytdl.chooseFormat(info.formats, { quality: [128,127,120,96,95,94,93] });
return format.url;
} else return ytdl.downloadFromInfo(info, { filter: 'audioonly' });
}
connection.play(stream());
And with this the bot proceeded to play the livestream properly, it played it fine and did not stop until I told it to stop ~ 1 hour-ish later. It did play with a few sound "glitches" sometimes, but I'll consider that a win. 馃憤
I hope this piece of info is useful in finding a solution for this issue. 馃憤
its not ytdl issue, its your code issue, because works fine for me :>
is this still happening for people? i'm not able to replicate using ytdl and the command
ytdl [video_id] | mpv -
Its back to working for me so I think it might have been a youtube error. I'll close this.
Most helpful comment
I also use ytdl-core to play YouTube videos on a Discord Bot, I'm using Eris lib.
So, before I was doing something like this:
With this setup, I noticed through
stream().on("info", (info, format) => { console.log(format) })that the format itag ytdl was picking was140. This is not a livestream itag, so this will likely be a small audio file with just a few seconds, which is proven by how the Discord bot proceeded to play the livestream for just a few seconds, much like @MayorChano demonstrated in this video.Then, I changed to something like this:
With this I check if the video is a livestream and if so I make ytdl pick a format itag from
[128,127,120,96,95,94,93]which are a few livestream "compatible" itags. This time ytdl picked the format with itag94. Unfortunately, the bot did not play the livestream at all, not even a few seconds, it stopped immediately. Then I got the url of this format (again through.on("info")) which wasI tried to play directly from this url, which I know Eris can do, so... something like this:
And with this the bot proceeded to play the livestream properly, it played it fine and did not stop until I told it to stop ~ 1 hour-ish later. It did play with a few sound "glitches" sometimes, but I'll consider that a win. 馃憤
I hope this piece of info is useful in finding a solution for this issue. 馃憤