Record Live Streaming Radio to MP3

Sometime you want to record Live Radio Stream to MP3 file, you can find many online linux tools for recording radio stream to server and then download to your local computer.

You can use Linux “wget” or “curl”

CURL

# curl -sS -o stream.mp3 –max-time 150 http://Radio-Server:Port/stream
Bitrate: 128 kb/s [it will make approx 2MB MP3 file]

# curl -sS -o stream.mp3 –max-time 150 http://Radio-Server:Port/stream
Bitrate: 64 kb/s [it will make approx 1MB MP3 file]

FFMPEG

# ffmpeg -y -i http://Radio-Server:Port/stream stream.mp3

# ffmpeg -i http://Radio-Server:Port/stream -t 00:00:40 -acodec copy stream.mp3
[It will record MP3 file stream.mp3 of duration of 40 sec with same Radio Stream Codec Info & Bitrate]

MPLAYER & LAME

# mplayer ‘http://Radio-Server:Port/stream’ -endpos ’00:01:00′ -vo null -ao pcm:waveheader:file=stream.wav &> /dev/null
# lame stream.wav stream.mp3 &> /dev/null

WGET

# wget -O stream.mp3 “http://Radio-Server:Port/stream”

VLC is not supposed to be run as root. Sorry

Today I need to install VLC Media player on CentOS 5.x to capture remote live event from VLC client as HTTP stream.

So, I have installed that using # yum install vlc

But VLC can not be run as root privileged user 🙁

# vlc
VLC is not supposed to be run as root. Sorry.
If you need to use real-time priorities and/or privileged TCP ports
you can use vlc-wrapper (make sure it is Set-UID root first and
cannot be run by non-trusted users first).

To run VLC from command line we need to edit VLC file located below
# vi /usr/bin/vlc

To edit “/usr/bin/vlc” search for geteuid and replace it with getppid using vi editor’s command

:%s/geteuid/getppid/ (here geteuid is search term and getppid is replace one)

If we still face issues with stream capture, we can use mplayer 😉

# mplayer http://stream_link -dumpstream -dumpfile outFileName

The trouble with doing something right the first time is that nobody appreciates how difficult it was.

 

How to check RTMP source stream is live or not?

RTMP Source Check RTMP Source RTMP Live Stream

Dear Friends,
You can check RTMP Source is live or not using socket programming, but that will not give you exact output. Today I have tried Linux utility “rtmpdump” to test & check RTMP Source it produced quite interesting results on command line….

# rtmpdump -v -r rtmp://giraldatvlivefs.fplive.net/giraldatvlive-live/stream001 -o /tmp/rtmp-checker.log

RTMP Output
<?php

/* 
 * 
 * RTMPChecker - by S V N L A B S () (www.svnlabs.com/blogs)
 * You can use and modify this code as long as the above reference to me still exists 😉
 * 
 */

if(isset($_REQUEST['stream']) && $_REQUEST['stream']!="")
{

  exec("/usr/bin/rtmpdump -V  -v -r '".$_REQUEST['stream']."' -o /tmp/rtmp-checker.log 2>&1", $pp);
  echo implode("<br>", $pp);

}


?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Check RTMP is live or not?</title>
</head>
<body>

<form name="rtmp" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="text" name="stream" value="rtmp://164.100.49.14:80/live/dd2" /><br />
<input type="submit" name="check" value="check" />
</form>

</body>
</html>

Output may be…

Night is longer than day for those who dream & Day is longer than nights for those who MAKE their DREAMS come true…

Couldn’t find video filter ‘x264’

X264
X264

x264 is a free software library for encoding video streams into the H.264/MPEG-4 AVC format. It is released under the terms of the GNU General Public License.

x264 itself provides a command line interface as well as a library-level interface.

x264 is used to encode video files in mp4, m4v, h.264 (HD) output format.

Install x264
------------

*  Download the latest snapshot(tarball) here:
# wget ftp://ftp.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20090113-2245.tar.bz2

* Extract tarball
# bzip2 -cd x264-snapshot-20090113-2245.tar.bz2 | tar xvf -
# cd x264-snapshot-20090113-2245

* Build and install
# ./configure
# make
# make install

Some problems with mplayer & x264

Install/compile mplayer with x264 support

-x264encopts is not an MEncoder option
Checking for x264 ... no (in libavcodec: no)   (./configure)

# svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer

# cd /usr/local/src/mplayer

# svn update

# ./configure

After configure make sure you got

Checking for x264 ... yes (in libavcodec: yes)

# make && make install

Try latest version of video tools ffmpeg, mplayer, mencoder, flvtool2, mediainfo  🙂

Find correct path where you installed these components try …..

# locate command

“make sure you are using /usr/bin/mencode and NOT /usr/lib/bin/mencode”

🙂