axcore / tartube

A GUI front-end for youtube-dl, partly based on youtube-dl-gui and written in Python 3 / Gtk 3
GNU Lesser General Public License v2.1
2.05k stars 111 forks source link

How to download 1080p AVC MP4 from YouTube? #620

Closed adenry closed 6 months ago

adenry commented 7 months ago

As the title suggests, I am not able to download 1080p AVC MP4 videos from YouTube.

If I force TarTube to download an MP4, it only downloads a 720p MP4. If I let it download the best quality available, it downloads a 1080p VP9 MKV (and I don't want a VP9). If I force it to download a 1080p MP4 (using the Formats option), I get the "Nothing happened" window and a "Requested format is not available" error.

Obviously, I don't want to reencode the VP9 to AVC or just wrap the VP9 in an MP4.

This happens with literally every video I try, but here's one example: https://www.youtube.com/watch?v=_4WrKeoeZhk

When I Fetch the available formats, there is a <137> 1920x1080p AVC available. There is even another, higher bitrate 1080p AVC (<270>), which would be even better, as well as a <399> 1920x1080p AV1, but those are beside the point.

I am using classic mode by the way. I have the latest yt-dlp and ffmpeg installed.

Googling this issue didn't help very much. Somebody claimed it was a yt-dlp issue, but I don't think that's the case, because I am able to download these 1080p AVC videos with Open Video Downloader, which also uses yt-dlp. 4k Video Downloader is also able to download these as well, although I don't know if it uses yt-dlp or not.

Am I missing something here? I am new to TarTube, so I suppose I am, but any help would be appreciated.

TL DR:

  1. How do I setup Tartube to prefer an AVC 1080p video over a VP9 one (from YouTube)?
  2. Is there any way for Tartube to show me which video and audio formats are available for a video and for me to choose which ones I want to download? Like Open Video Downloader and 4k Video Downloader do.
axcore commented 7 months ago

How do I setup Tartube to prefer an AVC 1080p video over a VP9 one (from YouTube)?

First, find out how to do that with yt-dlp. The Reddit youtube-dl forum is a good place to ask.

Then, in the Classic Mode tab, click the menu button in the top-right corner, select Edit download options..., and then add something to the Additional download options box. For example, format <137> is video-only, but if you actually wanted that, then you would add

-f 137

Is there any way for Tartube to show me which video and audio formats are available for a video and for me to choose which ones I want to download?

I haven't used either of them. Presumably they fetch a list of available formats for each video in the background, which is why you can choose the format for each video individually. That's not very practical for Tartube, whose focus is managing very large numbers of videos. (Different applications, and a different focus for each.)

adenry commented 7 months ago

Thank you for your reply! I suspected Tartube can't do it natively, but it was worth asking. I will check how to do it with yt-dlp and use the additional download options box. I will post again if I find a solution, so others with the same issue can benefit from it.

adenry commented 6 months ago

Today I finally had some time to solve this issue.

First, to answer my own questions why neither of the three things I tried worked:

  1. If I force TarTube to download an MP4, it only downloads a 720p MP4: That's becuase yt-dlp is only looking for files that contain both audio and video, and that's only available in 720p, not in 1080p.
  2. If I let it download the best quality available, it downloads a 1080p VP9 MKV (and I don't want a VP9): That's because yt-dlp prioritizes VP9 over AVC as a codec with a better efficiency (the priority is: av01 > vp9.2 > vp9 > h265 > h264 > vp8 > h263 > theora > other).
  3. If I force it to download a 1080p MP4 (using the Formats option), I get the "Nothing happened" window and a "Requested format is not available" error: Again, that's because yt-dlp is only looking for files that contain both audio and video, and no such 1080p file exists.

The solution, as @axcore suggested, is to use yt-dlp code in Additional download options.

I want to get the best possible video with my preferred video and audio codecs, even if that means merging separate video-only and audio-only streams. And only if such streams don't exist, then I want just the best possible format yt-dlp can get me. So this is the code that I wrote and worked for me:

-f "(bv*[vcodec~='^((hevc|h265|avc|h264|av01)']+ba[acodec~='^(wav|flac|aac|mp4a|mp3|eac3|ac3)']) / (bv*+ba/b)"

Anyone can use this code and replace the codecs I wrote with their own preferred codecs in the order they want. I hope that can help others with the same issue.

PS: It would be great to see this as a feature implemented in TarTube. A user interface that allows you to set your preferred resolution, codecs, format, etc. The "Formats > Preferred" tab in Download options doesn't really offer that functionality.