metaRTC集成到ffmpeg实现srs的webrtc推拉流

概述

ffmpeg是音视频界的瑞士军刀,功能比较全面,但是音视频界最重量级的webrtc却不支持,metaRTC新版本支持静态编译集成到ffmpeg,实现ffmpeg的webrtc推拉流,助力ffmpeg进入webrtc新时代。

下载源码

https://github.com/metartc/metaRTC/releases/tag/2.0.120https://github.com/metartc/metaRTC/releases/tag/2.0.102https://gitee.com/metartc/metaRTC/releases/2.0.120https://gitee.com/metartc/metaRTC/releases/2.0.102

GitHub - metartc/ffmpeg-metartc: 集成到ffmpeg的metaRTC集成到ffmpeg的metaRTC. Contribute to metartc/ffmpeg-metartc development by creating an account on GitHub.https://github.com/metartc/ffmpeg-metartcffmpeg-metartc: 集成到ffmpeg里的metaRTChttps://gitee.com/metartc/ffmpeg-metartc

编译

拉流集成参考

metaRTC集成到ffmpeg实现srs的webrtc拉流播放_m0_56595685的博客-CSDN博客

将编译好的文件放到metartc2目录下

 

 ./configure --enable-libx264 --enable-gpl --extra-libs='-L/path/metartc2 -lmetartccore2 -lspeexdsp -lpthread -lsrtp2 -lssl -lcrypto -ldl'
make
sudo make install

编译后执行推流命令

ffmpeg ......-acodec opus -strict -2 -ar 48000 -f webrtc webrtc://192.168.0.1/live/livestream

集成说明

实现了webrtc的muxer和protocol

增加了x264的支持,修改ffmpeg.c文件,开发者可以在此增加其他编码的支持。

		if(ost->enc_ctx->codec_id==AV_CODEC_ID_H264&&memcmp(oc->ctx->filename,"webrtc",6)==0){
			 ost->enc_ctx->pix_fmt = AV_PIX_FMT_YUV420P;
			  av_dict_set(&ost->encoder_opts, "preset", "superfast", 0);
			  av_dict_set(&ost->encoder_opts, "tune", "zerolatency", 0);
			  av_dict_set(&ost->encoder_opts, "profile", "baseline", 0);
			
        	  ost->enc_ctx->profile = FF_PROFILE_H264_CONSTRAINED_BASELINE;//:FF_PROFILE_HEVC_MAIN;
        	  ost->enc_ctx->level=31;
        	  ost->enc_ctx->max_b_frames=0;
			  ost->enc_ctx->has_b_frames=0;		
        }

srs服务器

推荐Srs4.0,下载编译参考http://github.com/ossrs/srs#usage​   

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

猜你喜欢

转载自blog.csdn.net/m0_56595685/article/details/122642347