【配置】FFmpeg配置环境ubuntu踩坑记录。

powershell 复制代码
git clone https://github.com/FFmpeg/nv-codec-headers.git
cd nv-codec-headers
git checkout sdk/11.0 切换分支(看自己显卡)
make install
pkg-config --modversion ffnvcodec 
11.0.10.4
确认

wget http://www.ffmpeg.org/releases/ffmpeg-5.1.2.tar.gz
太慢就手动下载
tar -xvf ffmpeg-5.1.2.tar.gz
cd ffmpeg-5.1.2

./configure   --prefix=/usr/local/ffmpeg   --disable-x86asm      --enable-gpl   --enable-version3      --enable-libmp3lame      --enable-shared   --enable-libfdk-aac   --enable-libass   --enable-libfontconfig   --enable-libfreetype          --enable-libx264   --enable-libx265     --enable-nonfree   --enable-cuda-nvcc   --enable-cuvid   --enable-nvenc   --enable-ffnvcodec   --enable-nvdec   --enable-opencl   --extra-cflags=-I/usr/local/cuda/include   --extra-ldflags=-L/usr/local/cuda/lib64   --extra-ldflags=-L/usr/local/lib   --extra-libs=-liconv 
make -j $(nproc)
make install
bash: /usr/local/bin/ffmpeg: No such file or directory
ffmpeg 如何没有则
cp -f ffmpeg /usr/bin/ffmpeg

ffmpeg硬编码踩坑Driver does not support the required nvenc API version. Required: 12.2 Found: 12.0
降低ffmpeg版本突然意识到自己ffmpeg是8.0.


ERROR: cuvid requested, but not all dependencies are satisfied: ffnvcodec
升级nv-codec-headers

cd nv-codec-headers
pkg-config --modversion ffnvcodec 
git checkout sdk/11.0
make install

https://xujinzh.github.io/2023/01/10/ffmpeg-gpu/index.html

https://www.cnblogs.com/ssyfj/p/14556182.html

ffmpeg -y -hwaccel cuda -i 186786DEEE3E75E36F15C4841F4F2CE2-400.mp4 -c:v h264_nvenc -c:a aac output-gpu.mp4

ffmpeg version 5.1.2 Copyright © 2000-2022 the FFmpeg developers

built with gcc 11 (Ubuntu 11.4.0-1ubuntu1~22.04)

configuration: --prefix=/usr/local/ffmpeg --disable-x86asm --enable-gpl --enable-version3 --enable-libmp3lame --enable-shared --enable-libfdk-aac --enable-libass --enable-libfontconfig --enable-libfreetype --enable-libx264 --enable-libx265 --enable-nonfree --enable-cuda-nvcc --enable-cuvid --enable-nvenc --enable-ffnvcodec --enable-nvdec --enable-opencl --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64 --extra-ldflags=-L/usr/local/lib --extra-libs=-liconv

libavutil 57. 28.100 / 57. 28.100

libavcodec 59. 37.100 / 59. 37.100

libavformat 59. 27.100 / 59. 27.100

libavdevice 59. 7.100 / 59. 7.100

libavfilter 8. 44.100 / 8. 44.100

libswscale 6. 7.100 / 6. 7.100

libswresample 4. 7.100 / 4. 7.100

libpostproc 56. 6.100 / 56. 6.100

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '186786DEEE3E75E36F15C4841F4F2CE2-400.mp4':

Metadata:

major_brand : isom

minor_version : 512

compatible_brands: isomiso2avc1mp41

width : 1920

height : 1080

videodatarate : 6144

framerate : 60

description : "Packed by AutoHome AHCoder v1.0.2"

encoder : Lavf59.27.100

Duration: 00:06:26.75, start: 0.000000, bitrate: 6374 kb/s

Stream #0:00x1: Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 6231 kb/s, 30 fps, 30 tbr, 15360 tbn (default)

Metadata:

handler_name : VideoHandler

vendor_id : [0][0][0][0]

Stream #0:10x2: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 134 kb/s (default)

Metadata:

handler_name : SoundHandler

vendor_id : [0][0][0][0]

Stream mapping:

Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_nvenc))

Stream #0:1 -> #0:1 (aac (native) -> aac (native))

Press [q] to stop, [?] for help

Output #0, mp4, to 'output-gpu.mp4':

Metadata:

major_brand : isom

minor_version : 512

compatible_brands: isomiso2avc1mp41

width : 1920

height : 1080

videodatarate : 6144

framerate : 60

description : "Packed by AutoHome AHCoder v1.0.2"

encoder : Lavf59.27.100

Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), nv12(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 2000 kb/s, 30 fps, 15360 tbn (default)

Metadata:

handler_name : VideoHandler

vendor_id : [0][0][0][0]

encoder : Lavc59.37.100 h264_nvenc

Side data:

cpb: bitrate max/min/avg: 0/0/2000000 buffer size: 4000000 vbv_delay: N/A

Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)

Metadata:

handler_name : SoundHandler

vendor_id : [0][0][0][0]

encoder : Lavc59.37.100 aac

frame= 4804 fps=202 q=30.0 Lsize= 42275kB time=00:02:40.61 bitrate=2156.2kbits/s speed=6.75x

video:39513kB audio:2609kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.362425%

终于成功了!

相关推荐
七夜zippoe16 小时前
Spring Data JPA原理与实战 Repository接口的魔法揭秘
java·ffmpeg·事务·jpa·repository
Benny的老巢16 小时前
n8n工作流中FFmpeg 视频截取失败排查:文件路径和参数顺序错误解决方案
chrome·ffmpeg·音视频
王者鳜錸2 天前
Java使用FFmpeg获取音频文件时长:完整实现与原理详解
java·开发语言·ffmpeg·音频时长
桃杬2 天前
用现代 C++ 封装 FFmpeg:从摄像头采集到 H.264 编码的完整实践
c++·ffmpeg·h.264
cvcode_study2 天前
FFmpeg 工具基础
ffmpeg
1nv1s1ble2 天前
记录一个`ffmpeg`的`swscale`库crash的例子
ffmpeg
CodeOfCC3 天前
C++ 实现ffmpeg解析hls fmp4 EXT-X-DISCONTINUITY并支持定位
开发语言·c++·ffmpeg·音视频
Java程序员 拥抱ai3 天前
SpringBoot + FFmpeg + Redis:视频转码、截图、水印异步处理平台搭建
spring boot·redis·ffmpeg
给算法爸爸上香3 天前
yolo tensorrt视频流检测软解码和硬解码
yolo·ffmpeg·视频编解码·tensorrt·nvcodec