trizen / youtube-viewer

Lightweight YouTube client for Linux
https://trizenx.blogspot.com/2012/03/gtk-youtube-viewer.html
Artistic License 2.0
1.19k stars 86 forks source link

Lag/Out of Sync when Rewinding #424

Closed ghost closed 1 year ago

ghost commented 1 year ago

If you open a video with youtube-viewer, it will play fine, but if you try to skip back 5 seconds using the left arrow key, then it glitches. The video will play, then the video will stop and the audio will play, then the video speeds up until it catches back up to where you were.

Running youtube-viewer and also gtk version, happens in both, on Ubuntu 22.04.1 LTS.

trizen commented 1 year ago

This is an mpv/ffmpeg/youtube issue...

ghost commented 1 year ago

This is an mpv/ffmpeg/youtube issue...

Previously I was on Ubuntu 22.04, and it was happening with both youtube-viewer, and with just giving mpv the url directly. However I moved to arch and it only seems to be happening with youtube-viewer. Just passing the link to mpv directly and the skipping is seamless. Is youtube-viewer using an older version of mpv?

trizen commented 1 year ago

There are some differences on how mpv/yt-dlp extracts the YouTube streaming URLs, compared to youtube-viewer.

Some workarounds for this issue, would be:

Or passing the YouTube URLs directly to mpv, by making the following change in the configuration-file:

mpv => {
        arg => "--really-quiet --force-media-title=*TITLE* *URL*",
        cmd => "mpv",
        fs => "--fullscreen",
        novideo => "--no-video",
        srt => "--sub-file=*SUB*",
      },
ghost commented 1 year ago

Disabling Dash supported worked, but the resolution is then only 640p.

Passing the URL directly didn't affect the resolution, however the issue still happens.

There are some differences on how mpv/yt-dlp extracts the YouTube streaming URLs, compared to youtube-viewer.

Some workarounds for this issue, would be:

* Disabling `dash_support` in the configuration file. (`dash_support => 0,`)

Or passing the YouTube URLs directly to mpv, by making the following change in the configuration-file:

mpv => {
        arg => "--really-quiet --force-media-title=*TITLE* *URL*",
        cmd => "mpv",
        fs => "--fullscreen",
        novideo => "--no-video",
        srt => "--sub-file=*SUB*",
      },
trizen commented 1 year ago

Passing the URL directly didn't affect the resolution, however the issue still happens.

That's weird. Because it should be equivalent with executing mpv YOUTUBE-URL.

Another possible workaround would be setting force_fallback => 1, in the configuration file, which will make youtube-viewer to always use yt-dlp (or the invidious instances) for extracting the YouTube streaming URLs.

Although, it may not fix the issue, because I suspect it's an mpv/ffmpeg issue, having issues with syncing the audio file and the video file when navigating backwards and forwards, where both the audio and the video files are URLs.

ghost commented 7 months ago

(Commenting from different account). I came back to this issue recently when trying to get around YouTube's annoying adblock-blocking stuff.

You're right about it being to do with having a separate audio and video file, as if you use the 22 format (the 720p one you get if you use mpv --ytdl-format=best), then the issue doesn't occur. It still occurs in when setting the resolution to 720p in gtk-youtube-viewer, as it's using separate audio streams (I assume, as the audio is opus but the 22 format uses aac, the one youtube-viewer is using looks much better visually.

Adding hr-seek=yes to mpv.conf fixes the issue, not sure if it has an other drawbacks though, I don't fully understand what it does.