wader / ydls

youtube-dl HTTP download and transcode service
https://hub.docker.com/r/mwader/ydls/
MIT License
185 stars 24 forks source link

feature: Specify bitrate #25

Open JasonLocklin opened 4 years ago

JasonLocklin commented 4 years ago

Specific use-case: When downloading voice audio (such as podcasts or lectures) from Youtube over limited data plans, it would be great to be able to specify a very low bitrate in combination with the opus codec.

Feature request: A bitrate option in the parameters that is passed ffmpeg.

Workaround: Would adding parameters to either OutputFlags or FormatFlags in ydls.json work? For a 25kbps example, Youtube-dl would be --audio-quality 25K and for ffmpeg, -b 25k --mode mono.

wader commented 4 years ago

Hey! yes good idea. I've thought about adding support for some kind of named presets which could be used for things like this. Otherwise i guess having a specific option for audio/video bitrate would work, e.g. something like a128kbps or 128kabr for 128kbps audio bitrate. But i wonder if ydls still should try to get the high quality source format?

Yes that workaround should work i think. For example you could add an additional format something like:

...
    "ogglow": {
      "Formats": [
        "ogg"
      ],
      "Streams": [
        {
          "Specifier": "a:0",
          "Codecs": [
            {
              "Name": "opus",
              "FormatFlags": [
                "-b:a",
                "25k"
              ]
            }
          ]
        }
      ],
      "Ext": "ogg",
      "MIMEType": "audio/ogg"
    },
...

But note that the bitrate flags will only be used if transcode is needed, you could combine with the "retranscode" option i guess. A bit messy so something better would be nice.

Let me know if it works. This would still download the "best" source format sorted by codec and bitrate but i guess in most cases it's the output from ydls that you want to limit.

JasonLocklin commented 4 years ago

Thanks! I will give it a shot later and update.

edit: yes, I think it should always start with the high-quality format. Transcoding from one lower bitrate codec to a second, different low-bitrate codec would be a recipe for artifacts and degraded audio quality.