当前位置: 首页 > news >正文

ffmpeg-webrtc(metartc)给ffmpeg添加webrtc协议

这个是使用metrtc的库为ffmpeg添加webrtc传输协议,目前国内还有一个这样的开源项目,是杨成立大佬,大师兄他们在做,不过wili页面维护的不好,新手不知道如何使用,我专门对它做过介绍,另一篇博文:ubuntu22.10 ffmpeg-webrtc推拉流srs环境搭建
后者目前还不支持whep(应该在开发中),因此推荐使用metartc的库。
首选它有三个第三方库,先编译这三个库。

版本commit 681b58754e9dd4bcfe79388ea73782705124c65b master

1.metartc6
2.srtp
3.ssl和crypto
4.编译ffmpeg
5.推流命令 WHIP
6.拉流命令 WHEP
7.测试
7.1配置srs
7.1推流
7.3拉流

笔者用的是ubuntu22.04默认gcc/g++是11
在编译srtp时报错,多重定义,其实是编译器版本过高,需要切换版本。

sudo apt-get install gcc-9
sudo apt-get install g++-9
sudo ln -sf /usr/bin/gcc-9 /usr/bin/gcc
sudo ln -sf /usr/bin/g++-9 /usr/bin/g++

1.metartc6,这里有webrtc的传输协议。

cd FFmpeg-n4.3.3/metartc6/metartc6
cd libmetartccore6
mkdir build
cd build
./cmake_x64.sh //x86_64
cp ./libmetartccore6.a ../../

2.srtp

./configure
make -j20
cp libsrt2.a ../

3.openssl

./config
make -j20
cp libcrypto2.a libssl2.a ../

4.编译ffmpeg,注意下面路径改为自己的路径

./configure --enable-libx264 --enable-gpl --extra-libs='-L/home/yqw/temp/ffmpeg-webrtc/FFmpeg-n4.3.3/metartc6 -lmetartccore6 -lpthread -lsrtp2 -lssl -lcrypto -ldl'
make -j20
sudo make install

5.推流命令 WHIP

ffmpeg ......-acodec opus -strict -2 -ar 48000 -f webrtc "url"
srs sample: whip url http://192.168.0.105:1985/rtc/v1/whip/?app=live&stream=livestream
ffmpeg ......-acodec opus -strict -2 -ar 48000 -f webrtc "http://192.168.0.105:1985/rtc/v1/whip/?app=live&stream=livestream"
ffmpeg ......-acodec opus -strict -2 -ar 48000 -f webrtc "webrtc://192.168.0.105:1985/rtc/v1/whip/?app=live&stream=livestream"
./ffmpeg -re -i /path/test.mp4 -vcodec libx264 -acodec opus -strict -2 -ar 48000 -f webrtc "http://192.168.0.105:1985/rtc/v1/whip/?app=live&stream=livestream"

6.拉流命令 WHEP

ffplay "webrtc://whep_url"
srs sample: whep url http://192.168.0.105:1985/rtc/v1/whip-play/?app=live&stream=livestream
ffplay "webrtc://192.168.0.105:1985/rtc/v1/whip-play/?app=live&stream=livestream"

7.测试:
7.1拉取srs代码
srs,版本要求SRS version 5.0.153 or higher, or 6.0.43 or higher。

https://github.com/ossrs/srs

编译srs后运行:

./objs/srs -c conf/https.rtc.conf

7.2推流

ffmpeg -re -i /home/yqw/t/juren-30s.mp4 -vcodec libx264 -acodec opus -strict -2 -ar 48000 -f webrtc "http://192.168.100.77:1985/rtc/v1/whip/?app=live&stream=livestream"

如果不要视频如下:

ffmpeg -re -i /home/yqw/t/west.mp4 -vn -acodec opus -strict -2 -ar 48000 -f webrtc "http://192.168.100.77:1985/rtc/v1/whip/?app=live&stream=livestream"

7.3拉流

ffplay "webrtc://192.168.100.77:1985/rtc/v1/whip-play/?app=live&stream=livestream"

在这里插入图片描述

附录:
libmetartccore2 来自于metaRTC-2.0.120.zip编译
对于2.0 commit 3b7034bbf3a9fbe5682733f0adf11763c75edf28
./ffmpeg -re -i /home/yqw/t/juren-30s.mp4 -vcodec libx264 -acodec opus -strict -2 -ar 48000 -f webrtc “webrtc://192.168.100.77:1985/live/livestream”

./ffplay webrtc://192.168.100.77:1985/live/livestream

http://www.lryc.cn/news/355671.html

相关文章:

  • C语言知识大纲
  • 【必会面试题】synchronized锁升级的过程
  • 设计模式——工厂三兄弟之简单工厂
  • 如何使用ChatGPT撰写短视频爆款文案
  • 申办风景园林设计乙级资质如何整理技术人员的专业培训证明
  • 类别型特征
  • java医院管理系统源码(springboot+vue+mysql)
  • vue2 面试题
  • 【JavaEE精炼宝库】多线程(3)线程安全 | synchronized
  • el-table-column两种方法处理特殊字段,插槽和函数
  • huggingface笔记: accelerate estimate-memory 命令
  • 李飞飞亲自撰文:大模型不存在主观感觉能力,多少亿参数都不行
  • 超级好用的C++实用库之套接字
  • C++ | Leetcode C++题解之第108题将有序数组转换为二叉搜索树
  • 5月27日,每日信息差
  • echart扩展插件词云echarts-wordcloud
  • 解决无法直接抓取链接地址
  • java面对对象编程-多态
  • 【Sql Server】随机查询一条表记录,并重重温回顾下自定义函数的封装和使用
  • 基于C#开发web网页管理系统模板流程-主界面管理员录入和编辑功能完善
  • K8s证书过期处理
  • 刷题之路径总和Ⅲ(leetcode)
  • MongoDB 原子操作:确保数据一致性和完整性的关键
  • 2024上半年软考高级系统架构设计师回顾
  • SQL注入绕过技术深度解析与防御策略
  • Redis教程(十六):Redis的缓存穿透、缓存击穿、缓存雪崩
  • 如何实现一个高效的单向链表逆序输出?
  • 使用 Go 实现 HelloWorld 程序,并分析其结构
  • 机器学习:在Python中sklearn库的使用,纯干货!12个小时的整理!
  • XSS 攻击