Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

yt-dlp has been awesome, but one thing I [admittedly havent tried to solve and] don't like about it is that it seems to default to unusual container types when downloading.

When using yt-dlp, I get a .webm file, and when asking for audio only using `-x`, I get an .opus file. Is there any reason for this?



That is because by default yt-dlp tries to download the best / better format available and (I take it the context of your downloads are YT) these are the best ones available.

You can customize which format to download by doing first:

yt-dlp -F <url>

Check what numbers are there, and then download the formats you want.

You can customize both the video format & rate, and same for sound, by using

yt-dlp #+# <url>

Where the first hash is the id of the video stream, and the 2nd hash is the id of the audio id.

Take into account that you'd probably need also ffmpeg available on the command line for this; that if you "mix" containers (Say, a webm video and an m4u audio stream) you-ll end up with an .mkv container; and finally, that all of the downloaded streams are themselves containers (.m4u, mp4 & webm).


> Take into account that [...] if you "mix" containers [...] you'll end up with an .mkv container

He's complaining about getting an .mkv in the first place, so this seems unlikely to solve his problem.


He can solve it if he tells yt-dlp to download a mix of .mp4 and .m4u


A .webm file is an .mkv file. You can rename to .mkv without any ramifications.

My guess would be that yt-dlp is giving you whatever file format it finds, with no editorializing. The default is just to go with "best quality" available. So "Is there a reason for this?" is likely a better question for whoever maintains the site(s) you're downloading from.


to the best of my knowledge, that's because your system does not have ffmpeg for subsequent transcoding of the site's format into what you would consider "your" format: https://github.com/yt-dlp/yt-dlp/blob/2023.07.06/README.md#s... (they also allow you to specify the path, if you don't have it in your $PATH, via --ffmpeg-location <https://github.com/yt-dlp/yt-dlp/blob/2023.07.06/README.md?p...>)


i can imagine it's a bit of grandstanding for open formats vs the encumbered formats that are more popular.


No. It’s simply going for the highest quality available.


i'll accept that. so the grandstanding is with Googs/YT in only providing the higher quality in those formats. there's no compelling reason other than pushing the other formats and trying to throw shade on the others. they are already using h.264, so just up the quality and not force a totally different codec.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: