Stream youtube sound via Ruby? - ruby

I'm trying to build a music player/playlist maker with Ruby and TK. I still haven't figured out a way to stream the youtube video (actually only the sound) I don't want to download and then play the song, cause that would take too long. And I couldn't find any information regarding streaming directly without some kind of embedded player.
Does anyone know how I could best tackle this?

Seems to be an intersting project, so I searched a little. From this reddit post: Tip: Use mpv + youtube-dl as streaming audio player there's this code using the mpv program to stream audio:
mpv "https://www.youtube.com/watch?v=sVK5Z6wnMxg" --no-video
That URL is a livestream of the Bonaroo music festical that's currently happening. I tried it and it does start the audio. Under the hood this is using youtube-dl which has this note in the man page:
How do I stream directly to media player?
You will first need to tell youtube-dl to stream
media to stdout with -o -, and also tell your me‐
dia player to read from stdin (it must be capable
of this for streaming) and then pipe former to
latter. For example, streaming to vlc
(http://www.videolan.org/) can be achieved with:
youtube-dl -o - "http://www.youtube.com/watch?v=BaW_jenozKcj" | vlc -
So if you wanted to pass the stream to a different media player, that would be a good place to start.
In terms of Ruby; well, this isn't really a Ruby solution per se, and you'd simply call the shell program from Ruby using backticks, system, Process.spawn, fork, etc.

Related

Stream live audio device with VLC from the command line

I need a way to stream live audio over HTTP with VLC from the command line. I've been able to do this with the GUI, but it's inefficient, and I was hoping I could do the same thing with a shell script. I've looked at VLC's wiki and guides, but there has been nothing about streaming audio live from a device. Any help would be much appreciated! Thanks!

Media Foundation Encoder MF_E_TRANSCODE_NO_MATCHING_ENCODER

I am trying to convert from wmv to mp4.
First of do I need to implement my IMFTransform to do this ?
Do i need to convert the video to MFVideoFormat_I420 ?
As far as I know if you create the topology correctly this should be handled automatically.
So I created my profile showed in the
http://msdn.microsoft.com/en-us/library/windows/desktop/ff819476%28v=vs.85%29.aspx
but i get a MF_E_TRANSCODE_NO_MATCHING_ENCODER.
I have windows 7 so, i should have the encoder.
Also Does anyone know where the source code for that tutorial is. It is not under SDK samples.
Thanks.
You don't show code - noone knows what is wrong.
Take a look at this transcoding sample, which comes with source code and does exactly what you are trying to do: transcoding from ASF into MP4.
http://blogs.msdn.com/b/mf/archive/2009/12/02/mfsimpleencode.aspx
MFSimpleEncode.exe - This is a command line tool that transcodes files
from one media format to another. The source code is provided to use
as a reference if you write your own transcode application. This tool
uses the Media Foundation transcode API, which was introduced in
Windows 7.
Examples:
Transcode ASF to MPEG-4:
MFSimpleencode.exe –i Input.wmv –o output.mp4 –p TranscodeProfileMPEG4.xml

playing mp3 files in firefox

Can anyone suggest me webplayer which can play MP3 files in Firefox browser?
I tried jPlayer, however it needs ogg files. I tried converting MP3 to OGA using FFMPEG, however, even the generated file is not being played in JPlayer.
Is there any alternate player which can play MP3 files in Firefox.
I don't want to use Flash.
..alternate player which can play MP3 files in Firefox.
Combine these 3 for an answer.
Java Sound for the ability to play audio.
The MP3 plug-in SPI of JMF, to supply support for MP3, which Java Sound does not support by default.
Applet - to embed that ability in a web page.
Note
I am pretty sure there are easy ways to embed sound in web pages that does not require Java, or requires plug-ins that have higher usage (like Flash). If there is not something custom you wish to do, I recommend investigating alternatives.

FFMPEG command to combine a WAV file and a video file?

I use Qt & OpenCV to record video and QAudioInput to record audio into wav format. I want to combine them into one video file. How can I accomplish this? I have researched so much but I can't seem to find a command to accomplish this.
I use both Windows and Mac.
FYI, this operation seems to be accomplished through the cmd-line in this thread. This approach may turn into an easy hack since you can call this command using system().
But if you still want to do it programatically, I suggest you take a look at Dranger's FFmpeg tutorials. It provides 8 interesting tutorials that shows how to do simple stuff, from taking snapshots of a video to more complex stuffs like writing a simple video player with audio/video sync.
These tutorials teach how to work independently with audio and video streams, which is what you need to do: read the audio stream from the WAV file and then insert it as the audio stream of a video file.
Maybe not directly related to what you are aim for, but this answer demonstrates how to use FFmpeg to retrieve the audio stream of one file and play it with SDL, while simultaneously using OpenCV to retrieve video frames and display them in a SDL window.

How can I playback an audio stream from a Icecast on WP7

How can I playback an audio stream from a Icecast on WP7
I have tried SMF, SmoothStreaming Client and the MediaElement.
None of these have worked. The formats are either asx or and wma.
Edit:
Recently I found a new stream. this stream works when I'm in the designer. But it does not work on the device. On the device the stream is opened and closed immediately.
this stream is from an IceCast server in MP3 format. with a ?.mp3 extention. or without.
When you are streaming live radio, the stream may be encoded by an IceCast server or ShoutCast server. To read these streams, you will need to decode the stream in memomry and pass it to the MediaElement once it has been decoded.
have a look at Mp3MediaStreamSource
and Audio output from Silverlight
I lost tons of time on this, and this is the best solution I found so far.
Having had a quick look at the Icecast web site (I'm not familiar with their service) it seems that most of what they offer for streamed audio is offered in MP3 format, but that they provide this as playlists in either M3U or XSPF format. You can't provide this to any of the built-in controls or classes in the WP7 framework, but you can parse the contents of the file and pass that to a MediaElement to play individual files.
The M3U file is a simple list of the consituent URLs, so is the simplest to deal with, but the XSPF format (which is an XML format) provides more information, such as the title. You can easily use the XDocument class to parse the XSPF file and then use LINQ to query the contents.
You're not adding the ?.mp3 to the pls file right, to the embedded URL? IF you are using the URL you get from the PLS/M3U file, you might need to append a file extension to it. You can often do this by adding ?ext=.mp3 or ?file.mp3 to the URL and it should play with MediaElement, as I read on the MS dev boards that people had been getting that to work with Shoutcast streams.
Does your stream work on the device when you unplug it from the computer? Media playing doesn't work while you're plugged into the Zune sync center.
Chris

Resources