关于rtp推流的一些事情

【版权申明】转载请附上出处链接

关于rtp推流的一些事情

使用ffmpeg推流一个mp4文件

$ffmpeg.exe -re -i in.mp4 -c:v copy -c:a copy -f rtp rtp://192.168.3.34:5004

[rtp @ 0000017a4a5c0500] Only one stream supported in the RTP muxer
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument

出错解析:
上面的ffmpeg命令创建了两个流(mp4中有video也有audio),一个流是video,一个流是audio,而rtp只能推送一个流,所以出现了上面的错误。

使用如下命令即可:

# 推两路流
$ffmpeg.exe -re -i in.mp4 -c:v copy -an -f rtp rtp://192.168.3.34:5004 -vn -acodec copy -f rtp rtp://192.168.3.34:5006

# 只推音频流
$ffmpeg.exe -re -i in.mp4 -vn -acodec copy -f rtp rtp://192.168.3.34:5006

# 只推视频流
$ffmpeg.exe -re -i in.mp4 -c:v copy -an -f rtp rtp://192.168.3.34:5004

最终的sdp文件:

v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
c=IN IP4 192.168.3.34
t=0 0
a=tool:libavformat 58.29.100

m=video 5004 RTP/AVP 96
b=AS:6851
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1; sprop-parameter-sets=Z2QAM6zZQDwAQ+wEQAAAAwBAAAAMA8YMZYA=,aOvssiw=; profile-level-id=640033

m=audio 5006 RTP/AVP 97
b=AS:195
a=rtpmap:97 MPEG4-GENERIC/48000/2
a=fmtp:97 profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3; config=119056E500

遇到的问题:

  1. 当时ffplay打开一个rtp流报错;
$ffplay.exe rtp://192.168.3.34:5006

[rtp @ 000002b14f04c1c0] Unable to receive RTP payload type 97 without an SDP file describing it
Input #0, rtp, from 'rtp://192.168.3.34:5006':
  Duration: N/A, bitrate: N/A
Failed to open file 'rtp://192.168.3.34:5006' or configure filtergraph

当我们的ffmpeg传递的是rtp的新类型(即动态类型),没办法直接使用命令来播放rtp流,而需要使用sdp文件。

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

安河桥

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值