Kethsar / ytarchive

Garbage Youtube livestream downloader
MIT License
1.19k stars 94 forks source link

YouTube video player has better bitrate than vp9 file #89

Closed Indenhurst closed 2 years ago

Indenhurst commented 2 years ago

The video I downloaded while the livestream was happening using --vp9 was worse than a screengrab from the video player on youtube. Why is that? I used both --vp9 --no-frag-files and best

Kethsar commented 2 years ago

What do you mean by a screengrab? As in using screencapture with OBS or some other recording software?

Indenhurst commented 2 years ago

What do you mean by a screengrab? As in using screencapture with OBS or some other recording software?

I took a screenshot, a print screen off of youtube, and compared that to the downloaded mp4. The screenshot looks better than the video I downloaded. The screenshot has higher bitrate. I used the print screen key on my keyboard

Kethsar commented 2 years ago

I don't know what you are trying to do or why, but you do not compare screenshots to playing video. You can compare a lossless screenshot of the same frame of a video, in this case in the Youtube player and playing from the file you download. Or better yet, no need to take a screenshot unless you are showing it to someone else, and instead just compare the frame from the paused players themselves.

Indenhurst commented 2 years ago

I don't know what you are trying to do or why, but you do not compare screenshots to playing video. You can compare a lossless screenshot of the same frame of a video, in this case in the Youtube player and playing from the file you download. Or better yet, no need to take a screenshot unless you are showing it to someone else, and instead just compare the frame from the paused players themselves.

I think you misunderstood me. I compared the same exact frames, both paused, using both alt-tab and taking a lossless screenshot. I made sure the youtube video was aligned with the downloaded video by adjusting using , and . I imagine you thought I compared a screenshot to a moving video. I would never do that.

Kethsar commented 2 years ago

Indeed, I also don't know if you meant you were comparing the live download vs. the processed video on youtube, which would also have differences. This is why I am confused as to what you are doing or why you think this is an issue.

Indenhurst commented 2 years ago

What I am asking is, shouldn't a downloaded mp4 of a youtube livestream that is live right now be better than the one that I can find on youtube.com? I am losing my mind over the fact that a downloaded video on my harddrive from a livestream that has been deleted has lower bitrate than the video player on youtube.com. For example, the video on the built in video player on youtube had 2000kbps while the downloaded is 1900kbps. Am I still being misunderstood?

Kethsar commented 2 years ago

Okay, I figured that might be the case, but your original opening comment on this issue actually had me thinking you downloaded with yta and recorded the video via OBS or something else, that's how vague it was.

So, Youtube does variable bitrate for videos, with a target bitrate that it tries to keep a max average of over the whole video. Typically, 1080p60 targets ~4500kbps, 720p60 ~2500kbps, and I've not checked others. Low-motion streams can average below that target, but high motion streams pretty much keep to it. They do two transcodes for livestreams. One is while it's live, they transcode the stream being sent to them in real time, while also saving the raw data to their servers. Second, after the stream is finished, they take the raw data and transcode it again, presumably with better settings and processing power. Also, depending on the livestream latency set (ultra low, low, normal), VP9 might not be available live, but will be available in the processed video.

I would wholly expect, almost every time if not every time, for the processed video to be better than the live video. Bitrate is not the be-all-end-all by the way. If a streamer is only using 500kbps for a 720p stream, Youtube will still transcode with a target bitrate of 2500kbps, but it won't look any better despite that.

Indenhurst commented 2 years ago

Okay, I figured that might be the case, but your original opening comment on this issue actually had me thinking you downloaded with yta and recorded the video via OBS or something else, that's how vague it was.

So, Youtube does variable bitrate for videos, with a target bitrate that it tries to keep a max average of over the whole video. Typically, 1080p60 targets ~4500kbps, 720p60 ~2500kbps, and I've not checked others. Low-motion streams can average below that target, but high motion streams pretty much keep to it. They do two transcodes for livestreams. One is while it's live, they transcode the stream being sent to them in real time, while also saving the raw data to their servers. Second, after the stream is finished, they take the raw data and transcode it again, presumably with better settings and processing power. Also, depending on the livestream latency set (ultra low, low, normal), VP9 might not be available live, but will be available in the processed video.

I would wholly expect, almost every time if not every time, for the processed video to be better than the live video. Bitrate is not the be-all-end-all by the way. If a streamer is only using 500kbps for a 720p stream, Youtube will still transcode with a target bitrate of 2500kbps, but it won't look any better despite that.

I'm glad I was understood, but I don't understand all the stuff you just said. Since the stream will be deleted after it finishes, is there a way to download the livestream that won't be processed at all, in a higher bitrate and override the average bitrate? The livestream is in fact vp9, 1080p 30fps.

Kethsar commented 2 years ago

No. Also, if you are comparing the same frame of the same stream as it is live in the youtube player vs what you have downloaded, it will be the exact same. Any differences will either be perceptual and not actually there, OR it will be a case of how Youtube renders it vs how your media player renders it.

Indenhurst commented 2 years ago

No. Also, if you are comparing the same frame of the same stream as it is live in the youtube player vs what you have downloaded, it will be the exact same. Any differences will either be perceptual and not actually there, OR it will be a case of how Youtube renders it vs how your media player renders it.

Funny enough, I compared with another vp9 stream vs a downloaded mp4. Those looked the same. Is it the stream I actually want to download that has some issues?

I use mpc-hc, vlc. Lossless screenshots.

Kethsar commented 2 years ago

I don't know. Also MP4 is just a container, it can contain VP9. ytarchive uses the mp4 container by default regardless of if the stream video is VP9 or h264.

Indenhurst commented 2 years ago

I don't know. Also MP4 is just a container, it can contain VP9. ytarchive uses the mp4 container by default regardless of if the stream video is VP9 or h264.

Ye I know mp4 is a container. I used the mp4 as a way to be clear with what I meant.

Indenhurst commented 2 years ago

Anyway, thank you for your explanation and time. I know my explanation in the beginning was mediocre.

Indenhurst commented 2 years ago

Last thing, is there a vp9 m3u8 for a livestream? Because the one fetched by youtube-dl/yt-dlp is h264. Can I fetch the url that ytarchive uses for the specific video?

Kethsar commented 2 years ago

youtube-dl/yt-dlp use HLS for the stream, which does not support VP9 as far as I know, and has the video and audio combined into one data stream. ytarchive prioritizes using DASH, which has all the available data streams but also means you have to grab video and audio separately.

Indenhurst commented 2 years ago

youtube-dl/yt-dlp use HLS for the stream, which does not support VP9 as far as I know, and has the video and audio combined into one data stream. ytarchive prioritizes using DASH, which has all the available data streams but also means you have to grab video and audio separately.

Okay great. So how do I get the dash url that ytarchive uses so that I can record the separate audio and video streams?