RTMP:有没有这样的linux命令行工具?

时间:2022-10-22 14:56:04

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流的linux实用程序。不是flv视频而是MP3流。我想下载的流的位置采用这种格式。

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.

我不想要完整的软件应用程序,如果它通过Shell或其他东西在Linux上运行会很棒。

Thanks all

谢谢大家

3 个解决方案

#1


23  

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

如果您使用RTMP访问编译mplayer或vlc,则应执行以下操作之一。

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

This will generate a ./stream.dump.

这将生成./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.

这将生成./output.mpg。您必须将其解复用以仅提取音频流。

#2


11  

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.

我认为从以前的一些答案开始,景观已经发生了一些变化。至少根据rtmp*页面。 rtmp协议规范似乎是公开使用的。为此,您可以使用2个工具来完成原始海报所要求的内容,rtmpdump和ffmpeg。这是我下载发送音频播客的rtmp流所做的。

step #1 - download the stream

步骤#1 - 下载流

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

我使用工具rtmpdump来实现这一目标。像这样:

% 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

步骤#2 - 将flv文件转换为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.

好的,现在你有了一个流的本地副本file.flv。您可以使用ffmpeg进一步询问文件,也可以仅提取音频部分。

% 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:

从上面的输出我们可以看到file.flv包含一个流,只是音频,它是mp3格式,它是一个单一的通道。要将其解压缩到合适的mp3文件,您可以再次使用ffmpeg:

% 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:

上面的命令会将音频流复制到文件file.mp3中。您也可以将其解压缩到wav文件中,如下所示:

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.

此页面可用于确定如何将flv文件转换为其他格式。

#3


10  

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
  • RTMPDump。示例: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
  • flvstreamer。示例: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:

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

#1


23  

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

如果您使用RTMP访问编译mplayer或vlc,则应执行以下操作之一。

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

This will generate a ./stream.dump.

这将生成./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.

这将生成./output.mpg。您必须将其解复用以仅提取音频流。

#2


11  

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.

我认为从以前的一些答案开始,景观已经发生了一些变化。至少根据rtmp*页面。 rtmp协议规范似乎是公开使用的。为此,您可以使用2个工具来完成原始海报所要求的内容,rtmpdump和ffmpeg。这是我下载发送音频播客的rtmp流所做的。

step #1 - download the stream

步骤#1 - 下载流

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

我使用工具rtmpdump来实现这一目标。像这样:

% 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

步骤#2 - 将flv文件转换为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.

好的,现在你有了一个流的本地副本file.flv。您可以使用ffmpeg进一步询问文件,也可以仅提取音频部分。

% 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:

从上面的输出我们可以看到file.flv包含一个流,只是音频,它是mp3格式,它是一个单一的通道。要将其解压缩到合适的mp3文件,您可以再次使用ffmpeg:

% 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:

上面的命令会将音频流复制到文件file.mp3中。您也可以将其解压缩到wav文件中,如下所示:

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.

此页面可用于确定如何将flv文件转换为其他格式。

#3


10  

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
  • RTMPDump。示例: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
  • flvstreamer。示例: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:

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