dank074/Discord-video-stream

Video lagging a lot

Opened this issue · 10 comments

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?

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

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?

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

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.

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

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

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 ysdragon/StreamBot#37 (comment)

dank074 commented

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