ffmpeg + cuda(cuvid) 硬解码+像素格式转换(cpu主导)实战

本文详细介绍了使用ffmpeg结合CUDA的cuvid进行音视频硬解码,并探讨了从AV_PIX_FMT_CUDA到AV_PIX_FMT_BGR24的转换问题,包括GPU和CPU主导的转换尝试及遇到的问题。
摘要由CSDN通过智能技术生成

注意:

VAAPI 是inter gpu 提供的硬编解码接口
VDPAU 是 video decode present api for unix
nvdec / ncvid 都是nivida产出的硬解接口,区别在于解码方式,和数据传输方式不同
nvenc  nivida 硬编接口

编译 & 运行

linux:
      gcc -g video_decode_gpu.c  `pkg-config --libs libavformat libavcodec libswresample libswscale libavutil` -o video_decode_gpu
run cmd:
      ./video_decode_gpu  data/left.mp4  ./bmp

gpu解码原理

问题1?  gpu 解码 是把内存中AVPacket 拷贝到gp显存中进行处理的吗?
        看来是的,代码中通过 av_read_frame(input_ctx, &packet) 读取数据包,其数据操作流向应该是 video file -> memory
问题2?  gpu 解码 的 数据流向? 
        videofile-> avpacket ->decoding frame's in gpu-> transfer  rame in gpu into host memory
问题3?  gpu 解码数据 cuvid 解码器,也是api,对应的数据操作流向?
        videofile-> avpacket ->decoding frame's in gpu-> transfer  rame in gpu into host memory

VDPAU 简介

Developed by NVIDIA for Unix/Linux systems. To enable this  you typically need the libvdpau development package in your distribution, and a compatible graphics card.
 
Note that VDPAU cannot be used to decode frames in memory, the compressed frames are sent by libavcodec to the GPU device supported by VDPAU and then the decoded image can be accessed using the VDPAU API. This is not done automatically by FFmpeg, but must be done at the application level (check for example the ffmpeg_vdpau.c file used by ffmpeg.c). Also, note that with this API it is not possible to move the decoded frame back to RAM, for example in case you need to encode again the decoded frame (e.g. when doing transcoding on a server).
 
Several decoders are currently supported through VDPAU in libavcodec, in particular H.264, MPEG-1/2/4, and VC-1.
 
翻译:
 
由NVIDIA开发的Unix / Linux系统。 要启用此功能,您通常需要分发中的libvdpau开发包和兼容的图形卡。
 
注意,VDPAU不能用于解码内存中的帧,压缩帧由libavcodec发送到VDPAU支持的GPU设备,然后可以使用VDPAU API访问解码图像。 
这不是由FFmpeg自动完成的,但必须在应用
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值