问题描述
在使用FFmpeg进行RTSP流读取时出现以下报错
[udp @ 000001e04eafbdc0] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
[udp @ 000001e04eb10d40] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
[udp @ 000001e04eb21b80] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
[udp @ 000001e04eb31e80] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
[rtsp @ 000001e04eaf8ec0] UDP timeout, retrying with TCP
问题分析
‘circular_buffer_size’ option was set but it is not supported on this build (pthread support is required)
出现该问题的主要原因就是:使用的FFmpeg
没有编译所需的pthread
模块。
解决方法
方法一:设置默认使用TCP
进行Rtsp
流读取(推荐)
添加-rtsp_transport
选项,-rtsp_transport tcp
完整例子,使用ffmpeg将Rtsp流实时的转成Rtmp流,然后推送到Rtmp服务器,如下:
ffmpeg -rtsp_transport tcp -i rtsp://184.72.239.149/vod/mp4://BigBuckBunny_175k.mov -vcodec copy -acodec copy -f flv -y rtmp://localhost:1935/rtmp/bigbuckbunny_175k
方法二:添加pthread
模块的支持(比较复杂,可以尝试)
首先修改 build_ffmpeg.sh 中 ./config 的编译配置,修改或添加下面几项:
./configure \
# 启用 mediacodec 必须要启用它
--enable-jni \
--enable-mediacodec \
--disable-decoders \
--enable-decoder=aac \
--enable-decoder=aac_latm \
--enable-decoder=mjpeg \
--enable-decoder=png \
# 替换原先解码器为硬解码
--enable-decoder=h264_mediacodec \
--enable-decoder=mpeg4_mediacodec \
项目推荐
DC3是基于Spring Cloud的开源可分布式物联网(IOT)平台,用于快速开发、部署物联设备接入项目,是一整套物联系统解决方案。