perl: URI::rtsp 是用来处理RTSP协议的的URI的模块。

安装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

参阅:基于FFmpeg进行rtsp推流及拉流(详细教程)


在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;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值