Search code examples
cronhttp-live-streaming

Downloading a .flv stream


I am trying to setup a cronjob that will run everyday at a specific time and record an .flv audio stream for an hour and then save the file and quit recording.

I know of a lot of rtmp tools to download such things, but I am unsure if the stream actually is rtmp as using the rtmp protocol in players such as VLC do not work.

In VLC I can play:

http://live.leanstream.co/CKBTFM?type=.flv&playertype=socast1

I however cannot play:

rtmp://live.leanstream.co/CKBTFM?type=.flv&playertype=socast1

How do I discover what kind of protocol is being used for this stream so that I can find the correct tool.

Edit: It looks like I can actually change the URL so that it gives me a different format such as .mp3:

http://live.leanstream.co/CKBTFM?type=.mp3

When trying to use tools such as Streamripper or wget I am receiving 404 errors which doesn't make sense as I can listen to the streams from my browser and vlc:

$ wget -O stream.mp3 "http://live.leanstream.co/CKBTFM?type=.mp3"
--2015-06-24 13:58:23--  http://live.leanstream.co/CKBTFM?type=.mp3
Resolving live.leanstream.co (live.leanstream.co)... 199.168.112.72
Connecting to live.leanstream.co (live.leanstream.co)|199.168.112.72|:80... connected.
HTTP request sent, awaiting response... 404 Not Available
2015-06-24 13:58:24 ERROR 404: Not Available.

Solution

  • You can use ffmpeg without worrying too much about the protocols and formats since it has an auto-detection feature.

    ffmpeg -i "http://live.leanstream.co/CKBTFM?type=.flv&playertype=socast1" -t 3600 -f flv out.flv
    

    where -t 3600 is the 1 hour time limit.

    If you only need to fetch information about the stream you can use ffprobe.

    https://www.ffmpeg.org/