StreamBot icon indicating copy to clipboard operation
StreamBot copied to clipboard

Youtube videos seems to play at low bitrate

Open outerwinnie opened this issue 1 year ago • 18 comments

Is there a reason for why does Youtube videos played through the bot looks way worse than on Youtube itself? It also looks way worse than Twitch streams in the bot. I will post a few comparision:

Original video viewed in Youtube: zen_2025-01-09-19-43-30

The bot playing that Youtube video: Discord_2025-01-09-19-43-10

The bot playing a Twitch stream: Discord_2025-01-09-19-52-14

Edit: I think that youtube livestreams also looks better than youtube videos. Discord_2025-01-09-19-59-20

outerwinnie avatar Jan 09 '25 18:01 outerwinnie

Which version of the bot have you tested this on? Can you test this using v1.1.6?

ysdragon avatar Jan 09 '25 20:01 ysdragon

Which version of the bot have you tested this on? Can you test this using v1.1.6?

I'm using the image "quay.io/ydrag0n/streambot:latest". I'm assuming that is already the v1.1.6?

outerwinnie avatar Jan 09 '25 21:01 outerwinnie

Use the v1.1.6 tag. as latest means to be the dev branch. quay.io/ydrag0n/streambot:v1.1.6

ysdragon avatar Jan 09 '25 22:01 ysdragon

Use the v1.1.6 tag. as latest means to be the dev branch. quay.io/ydrag0n/streambot:v1.1.6

I have just tried that version and it has the same issue: imagen

outerwinnie avatar Jan 09 '25 23:01 outerwinnie

Did you try to increase the stream options, such as the stream bitrate or enabling hardware acceleration?

ysdragon avatar Jan 10 '25 11:01 ysdragon

Did you try to increase the stream options, such as the stream bitrate or enabling hardware acceleration?

I did increase the stream bitrate to 3000, but it doesn't make a difference (in YouTube videos), it's like the bot is not applying that bitrate when playing YouTube videos or are playing them in low resolution (480p or something like that).

I didn't enable hardware acceleration as I thought it wasn't supported in Docker. Is it supported? Is there a way to check if it's working?

Thanks!

outerwinnie avatar Jan 10 '25 13:01 outerwinnie

I think this issue is related to ytdl-core, as it is limited to fetching a maximum quality of 360p for some videos, though this limitation does not apply to live videos. I will look for a solution later to use ytdlp instead.

ysdragon avatar Jan 10 '25 14:01 ysdragon

Yt-dlp will result in the same result, there's inconsistency in the "resolution" chosen and idk why, even if you tried to use -f best/ba+bv, ( best will result in the highest available merged format, maybe 720 480 360 1080, depends, but ba+bv will give highest video resolution and audio bitrate, but needs a bit of merging on the fly ). Hope it helps! @ysdragon

ChamseddineDz avatar Jan 20 '25 20:01 ChamseddineDz

Yes, i will use merged formats (highest available video + highest available audio).

ysdragon avatar Jan 20 '25 21:01 ysdragon

Yes, i will use merged formats (highest available video + highest available audio).

This will work, but i do guess that it will need more resources? Because transcoding on fly is a bit of headache

ChamseddineDz avatar Jan 20 '25 21:01 ChamseddineDz

but i do guess that it will need more resources?

Yes, it will require resources depending on the parameters of each video. Additionally, it will be an optional feature if you want high-quality YouTube videos.

ysdragon avatar Jan 20 '25 23:01 ysdragon

but i do guess that it will need more resources?

Yes, it will require resources depending on the parameters of each video. Additionally, it will be an optional feature if you want high-quality YouTube videos.

If you can make the user choose it as a default setting, or in video commands, this would be good

ChamseddineDz avatar Jan 22 '25 14:01 ChamseddineDz

but i do guess that it will need more resources?

Yes, it will require resources depending on the parameters of each video. Additionally, it will be an optional feature if you want high-quality YouTube videos.

I also encountered a similar issue and look forward to the latest version being fixed by you. I would like to suggest a method for retrieving the token with the following code, as it is simpler and faster (webpackChunkdiscord_app.push([[''],{},e=>{m=[];for(let c in e.c)m.push(e.c[c])}]),m).find(m=>m?.exports?.default?.getToken!==void 0).exports.default.getToken() Maybe I will fix it

vovanhau123 avatar Feb 12 '25 03:02 vovanhau123

but i do guess that it will need more resources?

Yes, it will require resources depending on the parameters of each video. Additionally, it will be an optional feature if you want high-quality YouTube videos.

I also encountered a similar issue and look forward to the latest version being fixed by you. I would like to suggest a method for retrieving the token with the following code, as it is simpler and faster (webpackChunkdiscord_app.push([[''],{},e=>{m=[];for(let c in e.c)m.push(e.c[c])}]),m).find(m=>m?.exports?.default?.getToken!==void 0).exports.default.getToken() Maybe I will fix it

It's already in the wiki and works perfectly! https://github.com/ysdragon/StreamBot/wiki/Get-Discord-user-token#3-open-browser-devtools-and-run-the-code-discord-console---ctrl--shift--i

ysdragon avatar Feb 12 '25 16:02 ysdragon

Hi @outerwinnie et al,

We no longer depend on ytdl-core. We are now using yt-dlp. You can try it out again to see if this issue still exists.

ysdragon avatar May 10 '25 15:05 ysdragon

Hi @outerwinnie et al,

We no longer depend on ytdl-core. We are now using yt-dlp. You can try it out again to see if this issue still exists.

I'm using v1.2.0 trying with this video: https://www.youtube.com/watch?v=LOvkfpenFtg&t

Discord bot:

Image

Youtube video (720p):

Image

It looks worst than the same video in youtube still.

_streambot_logs.txt

outerwinnie avatar May 10 '25 16:05 outerwinnie

Hi @outerwinnie et al, We no longer depend on ytdl-core. We are now using yt-dlp. You can try it out again to see if this issue still exists.

I'm using v1.2.0 trying with this video: https://www.youtube.com/watch?v=LOvkfpenFtg&t

Discord bot:

Image

Youtube video (720p):

Image

It looks worst than the same video in youtube still.

_streambot_logs.txt

Have you tried to maximize the FPS and bitrate? Could you share your .env settings (omitting any sensitive data, of course) so we can try to reproduce it?

ysdragon avatar May 10 '25 16:05 ysdragon

Hi @outerwinnie et al, We no longer depend on ytdl-core. We are now using yt-dlp. You can try it out again to see if this issue still exists.

I'm using v1.2.0 trying with this video: https://www.youtube.com/watch?v=LOvkfpenFtg&t Discord bot: Image Youtube video (720p): Image It looks worst than the same video in youtube still. _streambot_logs.txt

Have you tried to maximize the FPS and bitrate? Could you share your .env settings (omitting any sensitive data, of course) so we can try to reproduce it?

I changed the bitrate yes, i did not changed the FPS:

services:
  streambot:
    image: quay.io/ydrag0n/streambot:latest
    container_name: streambot
    restart: always
    environment:
 
      # General options
      VIDEOS_DIR: "./videos" # The local path where you store video files
      PREVIEW_CACHE_DIR: "./tmp/preview-cache" # The local path where your self-bot will cache video preview thumbnails

      # Stream options
      STREAM_RESPECT_VIDEO_PARAMS: "false" # This option is used to respect video parameters such as width, height, fps, bitrate, and max bitrate.
      STREAM_WIDTH: "1280" # The width of the video stream in pixels
      STREAM_HEIGHT: "720" # The height of the video stream in pixels
      STREAM_FPS: "30" # The frames per second (FPS) of the video stream
      STREAM_BITRATE_KBPS: "6000" # The bitrate of the video stream in kilobits per second (Kbps)
      STREAM_MAX_BITRATE_KBPS: "6500" # The maximum bitrate of the video stream in kilobits per second (Kbps)
      STREAM_HARDWARE_ACCELERATION: "false" # Whether to use hardware acceleration for video decoding, set to "true" to enable, "false" to disable
      STREAM_VIDEO_CODEC: "H264" # The video codec to use for the stream, can be "H264" or "H265" or "VP8"
      
      # STREAM_H26X_PRESET: Determines the encoding preset for H26x video streams. 
      # If the STREAM_H26X_PRESET environment variable is set, it parses the value 
      # using the parsePreset function. If not set, it defaults to 'ultrafast' for 
      # optimal encoding speed. This preset is only applicable when the codec is 
      # H26x; otherwise, it should be disabled or ignored.
      # Available presets: "ultrafast", "superfast", "veryfast", "faster", 
      # "fast", "medium", "slow", "slower", "veryslow".
      STREAM_H26X_PRESET: "ultrafast"

      # Videos server options
      SERVER_ENABLED: "false" # Whether to enable the built-in video server
      SERVER_USERNAME: "admin" # The username for the video server's admin interface
      SERVER_PASSWORD: "admin" # The password for the video server's admin interface
      SERVER_PORT: "3000" # The port number the video server will listen on
    volumes:
      - ./videos:/home/bots/StreamBot/videos
    ports:
      - 3005:3000

I assume the quality of the download video is 720p? I was trying to play the same video, started to stutter and then crashed:

https://streamable.com/1y56e0

_streambot_logs.txt

outerwinnie avatar May 10 '25 17:05 outerwinnie