dank074 / Discord-video-stream

Experiment for making video streaming work for discord selfbots.
183 stars 35 forks source link

Video lagging a lot #38

Open DanilochTop opened 1 year ago

DanilochTop commented 1 year ago

No errors in output, audio plays fine, but the video is lagging a lot, only some frames are playing... Do you guys have some suggestions to fix this issue?

dank074 commented 1 year ago

Make sure you're using h264 codec since the encoder for that uses a lot less cpu than vp8. If your computer/vps still struggles with that you can decrease the bitrate and/or resolution

DanilochTop commented 1 year ago

Thanks for the help, but apparently I don't believe it's a cpu problem, since ffmpeg isn't consuming even 10% of it looking through the task manager. I'll try hosting on a VPS and see if this problem is fixed, as soon as I have an answer I'll let you know.

DanilochTop commented 1 year ago

I just tested with a VPS, and it seems to work fine (almost), i just needed to set the stream FPS to 15, but that's not a problem for me. For better results maybe I need a better CPU?

dank074 commented 1 year ago

If it wasn't using too much cpu but the resulting video was still slow it could be your internet speed. Try lowering the bitrate and resolution

longnguyen2004 commented 9 months ago

Can you test the current version of the package? I've optimized various parts in the code, and it should be purely IO bound now.

Darwin1546 commented 1 month ago

Same thing. Even with 240p 15fps https://github.com/user-attachments/assets/f95dc66d-5123-4bb8-8176-6252e9763b7c

Darwin1546 commented 1 month ago

I've added buffer and performance/quality is fine now. I deleted

-fflags nobuffer
-analyzeduration 0

and added

-bufsize 6000k

But audio still ahead of the video. And I have no idea how to fix that

dank074 commented 1 month ago

What kind of video input is it? A regular video file or a m3u8 livestream? I know that there's an issue with certain m3u8 streams where the audio is out of sync with the video and the only solution I found was to remove the '-re' flag. There's an open issue about it

Darwin1546 commented 1 month ago

I'm using this interface https://github.com/ysdragon/StreamBot

It doesn't support readAtNativeFps option afaik Is '-re' enabled by default?

I've tested local file and youtube video (it still loads locally)

Also this https://github.com/ysdragon/StreamBot/issues/37#issue-2417751216

dank074 commented 1 month ago

At some point it was the default, until I removed it and added it as an option instead since it did not affect all video files