使用带有 NVDEC 的 GStreamer 提取帧

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

我正在尝试将 GStreamer 与 NVDEC 结合使用从视频文件中提取帧。我已经编译并安装了 NVDEC GStreamer 插件。

使用 CPU 解码器,它工作得非常好:

gst-launch-1.0 filesrc location=video.mkv ! matroskademux ! h264parse ! avdec_h264 ! videoconvert ! videoscale ! video/x-raw,width=2560,height=1920 ! jpegenc ! multifilesink index=0 location=%d.jpg

但是,我想利用GPU中的硬件解码器(使用NVDEC):

gst-launch-1.0 filesrc location=video.mkv ! matroskademux ! h264parse ! nvdec ! videoconvert ! videoscale ! video/x-raw,width=2560,height=1920 ! jpegenc ! multifilesink index=0 location=%d.jpg

此操作失败:

WARNING: erroneous pipeline: could not link videoscale0 to jpegenc0, videoscale0 can't handle caps video/x-raw, width=(int)2560, height=(int)1920

如何解决这个问题?

gstreamer video-encoding nvdec
2个回答
2
投票

使用 NVDEC 时,可以通过在管道中的视频缩放之前添加视频转换元素来解决此问题:

gst-launch-1.0 filesrc location=video.mkv ! matroskademux ! h264parse ! nvdec ! videoconvert ! videoscale ! video/x-raw,width=2560,height=1920 ! jpegenc ! multifilesink index=0 location=%d.jpg

0
投票

您可以尝试从GL内存下载到系统内存:

gst-launch-1.0 filesrc location=video.mkv ! matroskademux ! h264parse ! nvdec ! gldownload ! videoscale ! video/x-raw,width=2560,height=1920 ! videoconvert ! jpegenc ! multifilesink index=0 location=%d.jpg
© www.soinside.com 2019 - 2024. All rights reserved.