RTMP: Is there such a linux command line tool?

此生再无相见时 提交于 2019-12-03 02:46:30

问题


I have looked everywhere to find a linux utility that will allow me to download rtmp streams. Not flv video but MP3 streams. The location of the streams I want to download are in this format.

rtmp://live.site.com/loc/45/std_fc74a6b7f79c70a5f60.mp3

Anyone know of such a command line tool? Or even anything close to what I am asking for?

I do not want full software applications and it would be great if it worked on Linux via Shell or something.

Thanks all


回答1:


One of the following should do, if you have mplayer or vlc compiled with RTMP access.

mplayer -dumpstream rtmp://live.site.com/loc/45/std_fc74a6b7f79c70a5f60.mp3

This will generate a ./stream.dump.

vlc -I dummy rtmp://live.site.com/loc/45/std_fc74a6b7f79c70a5f60.mp3 \
    --sout file/ts:output.mpg vlc://quit

This will generate a ./output.mpg. You'll have to demux it to extract just the audio stream out.




回答2:


I think the landscape has changed a bit since the time of some of the previous answers. At least according to the rtmp wikipedia page. It would appear that the rtmp protocol specification is open for public use. To that end you can use 2 tools to accomplish what the original poster was asking, rtmpdump and ffmpeg. Here's what I did to download a rtmp stream that was sending an audio podcast.

step #1 - download the stream

I used the tool rtmpdump to accomplish this. Like so:

% rtmpdump -r rtmp://url/to/some/file.mp3 -o /path/to/file.flv
RTMPDump v2.3
(c) 2010 Andrej Stepanchuk, Howard Chu, The Flvstreamer Team; license: GPL
Connecting ...
INFO: Connected...
Starting download at: 0.000 kB
28358.553 kB / 3561.61 sec
Download complete

step #2 - convert the flv file to mp3

OK, so now you've got a local copy of the stream, file.flv. You can use ffmpeg to interrogate the file further and also to extract just the audio portion.

% ffmpeg -i file.flv
....
[flv @ 0x25f6670]max_analyze_duration reached
[flv @ 0x25f6670]Estimating duration from bitrate, this may be inaccurate
Input #0, flv, from 'file.flv':
  Duration: 00:59:21.61, start: 0.000000, bitrate: 64 kb/s
    Stream #0.0: Audio: mp3, 44100 Hz, 1 channels, s16, 64 kb/s

From the above output we can see that the file.flv contains a single stream, just audio, and it's in mp3 format, and it's a single channel. To extract it to a proper mp3 file you can use ffmpeg again:

% ffmpeg -i file.flv -vn -acodec copy file.mp3
....
[flv @ 0x22a6670]max_analyze_duration reached
[flv @ 0x22a6670]Estimating duration from bitrate, this may be inaccurate
Input #0, flv, from 'file.flv':
 Duration: 00:59:21.61, start: 0.000000, bitrate: 64 kb/s
    Stream #0.0: Audio: mp3, 44100 Hz, 1 channels, s16, 64 kb/s
Output #0, mp3, to 'file.mp3':
  Metadata:
    TSSE            : Lavf52.64.2
    Stream #0.0: Audio: libmp3lame, 44100 Hz, 1 channels, 64 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
Press [q] to stop encoding
size=   27826kB time=3561.66 bitrate=  64.0kbits/s    
video:0kB audio:27826kB global headers:0kB muxing overhead 0.000116%

The above command will copy the audio stream into a file, file.mp3. You could also have extracted it to a wav file like so:

ffmpeg -i file.flv -vn -acodec pcm_s16le -ar 44100 -ac 2 file.wav

This page was useful in determining how to convert the flv file to other formats.




回答3:


This question is old but this can help to another users with this doubt.
To download directly, without any conversion, there is two options (the author of both programs is the same and the behavior is the same):

  • RTMPDump. Example: rtmpdump -r "rtmp://host.com/dir/file.flv" -o filename.flv
  • flvstreamer. Example: flvstreamer -r "rtmp://od.flash.plus.es/ondemand/14314/plus/plustv/PO770632.flv" -o salida.flv

And if you want download and convert the video at same time, the best way is use ffmpeg:

ffmpeg -i rtmp://server/live/streamName -acodec copy -vcodec copy dump.mp4


来源:https://stackoverflow.com/questions/1024632/rtmp-is-there-such-a-linux-command-line-tool

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!