Search code examples
youtubeyoutube-dl

youtube-dl format option for best audio and video does not working in live streams


I use youtube-dl to stream videos from youtube. I use this format to stream/download youtube non-live videos of quality less than 720p which works fine.

youtube-dl -f 'bestvideo[height<=?720]+bestaudio'  https://www.youtube.com/watch?v=ubk3dvOdYzg

But for live youtube videos

youtube-dl -f 'bestvideo[height<=?720]+bestaudio' https://www.youtube.com/watch?v=Ij2rYpNxXgM

its showing this error

ERROR: requested format not available


Solution

  • Your format says to take the best video-only stream below 720p and mux it together with the best audio stream. However, in this case, the live stream in question does not seem to have individual streams, just one stream with picture and audio.

    To support these kinds of videos, add that format (best[height<=?720]' in your case) to your format specification:

    youtube-dl -f 'bestvideo[height<=?720]+bestaudio/best[height<=?720]' Ij2rYpNxXgM
    

    If you always want videos in 720p or less, you can also write -f 'bestvideo[height<=?720]+bestaudio/best[height<=?720]' into a configuration file so you don't have to type it out all the time.