# FFmpegService **Repository Path**: Eunice-grow/ffmpeg-service ## Basic Information - **Project Name**: FFmpegService - **Description**: SpringBoot服务调用FFmpeg,拉取本地摄像头,进行推流和拉流 - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2023-12-05 - **Last Updated**: 2025-05-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # FFmpegService #### 介绍 SpringBoot服务调用FFmpeg,拉取本地摄像头,进行推流和拉流 #### 说明 需要现在本地安装FFmpeg之后服务才能正常使用 + Ubuntu18.04: + 安装v412-ctl ```bash sudo apt install v4l-utils v4l2-ctl --list-devices v4l2-ctl -d0 --list-formats-ext # ffmpeg -f video4linux2 -i /dev/video0 -framerate 30 -f flv rtmp://192.168.6.21:32322/live/edgetest -maxrate 3000k -bufsize 6000k -g 60 ffmpeg -f video4linux2 -i /dev/video0 -c:v libx264 -b:v 0 -f flv rtmp://192.168.6.21:32322/live/edgetest #-b:v 0 选项表示视频流的目标比特率为0,这意味着视频不会被限制为特定的比特率 ffmpeg -f video4linux2 -i /dev/video0 -input_format mjpeg -video_size 1920x1080 -c:v libx264 -b:v 0 -f flv rtmp://192.168.6.21:32322/live/edgetest ffmpeg -f video4linux2 -s 1920x1080 -r 30 -vcodec mjpeg -i /dev/video0 -pix_fmt yuv420p -b:v 2000k -vcodec libx264 -preset veryfast -f flv rtmp://192.168.6.21:32322/live/edgetest http://pull.stream.act.buaa.edu.cn/live_replay/edgetest.flv ``` + 安装ffmpeg ```bash wget http://www.ffmpeg.org/releases/ffmpeg-5.1.4.tar.gz tar -zxvf ffmpeg-5.1.4.tar.gz git clone https://git.ffmpeg.org/ffmpeg.git #cd进ffmpeg目录 ./configure --enable-ffplay --enable-ffserver --prefix=/usr/local/ffmpeg ./configure --enable-ffplay --prefix=/usr/local/ffmpeg #若出现报错 nasm/yasm not found or too old. Use --disable-x86asm for a crippled build. #则安装asm sudo apt-get install yasm sudo make sudo make install #进入ffmpeg的bin目录,ffmpeg\ffplay\ffserver\ffprobe 都已经安装好 #若ffpaly未安装,可能时缺乏依赖库sdl2组 sudo apt-get install libsdl2-2.0 sudo apt-get install libsdl2-dev #安装好依赖库后再生成ffmpeg的makefile #打开ffmpeg源码目录下的config.mak文件,搜索CONFIG_FFPLAY,[!CONFIG_FFPLAY=yes]变成了[CONFIG_FFPLAY=yes] ``` 出现以下报错可能是gcc没有安装 ``` gcc is unable to create an executable file. If gcc is a cross-compiler, use the --enable-cross-compile option. Only do this if you know what cross compiling means. C compiler test failed. If you think configure made a mistake, make sure you are using the latest version from Git. If the latest version fails, report the problem to the ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net. Include the log file "ffbuild/config.log" produced by configure as this will help solve the problem. ``` ```shell # 检查gcc是否安装 gcc --version make --version # 安装 sudo apt-get install build-essential ``` + Windows11: + 无