metartc / ffmpeg-webrtc

ffmpeg-webrtc for whip and whep protocol
Apache License 2.0
61 stars 13 forks source link

FFmpeg-Webrtc Ubuntu 20.04编译补充 #16

Open zou493451860 opened 8 months ago

zou493451860 commented 8 months ago
FFmpeg-Webrtc Ubuntu编译
1、首先编译metartc相关包
    cd ffmpeg-webrtc/FFmpeg-n4.3.3/metartc6/metartc6

    cd libmetartccore6

    # cmake_x64会自动创建build文件夹
    ./cmake_x64.sh

    # 把编译成功的 libmetartccore6.a 复制到metartc6文件夹下
    cp ./libmetartccore6.a FFmpeg-n4.3.3/metartc6

    # Requires ffmpeg to be configured with --enable-gpl --enable-libx264
    sudo apt-get install libx264-dev

2、解压libsrtp-2-fit.tar.gz、openssl-1.1-fit.tar.gz并进行编译
    cd ffmpeg-webrtc/FFmpeg-n4.3.3/metartc6

    # 编译 srtp2
    tar zxvf libsrtp-2-fit.tar.gz
    cd libsrtp-2-fit/
    ./configure 
    make
    cp libsrtp2.a FFmpeg-n4.3.3/metartc6

    # 编译openssl
    tar zxvf openssl-1.1-fit.tar.gz
    cd openssl-1.1-fit/
    ./config
    make
    cp libcrypto.a libssl.a FFmpeg-n4.3.3/metartc6

3、编译FFmpeg-webrtc    
    ./configure --enable-libx264 --enable-gpl --enable-cross-compile --extra-libs='-L/home/user/ffmpeg-webrtc/FFmpeg-n4.3.3/metartc6 -lmetartccore6 -lpthread -lsrtp2 -lssl -lcrypto -ldl'
    make -j8

    # 编译期间会报很多错误,可以不用理会
    make install

4、目前测试结果
    1)ffplay 没有,可能是少包了,或者编译FFmpeg-webrtc时./configure中没有启用相关配置
    2)使用whip推流到SRS流媒体服务器,但是拉流失败!目前暂未找到原因

    3)把RTMP流推送到SRS,SRS把RTMP转成RTC,使用FFmpeg-webrtc whep拉流,成功实现延迟1秒左右
FFmpeg-Webrtc拉取 whep命令示例
# SRS的whep地址是:http://127.0.0.1:1985/rtc/v1/whep/?app=live&stream=livestream
ffmpeg -i 'webrtc://127.0.0.1:1985/rtc/v1/whep/?app=live&stream=livestream' -vcodec rawvideo -pix_fmt yuv420p -f v4l2 /dev/video30

ffmpeg -i 'webrtc://127.0.0.1:1985/rtc/v1/whip-play/?app=live&stream=livestream' -vcodec rawvideo -pix_fmt yuv420p -f v4l2 /dev/video30
增加ffplay、pulse配置 -》 编译FFmpeg-webrtc

我把Get the Dependencies建议的包都给安装了

# opus 配置
    sudo apt-get install libopus-dev

# 编译FFmpeg-Webrtc
    ./configure --enable-libx264 --enable-gpl --enable-cross-compile --enable-libpulse --enable-libopus --enable-ffplay --extra-libs='-L/home/oook/user/ffmpeg-webrtc/FFmpeg-n4.3.3/metartc6 -lmetartccore6 -lpthread -lsrtp2 -lssl -lcrypto -ldl'

# ffplay 播放命令
    ffplay -i 'webrtc://127.0.0.1:1985/rtc/v1/whip-play/?app=live&stream=livestream'
zou493451860 commented 8 months ago

SRS 版本是5.0 ,Ubuntu 20.04

88act commented 8 months ago

Ubuntu 23 server 版本 编译 srtp2报错

编译 srtp2

tar zxvf libsrtp-2-fit.tar.gz
cd libsrtp-2-fit/
./configure 
make
cp libsrtp2.a FFmpeg-n4.3.3/metartc6
88act commented 8 months ago

报错信息如下 :
root@iZwz9asjbuf3dgqcuunbeiZ:/mydata/ffmpeg/ffmpeg-webrtc/FFmpeg-n4.3.3/metartc6/libsrtp-2-fit# make gcc -DHAVE_CONFIG_H -Icrypto/include -I./include -I./crypto/include -fPIC -Wall -pedantic -Wstrict-prototypes -O4 -fexpensive-optimizations -funroll-loops -I./test -L. -o crypto/test/aes_calc crypto/test/aes_calc.c test/util.c libsrtp2.a -lsrtp2 /usr/bin/ld: libsrtp2.a(datatypes.o):(.bss+0x0): multiple definition of `bit_string'; /tmp/ccKzQlkn.o:(.bss+0x0): first defined here collect2: error: ld returned 1 exit status make: *** [Makefile:209: crypto/test/aes_calc] Error 1

zou493451860 commented 8 months ago

Ubuntu 23 server 版本 编译 srtp2报错

编译 srtp2

tar zxvf libsrtp-2-fit.tar.gz
cd libsrtp-2-fit/
./configure 
make
cp libsrtp2.a FFmpeg-n4.3.3/metartc6

我的编译环境是Ubuntu 20.04 ,GCC版本是:gcc version 11.3.0 (GCC) 你这个错误可以看看这个解决办法:编译libsrtp-2-fit的错误

enjoyaday commented 6 months ago

@zou493451860 这个报错怎么处理 BEGIN /tmp/ffconf.Dx9AVYuG/test.c 1 int main(void){ return 0; } END /tmp/ffconf.Dx9AVYuG/test.c gcc -c -o /tmp/ffconf.Dx9AVYuG/test.o /tmp/ffconf.Dx9AVYuG/test.c gcc -o /tmp/ffconf.Dx9AVYuG/test /tmp/ffconf.Dx9AVYuG/test.o -L/home/user/ffmpeg-webrtc/FFmpeg-n4.3.3/metartc6 -lmetartccore6 -lpthread -lsrtp2 -lssl -lcrypto -ldl /usr/bin/ld: cannot find -lmetartccore6: No such file or directory /usr/bin/ld: cannot find -lsrtp2: No such file or directory collect2: error: ld returned 1 exit status C compiler test failed.

zou493451860 commented 6 months ago

@zou493451860 这个报错怎么处理 BEGIN /tmp/ffconf.Dx9AVYuG/test.c 1 int main(void){ return 0; } END /tmp/ffconf.Dx9AVYuG/test.c gcc -c -o /tmp/ffconf.Dx9AVYuG/test.o /tmp/ffconf.Dx9AVYuG/test.c gcc -o /tmp/ffconf.Dx9AVYuG/test /tmp/ffconf.Dx9AVYuG/test.o -L/home/user/ffmpeg-webrtc/FFmpeg-n4.3.3/metartc6 -lmetartccore6 -lpthread -lsrtp2 -lssl -lcrypto -ldl /usr/bin/ld: cannot find -lmetartccore6: No such file or directory /usr/bin/ld: cannot find -lsrtp2: No such file or directory collect2: error: ld returned 1 exit status C compiler test failed.

--extra-libs='-L/home/oook/user/ffmpeg-webrtc/FFmpeg-n4.3.3/metartc6 -lmetartccore6 -lpthread -lsrtp2 -lssl -lcrypto -ldl' 确认你的ffmpeg-webrtc目录是在/home/oook/user/下

enjoyaday commented 6 months ago

@zou493451860 这个报错怎么处理 BEGIN /tmp/ffconf.Dx9AVYuG/test.c 1 int main(void){ return 0; } END /tmp/ffconf.Dx9AVYuG/test.c gcc -c -o /tmp/ffconf.Dx9AVYuG/test.o /tmp/ffconf.Dx9AVYuG/test.c gcc -o /tmp/ffconf.Dx9AVYuG/test /tmp/ffconf.Dx9AVYuG/test.o -L/home/user/ffmpeg-webrtc/FFmpeg-n4.3.3/metartc6 -lmetartccore6 -lpthread -lsrtp2 -lssl -lcrypto -ldl /usr/bin/ld: cannot find -lmetartccore6: No such file or directory /usr/bin/ld: cannot find -lsrtp2: No such file or directory collect2: error: ld returned 1 exit status C compiler test failed.

--extra-libs='-L/home/oook/user/ffmpeg-webrtc/FFmpeg-n4.3.3/metartc6 -lmetartccore6 -lpthread -lsrtp2 -lssl -lcrypto -ldl' 确认你的ffmpeg-webrtc目录是在/home/oook/user/下

可以了,感谢

13545328937asd commented 4 months ago

请问推流的时候不会报错吗?我推流报如下的错误: avinfo->sys.whipUrl==webrtcProxy/exchangeSdp?streamName=dyj-test session->context.avinfo->sys.whipUrl=webrtcProxy/exchangeSdp?streamName=dyj-testYang Error(1): query whip sdp failure! [webrtc @ 0x5617f1b7d6c0] connect failed! uri= http://10.71.7.32:8080/webrtcProxy/exchangeSdp?streamName=dyj-test [webrtc @ 0x5617f1b7d6c0] webrtc_open exit

zou493451860 commented 4 months ago

请问推流的时候不会报错吗?我推流报如下的错误: avinfo->sys.whipUrl==webrtcProxy/exchangeSdp?streamName=dyj-test session->context.avinfo->sys.whipUrl=webrtcProxy/exchangeSdp?streamName=dyj-testYang Error(1): query whip sdp failure! [webrtc @ 0x5617f1b7d6c0] connect failed! uri= http://10.71.7.32:8080/webrtcProxy/exchangeSdp?streamName=dyj-test [webrtc @ 0x5617f1b7d6c0] webrtc_open exit

使用ffmpeg-webrtc推whip协议流没有测试成功,可以推rtmp流到SRS,然后拉取SRS的whep流是可以的

13545328937asd commented 4 months ago

请问推流的时候不会报错吗?我推流报如下的错误: avinfo->sys.whipUrl==webrtcProxy/exchangeSdp?streamName=dyj-test session->context.avinfo->sys.whipUrl=webrtcProxy/exchangeSdp?streamName=dyj-testYang Error(1): query whip sdp failure! [webrtc @ 0x5617f1b7d6c0] connect failed! uri= http://10.71.7.32:8080/webrtcProxy/exchangeSdp?streamName=dyj-test [webrtc @ 0x5617f1b7d6c0] webrtc_open exit

使用ffmpeg-webrtc推whip协议流没有测试成功,可以推rtmp流到SRS,然后拉取SRS的whep流是可以

现在应该是推不了webrtc,正常的查询sdp信息的接口,代码也会报错。我看了metaRTC最新版的代码和这个库里面差别有点大,估计修复了,没更新到这里面来。