Comments (18)
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.
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.
DASH would be nice. I'm not sure how hard it would be. I don't see any Go packages for it.
from moggio.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Yes, that may work. Will experiment.
from moggio.
https://github.com/Comcast/gaad
from moggio.
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.
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)
- support multi disc albums well
- Add link to website HOT 2
- Dependency broken in go1.6: github.com/gordonklaus/portaudio HOT 3
- stream: support M3U playlists
- album titles with / breaks stuff
- Consider using electron
- iTunes library as a source HOT 3
- libVLC as a Media Decoder HOT 2
- Reduce memory footprint HOT 2
- try out https://godoc.org/github.com/cznic/cc#Parse HOT 4
- Scrobbling? HOT 1
- Message too big HOT 4
- make pause also play when nothing playing yet
- Audible pop on play/pause/skip and volume changes HOT 1
- Scrollbar Visibility Issue
- Add command options to specify "file" source on start
- Create native client HOT 1
- The license should be GPL? HOT 1
- warning: ‘void* __builtin_memcpy(void*, const void*, long unsigned int)’ reading 32 bytes from a region of size 16 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from moggio.