资源简介
英伟达 最新的Video_Codec_SDK_9.0.20 sdk 不用去官网,还要注册麻烦
代码片段和文件信息
/*
* Copyright 2017-2018 NVIDIA Corporation. All rights reserved.
*
* Please refer to the NVIDIA end user license agreement (EULA) associated
* with this source code for terms and conditions that govern your use of
* this software. Any use reproduction disclosure or distribution of
* this software and related documentation outside the terms of the EULA
* is strictly prohibited.
*
*/
#include
#include
#include
#include
#include “NvDecoder/NvDecoder.h“
#include “../Utils/NvCodecUtils.h“
#include “../Utils/FFmpegDemuxer.h“
simplelogger::Logger *logger = simplelogger::LoggerFactory::CreateConsoleLogger();
void ConvertSemiplanarToPlanar(uint8_t *pHostframe int nWidth int nHeight int nBitDepth) {
if (nBitDepth == 8) {
// nv12->iyuv
YuvConverter converter8(nWidth nHeight);
converter8.UVInterleavedToPlanar(pHostframe);
} else {
// p016->yuv420p16
YuvConverter converter16(nWidth nHeight);
converter16.UVInterleavedToPlanar((uint16_t *)pHostframe);
}
}
void DecodeMediaFile(CUcontext cuContext const char *szInFilePath const char *szOutFilePath bool bOutPlanar
const Rect &cropRect const Dim &resizeDim)
{
std::ofstream fpOut(szOutFilePath std::ios::out | std::ios::binary);
if (!fpOut)
{
std::ostringstream err;
err << “Unable to open output file: “ << szOutFilePath << std::endl;
throw std::invalid_argument(err.str());
}
FFmpegDemuxer demuxer(szInFilePath);
NvDecoder dec(cuContext demuxer.GetWidth() demuxer.GetHeight() false FFmpeg2NvCodecId(demuxer.GetVideoCodec()) NULL false false &cropRect &resizeDim);
int nVideoBytes = 0 nframeReturned = 0 nframe = 0;
uint8_t *pVideo = NULL **ppframe;
bool bDecodeOutSemiPlanar = false;
do {
demuxer.Demux(&pVideo &nVideoBytes);
dec.Decode(pVideo nVideoBytes &ppframe &nframeReturned);
if (!nframe && nframeReturned)
LOG(INFO) << dec.GetVideoInfo();
bDecodeOutSemiPlanar = (dec.GetOutputFormat() == cudaVideoSurfaceFormat_NV12) || (dec.GetOutputFormat() == cudaVideoSurfaceFormat_P016);
for (int i = 0; i < nframeReturned; i++) {
if (bOutPlanar && bDecodeOutSemiPlanar) {
ConvertSemiplanarToPlanar(ppframe[i] dec.GetWidth() dec.GetHeight() dec.GetBitDepth());
}
fpOut.write(reinterpret_cast(ppframe[i]) dec.GetframeSize());
}
nframe += nframeReturned;
} while (nVideoBytes);
std::vector aszDecodeOutFormat = { “NV12“ “P016“ “YUV444“ “YUV444P16“ };
if (bOutPlanar) {
aszDecodeOutFormat[0] = “iyuv“; aszDecodeOutFormat[1] = “yuv420p16“;
}
std::cout << “Total frame decoded: “ << nframe << std::endl
<< “Saved in file “ << szOutFilePath << “ in “
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-02-19 15:12 Video_Codec_SDK_9.0.20\
文件 654 2019-02-19 15:07 Video_Codec_SDK_9.0.20\deprecation_notices.txt
目录 0 2019-02-19 15:12 Video_Codec_SDK_9.0.20\doc\
文件 570429 2019-02-19 15:07 Video_Codec_SDK_9.0.20\doc\NVDEC_Application_Note.pdf
文件 694895 2019-02-19 15:07 Video_Codec_SDK_9.0.20\doc\NVDEC_VideoDecoder_API_ProgGuide.pdf
文件 657175 2019-02-19 15:07 Video_Codec_SDK_9.0.20\doc\NVENC_Application_Note.pdf
文件 874733 2019-02-19 15:07 Video_Codec_SDK_9.0.20\doc\NVENC_VideoEncoder_API_ProgGuide.pdf
文件 709164 2019-02-19 15:07 Video_Codec_SDK_9.0.20\doc\Using_FFmpeg_with_NVIDIA_GPU_Hardware_Acceleration.pdf
目录 0 2019-02-19 15:12 Video_Codec_SDK_9.0.20\include\
文件 51590 2019-02-19 15:07 Video_Codec_SDK_9.0.20\include\cuviddec.h
文件 23258 2019-02-19 15:07 Video_Codec_SDK_9.0.20\include\nvcuvid.h
文件 211108 2019-02-19 15:07 Video_Codec_SDK_9.0.20\include\nvEncodeAPI.h
目录 0 2019-02-19 15:12 Video_Codec_SDK_9.0.20\Lib\
目录 0 2019-02-19 15:12 Video_Codec_SDK_9.0.20\Lib\linux\
目录 0 2019-02-19 15:12 Video_Codec_SDK_9.0.20\Lib\linux\stubs\
目录 0 2019-02-19 15:12 Video_Codec_SDK_9.0.20\Lib\linux\stubs\x86_64\
文件 3528 2019-02-19 15:07 Video_Codec_SDK_9.0.20\Lib\linux\stubs\x86_64\libnvcuvid.so
文件 1480 2019-02-19 15:07 Video_Codec_SDK_9.0.20\Lib\linux\stubs\x86_64\libnvidia-encode.so
目录 0 2019-02-19 15:12 Video_Codec_SDK_9.0.20\Lib\Win32\
文件 9000 2019-02-19 15:07 Video_Codec_SDK_9.0.20\Lib\Win32\nvcuvid.lib
目录 0 2019-02-19 15:12 Video_Codec_SDK_9.0.20\Lib\x64\
文件 8152 2019-02-19 15:07 Video_Codec_SDK_9.0.20\Lib\x64\nvcuvid.lib
文件 404812 2019-02-19 15:07 Video_Codec_SDK_9.0.20\LicenseAgreement.pdf
文件 7886 2019-02-19 15:07 Video_Codec_SDK_9.0.20\NOTICES.txt
文件 3786 2019-02-19 15:07 Video_Codec_SDK_9.0.20\ReadMe.txt
文件 2258 2019-02-19 15:07 Video_Codec_SDK_9.0.20\Release_notes.txt
目录 0 2019-02-19 15:12 Video_Codec_SDK_9.0.20\Samples\
目录 0 2019-02-19 15:12 Video_Codec_SDK_9.0.20\Samples\AppDecode\
目录 0 2019-02-19 15:12 Video_Codec_SDK_9.0.20\Samples\AppDecode\AppDec\
目录 0 2019-02-19 15:12 Video_Codec_SDK_9.0.20\Samples\AppDecode\AppDecD3D\
文件 4608 2019-02-19 15:07 Video_Codec_SDK_9.0.20\Samples\AppDecode\AppDecD3D\AppDecD3D.cpp
............此处省略245个文件信息
评论
共有 条评论