I want to use a format selector that is something like -f bestvideo+
best audio whose extension is compatible with the video extension
so that they don't need to be muxed into an mkv (WARNING: Requested formats are incompatible for merge and will be merged into mkv.
).
Note: I know about -f best
and I don't want that. I want the best possible qualities of both audio and video while ensuring that they are compatible. How to do that?
You can download the best video and audio by using:
If that gives you an error, try the following instead:
Here you download the best video and audio seperately and then merge into a, in this case mp4 file. You can change the output format on the merged video as well.
Good luck!
old question, but first answer on google, so:
with defining the following function, it worked for me (also possible to place it in
~/.bashrc
):now you can download with
source: own creation
mix'n'match formats
This will show all available formats for the linked vid.
so
then just pick formats and join with a plus.
137 = 2k, 30fps. For example, I dont want 60fps, but I want best audio.
Note that not all formats merge into mp4, so mkv is a safer bet.
you choose the audio and video format and then combine with
+
.For example:
But
ffmpeg
is necessary.Similar to the above I use the following to download the best video and best audio for all videos in a playlist
There's a manual component and you need FFMpeg folder in the same director as youtube-dl
First run .\youtube-dl.exe --list-formats https://www.youtube.com/watch?v=cTcMtgA6iYt
sample output:
Output of .\youtube-dl.exe --list-formats https://www.youtube.com/watch?v=cTcMtgA6iYt
Now pick the format numbers you want to merge [137 for video and 140 for audio] Note | you need to pick the same format container e.g. 313 for video won't work with 140, you need a webm audio only file like 251
then run the following
.\youtube-dl.exe --ffmpeg-location "D:\FFmpeg\ffmpeg-N-100072-g1555cfedf6-win64-gpl-shared-vulkan\bin\ffmpeg.exe" --format 137+140 --yes-playlist -i https://www.youtube.com/playlist?list=PLFfX4Mdr5gLs52KWVl3KQNrRpTmLOn
once that finishes downloading all files where 137 was available, then re-run the same command, but this time with the next best code like 136+140
and what i usually do is...
at the very end...i run
.\youtube-dl.exe --ffmpeg-location "D:\FFmpeg\ffmpeg-N-100072-g1555cfedf6-win64-gpl-shared-vulkan\bin\ffmpeg.exe" --format 22 --yes-playlist -i https://www.youtube.com/playlist?list=PLFfX4Mdr5gLs52KWVl3ZQNrSoTmLOnQdk
22 - will pick up all videos missed, its a video and audio merged file that youtube-dl downloads by default, when you ommmit the format switch