rtmp streaming without a browser!
A simple bash script! …
Flash video is 'obsolete' now that HTML5 has arrived! :up:
Unfortunately, there are still tons of legacy sites out there that didn't get the memo! :awww:. Now you can still use the Adobe Flash browser plugin to watch/listen to these sites, however, there are many good reasons why you might not want to do that. Firstly, the Flash plugin is a memory whore! It is very inefficient both with it's hoggish use of memory, as well as it's poor video rendering and cpu usage! :irked:. Secondly, if you're listening to a streaming audio, radio station, you might want to close your browser while continuing with off-line work! :sherlock:.
Now, vlc can play flash video files and work is currently underway to support direct streaming of rtmp video streams. Unfortunately, this work has not yet been completed. :awww:.
So, trying to find a way to stream Radio Al Ansaar in the background, I did some investigation! :idea:.
Like I said, vlc can't access a rtmp stream, yet! :sherlock:, But, by perusing the source code for the Al Ansaar streaming page, I was able to determine the correct rtmp url.
Google eventual led me to flvstreamer, which is available in the Debian repositories!
My first attempt with flvstreamer was,
~$ flvstreamer -r rtmp://22.214.171.124/alansaar
Which threw up an error message. The url was not quite complete.
The corrected code was as follows!
~$ flvstreamer -r rtmp://126.96.36.199/alansaar --playpath alansaar.stream
Better, this opened the stream and started outputting to stdout! :eyes:.
Outputting a video stream to stdout results in tons of giberish being displayed on your terminal's screen!!! :insane:.
But now I knew that it worked! :hat:.
The next test was to pipe this output to a file!
~$ flvstreamer -r rtmp://188.8.131.52/alansaar --playpath alansaar.stream > test.audio
~$ flvstreamer -r rtmp://184.108.40.206/alansaar –playpath alansaar.stream > test.audio
(c) 2010 Andrej Stepanchuk, Howard Chu, The Flvstreamer Team; license: GPL
Starting download at: 0.000 kB
118.256 kB / 28.65 sec[/code]
No more giberish on-screen! :yes:. And the file, test.audio played when opened by vlc! :happy:.
So now I thought I knew what I was doing, so I tried this! :rolleyes:.
~$ flvstreamer -r rtmp://220.127.116.11/alansaar --playpath alansaar.stream > vlc
That didn't work because vlc needs a significant portion of input before it k nows what to do with it! :irked:.
By now you've either stopped reading, fallen asleep, or you're as much of a geek as I am! :p.
Long story short, I eventually deriveed a bash script that works! :hat:.
It's primitive, but it uses vlc to play Radio Al Ansaar in the background, without a browser! :happy:.
:sst:, note that this script can be adapted to play video streams or even play/save flash videos to your computer! :whistle:.
here it is:
# a simple 'play that rtmp' stream script # currently, to stop flvstreamer, you need to issue the command 'killall flvstreamer' from the command line # any neater solution to this would be welcome! # first, open rtmp url with flvstreamer flvstreamer -r rtmp://18.104.22.168/alansaar --playpath alansaar.stream > 0001.tmp & # add delay to allow time for buffer.tmp to get some data sleep 5 # open vlc to play stream from buffer.tmp vlc -q --quiet-synchro --no-video 0001.tmp & # delete the buffer file. It will now become a 'magic' invisible pipe! # this is dirty programming, yet it's the only way I could find to do this sleep 5 rm 0001.tmp &
Copy this to a new file. (called alansaar.sh or whatever you choose)
Set the permissions to, 'Allow Execution'
Click on the file! (or double click, depending on how your system is setup!)
You need both flvstreamer and vlc installed to use this script. (you can modify the script to use any other media player that will play the flash video/audio file)
Happy listening! :hat:!