glubsy / livestream_saver

Monitor a Youtube channel and download live-streams from the first segment
GNU General Public License v3.0
315 stars 39 forks source link

Audio is exactly 2 seconds behind #83

Open eugeny-dementev opened 2 months ago

eugeny-dementev commented 2 months ago

Each stream captured have exactly 2 seconds desync behind video

Firstly I've run mostly example configuration with no change to yt-dlp command. Default one as in example livestream_saver.cfg

When noticed the issue I've run yt-dlp command directly but reduced version: yt-dlp -f bestvideo+bestaudio --live-from-start <youtube_stream_link> Left it for the night and it end up being perfect, no sync issue

Updated command in livestream_saver.cfg to be the same with only -f and --live-from-start arguments and nothing changed, still each stream recorded has that exactly 2 seconds desync

What can I try to fix the issue?

glubsy commented 2 months ago

I did not notice this bug on my side (yet) but it's definitely related to yt-dlp.

Make sure that the yt-dlp you are using in your virtual environment is up to date. This is separate from any yt-dlp client you have installed on your system, we're talking about the library package of yt-dlp in this case:

source path/to/venv/bin/activate
pip install --upgrade yt-dlp

Be wary that the yt-dlp configuration is done in ytdlp_config.json currently. The example ytdlp_command variable in livestream_saver.cfg is only used by hooks (for example: on_upcoming_detected_command, etc.)

This is not something I can fix, but thanks for reporting anyway. Will keep an eye on this.

eugeny-dementev commented 1 month ago

Thank you for reply. One important thing I forgot to mention. I'm using https://hub.docker.com/r/glubsy/livestream_saver

Inside is definitely old version of yt-dlp: 2023.12.30 While the latest is 2024.04.09

eugeny-dementev commented 1 month ago

I'm not sure why your Dockerfile doesn't pulls latest version of yt-dlp, don't really have much experience with python and pip, but maybe switching to ADD --chmod=755 https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp /usr/bin approach to build docker image would change something?

eugeny-dementev commented 1 month ago

@glubsy Please check updates on the context

glubsy commented 1 month ago

Currently there is no mechanism to fetch the latest version of yt-dlp inside the docker image (at run-time). The embedded yt-dlp is the latest version coming from the upstream github repository at the time of image building.

I updated the Docker hub image 13 days ago with the latest version of yt-dlp (2024.04.09), perhaps this will help in that regard.

Does the desync happen over time, or right from the start of the video?

eugeny-dementev commented 1 month ago

Right from the start. It's rock solid exactly 2 seconds through the whole video. I'll try new image and report with updates

eugeny-dementev commented 1 month ago

It's the same with new image with latest yt-dlp