MattJeanes / YouTubeDL

.NET Core app for downloading and streaming YouTube videos as audio
8 stars 2 forks source link

mp3 support (feature request) #66

Closed Aws0mee closed 1 year ago

Aws0mee commented 1 year ago

Hey, I have really been enjoying your project so far, but I was wondering if you would be open to adding a new feature. I need a way to return an mp3 url to a youtube video and I cannot seem to find any other working apis. I tried using another api along with yours to convert to an mp3, but that doesn't seem to work either. Is there any chance you could add a feature to support mp3s? I would really appreciate it. :)

MattJeanes commented 1 year ago

Hey, as luck would have it the YouTubeExplode library I'm using supports automatic transcoding to any format ffmpeg supports!

I've added support for this into the app and you can now transcode by specifying the environment variable TranscodeFormat which can be e.g. mp3, ogg, etc and this is in main branch / latest docker image now!

Note that it must download the stream fully and then transcode with ffmpeg so if you use this it will take a bit longer to start streaming, leaving the value unset as is the default will use the previous behaviour of directly streaming the mp4 audio stream straight from YouTube.

Let me know what you think! Hopefully this is what you are looking for 🙂

Aws0mee commented 1 year ago

Hey, thank you for the feature addition and quick response. I really appreciate it! Would it be possible to add the encoding type as a url parameter? That way we could more easily request whatever filetype we want.

MattJeanes commented 1 year ago

Sure, that'll be an easy addition. I'll do that tomorrow 🙂

MattJeanes commented 1 year ago

Okay, all done - you must now supply the AllowUserTranscode = true environment variable which will allow users to use for example /play?id=abc123&format=mp3

MattJeanes commented 1 year ago

Note that you no longer need to set the TranscodeFormat environment variable if you don't want to transcode by default without any URL parameter set 🙂