Code Monkey home page Code Monkey logo

Comments (18)

maddyblue avatar maddyblue commented on July 23, 2024 1

I would love youtube support. I have already done some work on it: https://github.com/mjibson/moggio/tree/youtube

The difficulty is that we have to extract the audio from a video file. Youtube supports webm files, which are mkv files. There are a few go projects to sort-of decode them. You can see my work off of those in the linked branch. From there we can extract a Vorbis (not Ogg-encapsulated, though) file. However the ogg vorbis decoder that moggio uses is written in C and currently only decodes Ogg Vorbis files. So we'd have to create an ogg vorbis from the vorbis and feed it to that.

The youtube branch is currently missing two parts: 1) the extraction of the actual data bytes of the vorbis file frames (it currently has just one level above that, so I think it's really close), and 2) creating ogg vorbis from vorbis. I don't think either of these are too complicated, but I don't have expertise in this area and it's not obvious to me what the next parts are. I'll try again at some point. But yes, I really want this. Youtube is the only music source I use that moggio doesn't support.

from moggio.

 avatar commented on July 23, 2024

YouTube has DASH audio only streams, why not utilize those? See
"Comparison of YouTube media encoding options" table on this page:

http://wikipedia.org/wiki/YouTube#Quality_and_formats

from moggio.

maddyblue avatar maddyblue commented on July 23, 2024

DASH would be nice. I'm not sure how hard it would be. I don't see any Go packages for it.

from moggio.

 avatar commented on July 23, 2024

I guess I dont understand what Moggio actually does. Wouldnt it be easier just to do something like this:

<iframe src="http://youtube.com/embed/<videoId>?autoplay=1"></iframe>

from moggio.

maddyblue avatar maddyblue commented on July 23, 2024

The moggio web interface is just a controller for the server. You don't need to have a browser open at all to use moggio. The server is what streams and plays the music, and it's all Go.

from moggio.

 avatar commented on July 23, 2024

That still doesnt make sense. YouTube is a streaming site. Sure, there are tool out there to download audio/video from YouTube, but why do that? Why wait for an entire song to download when you could easily stream it using an iframe like above?

from moggio.

maddyblue avatar maddyblue commented on July 23, 2024

iframes are a browser thing. You can use moggio without ever opening a web browser. The browser does not play the music. moggio is a program that streams music to the sound system itself. You can use a browser to tell moggio what do to, but the browser is not the thing streaming the music.

from moggio.

 avatar commented on July 23, 2024

Yeah, but how the hell are you going to steam YouTube? As far as I know the only "API" for this is using an iframe, which yes, requires a browser. Failing that any solution will require fully downloading the file before playing. The only other thing that comes to mind is FFmpeg "http://" protocol, which who knows if that is possible in Golang

from moggio.

maddyblue avatar maddyblue commented on July 23, 2024

Look at my youtube branch and https://godoc.org/github.com/otium/ytdl. You can get a URL, make a web request, then stream the resp.Body into some decoders. moggio already does this with, for example, mp3s hosted on dropbox or google drive. No need to download the whole file first, can just stream and decode as needed.

from moggio.

 avatar commented on July 23, 2024

Ok then. Well if you need help pull DASH URLs, I can do this. I know how to access them, and have code for it in JavaScript already. I could port it to Golang, or send you the algo so you could do it

Check that, it looks like Otium does this already?

best-audio

http://github.com/otium/ytdl#options

from moggio.

maddyblue avatar maddyblue commented on July 23, 2024

The last time I looked at that it wasn't clear to me how to just get a mp3 or vorbis stream. I would love having a Go library that can get me DASH URL if they can indeed provide audio-only streams. Where's your JS library in the mean time?

from moggio.

 avatar commented on July 23, 2024

You might want to drop the idea of MP3/Vorbis sir. YouTube is LARGELY AAC, so you are going to
need an AAC decoder if you dont have it already. Consider this video upload by YouTube themself:

http://youtube.com/watch?v=WeYVLG1bsV0

Here are the available streams:

128k AAC
720p H.264 192k AAC
360p H.264 96k AAC
240p MPEG-4 36k AAC
144p MPEG-4 24k AAC
360p VP8 128k Vorbis
240p H.263 64k MP3
1080p H.264
720p H.264
480p H.264
360p H.264
240p H.264
144p H.264

Notice carefully the only "audio only" stream is:

128k AAC

So if you want to dutifully stick to MP3/Vorbis you will need to stream a
video/audio file, or download a video/audio file and extract the audio. Here is my work, note it is not a library per se, but it could push you in the right direction:

http://github.com/svnpenn/bm/blob/gh-pages/yt-dl.js

from moggio.

maddyblue avatar maddyblue commented on July 23, 2024

I have looked but not found anything I could use to decode AAC from Go, including C libraries. I'm OK using C for AAC decoding for now, but it would need to be a self-contained package like the vorbis package is (https://github.com/mccoyst/vorbis). Hence the desire to use the webm format and extract the vorbis audio out of it, because moggio can decode ogg vorbis already.

from moggio.

 avatar commented on July 23, 2024

I use FDK-AAC library in my FFmpeg builds:

http://github.com/mstorsjo/fdk-aac

It is C++, but might work for your needs?

from moggio.

maddyblue avatar maddyblue commented on July 23, 2024

Yes, that may work. Will experiment.

from moggio.

JalonSolov avatar JalonSolov commented on July 23, 2024

https://github.com/Comcast/gaad

from moggio.

mvpmvh avatar mvpmvh commented on July 23, 2024

I'm looking to do exactly what this repo is doing: building a go-only media player. I specifically want to build a media player that streams audio directly from YouTube. Is your branch workable? Did you end up finding another workable solution?

from moggio.

maddyblue avatar maddyblue commented on July 23, 2024

I was never able to stream audio from youtube, but it's been years since I've tried. If I were to try again today I'd look into the youtube music API (well, the unofficial API), probably starting with the python project.

from moggio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.