DzenanJupic/rustube

Make high quality the default (or add documentation on how to choose that)

Closed this issue · 4 comments

Lyamc commented

I don't know if this is related to the split_once, but trying with a couple videos, it consistently does the following:

Rustube chooses P360
640x360 h.264 at average bitrate around 700kbps
96kbps VBR aac 44100Hz (not normalized)

Youtube chooses P1080
1920x1080 VP9/H264
Opus 48000Hz (normalized)

With rustube check <url> I notice two things:

  1. The correct stream types are showing up, but P360 is the first in the list and out of order from the rest.
  2. The loudness_db is not being correctly applied

Videos are listed before audio and shows:

        loudness_db: None

so if there's an audio stream with some ridiculous loudness_db:

        loudness_db: Some(
            8.46,
        ),

then the final audio is way too loud and clips. I'm going to guess it's related to my issue with it choosing 360p

@Lyamc thank you for the report.

It's not related to split_once. The current implementation of Video::best_quality (which is used by the CLI) works by first filtering out all videos that don't have both a video and an audio track, and then picking the stream with the maximum QualityLabel:

self
    .streams
    .iter()
    .filter(|stream| stream.includes_video_track && stream.includes_audio_track)
    .min_by_key(|stream| stream.quality_label)

My guess is that either the video and audio track detection is wrong, or that the Streams you're referring to don't contain audio. Did you download some of the high-quality Streams to check if they contain an audio track?

Currently, the best way of doing that is either
rustube download --ignore-missing-audio <URL>
or
rustube download --video_quality [144p|240p|360p|480p|720p|720p50|720p60|1080p|1080p60|1440p|1440p60(only >0.2.6)|2160p|2160p60] <URL>.

I'm currently adding some features to the CLI, and as it turns out I was lying to you. The CLI doesn't use Video::best_quality, but its own, hacky algorithm to compare the quality of two Streams.
I'll rewrite it to match the behaviour of the Video methods.
The last point I made, though, still holds true: Streams with high video quality often come without an audio track.

Lyamc commented

Just to answer the earlier question, I tried a variety of high quality music videos since they often have a significant loudness reduction (45%!!) in the youtube player.

@Lyamc now, after quite some time, rustube-cli 0.3.0 is released. With this release, we also shipped a new stream comparison algorithm that now hopefully does what it should do.

To check out all the streams that rustube-cli considers for downloading you can run rustube check <identifier>. To also see streams without video or without audio track you can run rustube check --ignore-missing-video --ignore-missing-audio <identifier>.

When you run rustube download <identifier>, rustube-cli will tell you which stream it picked for downloading.