Search code examples
youtube-dl

Can't use YouTube-dl to download specified bitrate


After needing something both easy and powerful that would allow me to download YouTube playlists and finding no better alternative, I've recently started using youtube-dl (with ffmpeg) in the command line. I'm currently in the process of playing around with and testing the quality of my downloaded playlists, but I've run into a problem converting a playlist to M4A audio at 192kbps. Here is what I'm using:

youtube-dl --extract-audio --audio-format m4a --audio-quality 192 --playlist-items 1-26 https://www.youtube.com/playlist?list=PLR3nWwHlZ9WBpi3uWsjSe6r1PiA8MTbnE

The --audio-quality 192 doesn't seem to be registering, even though the syntax seems right as far as I can tell, and when the audio files are downloaded and extracted, they consist of a whole range of different bitrates, from 189 to 254. Can anyone tell me why I might be having this problem?


Solution

  • According to the youtube-dl helpfile, for bitrate, you need to specify the K after 192. Otherwise it treats it as variable bit rate:

    -audio-quality QUALITY Specify ffmpeg/avconv audio quality, insert a value between 0 (better) and 9 (worse) for VBR or a specific bitrate like 128K (default 5)

    See: Post Processing Options in helpfile

    UPDATE BASED ON COMMENT: There are open issues suggesting that ffmpeg does not report all the errors it faces when processing, particularly the mp4 (m4a) codec. See Issue 8230. An alternative format may be a workaround. Another workaround may be changing the system's mp4 codecs such that ffmpeg is happier with them.

    If neither of these workarounds work for you, please post the output of running the command with the --verbose option so that we can see the debug info.

    UPDATED SINCE DOESN'T AFFECT MP3s:

    Since ffmpeg is known to have some mp4 codec issues, another thing you can try is use avconv and avprobe instead of ffmpeg and ffprobe as post-processors for youtube-dl. You can download the latest Windows binaries here: LibAV Windows binaries. Don't forget to add the executables to your PATH system environment variable so that youtube-dl can find them.

    Then add the --prefer-avconv option in your youtube-dl command and see if it behaves better.

    EDIT WITH KNOWN-BUG DETAILS:

    It seems you may have tripped over a previously-missed version of this bug M4a Audio file post-processing skipped - While the developer has addressed the slightly different case in the bug description, it seems to occur in your case as well. It may be worth posting the details to the youtube-dl Github Issue Tracker.

    Switching to a different format (like mp3) may be the only workaround at this point.