安装rtsp服务器,可以从 rtsp-simple-server下载 mediamtx_v1.8.3_windows_amd64.zip
和 源代码包 mediamtx-1.8.3.zip
注意:在 FFmpeg 推流之前先运行 rtsp-simple-server
cd D:\VIDEO\mediamtx_v1.8.3_windows_amd64
运行 mediamtx.exe
3.1 UDP推流
ffmpeg -re -i input.mp4 -c copy -f rtsp rtsp://127.0.0.1:8554/stream
3.2 TCP推流
ffmpeg -re -i input.mp4 -c copy -rtsp_transport tcp -f rtsp rtsp://127.0.0.1:8554/stream
3.3 循环推流
ffmpeg -re -stream_loop -1 -i input.mp4 -c copy -f rtsp rtsp://127.0.0.1:8554/stream
4.1 ffplay/VLC 拉流显示
ffplay rtsp://127.0.0.1:8554/stream
在Perl中,URI::rtsp 是用来处理RTSP(Real Time Streaming Protocol,实时流协议)的URI的模块。
以下是一些使用 URI::rtsp 的方法:
1.创建一个RTSP URI
use URI::rtsp;
my $uri = URI::rtsp->new("rtsp://user:password\@host:port/path?query");
print $uri->as_string, "\n";
2.解析RTSP URI
use URI::rtsp;
my $uri = URI::rtsp->new("rtsp://user:password\@host:port/path?query");
print "scheme: ", $uri->scheme, "\n";
print "userinfo: ", $uri->userinfo, "\n";
print "host: ", $uri->host, "\n";
print "port: ", $uri->port, "\n";
print "path: ", $uri->path, "\n";
print "query: ", $uri->query, "\n";
3.修改RTSP URI的某一部分
use URI::rtsp;
my $uri = URI::rtsp->new("rtsp://user:password\@host:port/path?query");
$uri->user("newuser");
$uri->password("newpassword");
$uri->host("newhost");
$uri->port(554);
$uri->path("/newpath");
$uri->query("newquery");
print $uri->as_string, "\n";
4.在RTSP URI 上添加和删除查询参数
use URI::rtsp;
my $uri = URI::rtsp->new("rtsp://host/path?query");
$uri->query_form(
action => 'play',
range => 'clock=12345-'
);
print $uri->as_string, "\n";
$uri->query_param_remove('range');
print $uri->as_string, "\n";
以上就是一些使用 URI::rtsp 的基本方法。
注意:以上代码可能无法在某些旧版本的Perl中运行,因为它们可能没有预装 URI::rtsp 模块。如果是这种情况,你可能需要先安装该模块,可以使用CPAN模块来安装它。
运行 cpan
install URI::rtsp
下载安装 OALDERS/URI-5.28.tar.gz
查找 D:\Strawberry\perl\site\lib\URI\rtsp.pm
package URI::rtsp;
use strict;
use warnings;
our $VERSION = '5.28';
use parent 'URI::http';
sub default_port { 554 }
1;
1189

被折叠的 条评论
为什么被折叠?



