我正在尝试将视频输出从相机转换为MP4但是它使用了太多的CPU(但是我们不能限制程序,因为我们需要快速完成)所以我们认为使用一些GPU可能是一种选择。
目前我们正在使用这个:
ffmpeg.exe -i "old.mkv" "new.mp4"
尝试使用:
ffmpeg.exe -hwaccel cuvid -i "old.mkv" "new.mp4"
但是它会抛出一个错误:
"Pixel format 'yuvj420p' is not supported"
我无法对视频输入做任何事情,但我正在寻找减少CPU使用的替代方案。
视频编码是HEVC。
我认为GPU可能是一个好主意,但这似乎与视频输入不兼容。
有关如何在GPU上运行ffmpeg或降低CPU使用率的其他想法?
此bash脚本应适用于Nvidia GPU。我用1050 Ti进行了测试,来自nvidia-gpu-support-matrix的第一代产品似乎是第一代具有NVDEC芯片,用于加速解码NVENC芯片以加速编码。
#! /usr/bin/sh
# requires a properly compiled ffmpeg; CUDA and a supported GPU from Nvidia https://developer.nvidia.com/video-encode-decode-gpu-support-matrix
# Take in some inputs, this will not check the validity
# there are many more rendering options available.
printf "input file: "
read INPUT
printf "output file: "
read OUTPUT
printf "choose audio [codec ac3, aac, etc]: "
read AUDIO
printf "video resolution [1920x1080, 1024x720, etc]: "
read RESOLUTION
printf "video bitrate [1200~48000]: "
read V_BITRATE
ffmpeg -hide_banner -hwaccel cuvid -c:v hevc_cuvid -resize $RESOLUTION -autorotate 0 -i $INPUT -c:a $AUDIO -c:v h264_nvenc -preset slow -b:v $V_BITRATE $OUTPUT
真的没有GPU编码这样的东西。有些GPU配备了视频编码芯片,有些则没有。您需要知道系统中的内容以及是否编译了ffmpeg以支持它。查看NVENC(如果是Nvidia GPU)VCE(如果是AMD)或快速同步(如果是英特尔)。 -hwaccel cuvid
如果用于加速解码(不编码)。