在 ffmpeg 中使用“overlay_cuda”,输入帧具有透明度

问题描述 投票:0回答:0

我正在尝试使用尽可能多的硬件辅助将全帧图像覆盖在 MP4 的顶部,在 ffmpeg 中。

这是为https://github.com/time4tea/gopro-dashboard-overlay

我的非 GPU 叠加层工作得很好,现在想利用 GPU。

ffmpeg 的输入是:

  • 来自 MP4 文件的流 - 具有 1 个音频和 1 个视频流
  • 来自仪表板软件的帧,作为原始 RGBA 帧提供,帧大小与电影相同。

我已经设法让覆盖有点使用nvidia扩展工作,但它不起作用,因为它使用

nv12
帧格式,它没有任何透明度(AFAIK)所以覆盖帧完全遮挡电影画面 - 有道理。

这样做的咒语是(放在不同的行上以尽量保持不同的部分 - 输入/转换/输出 - 显而易见):

ffmpeg -y -report -hide_banner -loglevel info 
-hwaccel cuda -hwaccel_output_format cuda 
-i movie.mp4 
-f rawvideo -framerate 10.0 -s 1024x576 -pix_fmt rgba -i - 
-filter_complex [0:v]null[mp4_stream];[1:v]format=nv12,hwupload_cuda[overlay_stream];[mp4_stream][overlay_stream]overlay_cuda,hwdownload,format=nv12 
-vcodec h264_nvenc 
-rc:v cbr -b:v 20M -bf:v 3 -profile:v high -spatial-aq true 
-movflags faststart 
output.mp4

当我尝试使用

yuva420p
(我认为这是正确的格式,但很高兴得到更正)时-在所有不同的地方,例如:

ffmpeg -y -report -hide_banner -loglevel info 
-hwaccel cuda -hwaccel_output_format yuva420p 
-i movie.mp4 
-f rawvideo -framerate 10.0 -s 1024x576 -pix_fmt rgba -i - 
-filter_complex [0:v]null[mp4_stream];[1:v]format=yuva420p,hwupload_cuda[overlay_stream];[mp4_stream][overlay_stream]overlay_cuda,hwdownload,format=yuva420p -vcodec h264_nvenc 
-rc:v cbr -b:v 20M -bf:v 3 -profile:v high -spatial-aq true -movflags faststart output.mp4

我得到了相同错误信息的味道:

Impossible to convert between the formats supported by the filter 'Parsed_null_0' and the filter 'auto_scaler_1'

AIUI - 当事物与分辨率或格式不匹配时,自动缩放器被插入到管道中 - 但这里一切都应该匹配?

使用

filter_complex
[1:v]format=yuva420p,hwupload_cuda[overlay_stream];[0:v][overlay_stream]overlay_cuda,hwdownload,format=yuva420p
,即不使用 null 过滤器,我放入它只是为了方便快速更改过滤器,但有同样的错误。

Impossible to convert between the formats supported by the filter 'graph 0 input from stream 0:0' and the filter 'auto_scaler_1'

我已经看过建议的类似问题,但它们似乎并没有为我解决问题。

感谢您的任何建议!

ffmpeg cuda nvidia
© www.soinside.com 2019 - 2024. All rights reserved.