14、ffmpeg中进进行硬件编码和解码的片段程序_cuda进行rgb2yuv和yuv2rgb

基本思想:为了加快ffmpeg进行编码和解码使用

测试环境为RTX3060台式机

一、进行RGB2YUV420(YU12)编码

cmakelist.txt

cmake_minimum_required(VERSION 3.5)

project(main LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(OpenCV)
include_directories(${OpenCV_INCLUDE_DIRS})
find_package(CUDA)
include_directories(${CUDA_INCLUDE_DIRS})
#INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}/include")

# nvcc flags -g for debug
#set(CUDA_NVCC_FLAGS -O3;-G;-g)

set(CUDA_NVCC_FLAGS -gencode arch=compute_86,code=sm_86;)

cuda_add_executable(main main.cpp rgb2yuv.cu rgb2yuv.h)

target_link_libraries(main ${OpenCV_LIBS} ${EXTRA_LIBS})

main.cpp



#include "rgb2yuv.h"
#include 
#include 
#include 
#include 
#include 


int main() {
    int width =

你可能感兴趣的:(FFMPEG基础知识,ffmpeg,人工智能)