You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Allow to use nvenc and nvdec in Windows for nVidia cards.
nVidia card don't use the DX API like intel or AMD cards. If ffmpeg and the libraries are compiled with nvenc and nvdec support on WIndows this should(!) now work.
This commit is contained in:
@@ -224,6 +224,23 @@ static enum AVPixelFormat get_hw_dec_format_d3(AVCodecContext *ctx, const enum A
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ReadStream (Unable to decode this file using hardware decode.)", "", -1, "", -1, "", -1, "", -1, "", -1, "", -1);
|
||||
return AV_PIX_FMT_NONE;
|
||||
}
|
||||
|
||||
static enum AVPixelFormat get_hw_dec_format_cu(AVCodecContext *ctx, const enum AVPixelFormat *pix_fmts)
|
||||
{
|
||||
const enum AVPixelFormat *p;
|
||||
|
||||
for (p = pix_fmts; *p != AV_PIX_FMT_NONE; p++) {
|
||||
switch (*p) {
|
||||
case AV_PIX_FMT_CUDA:
|
||||
hw_de_av_pix_fmt_global = AV_PIX_FMT_CUDA;
|
||||
hw_de_av_device_type_global = AV_HWDEVICE_TYPE_CUDA;
|
||||
return *p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ReadStream (Unable to decode this file using hardware decode.)", "", -1, "", -1, "", -1, "", -1, "", -1, "", -1);
|
||||
return AV_PIX_FMT_NONE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
@@ -378,6 +395,10 @@ void FFmpegReader::Open()
|
||||
hw_de_av_device_type = AV_HWDEVICE_TYPE_DXVA2;
|
||||
pCodecCtx->get_format = get_hw_dec_format_dx;
|
||||
break;
|
||||
case 2:
|
||||
hw_de_av_device_type = AV_HWDEVICE_TYPE_CUDA;
|
||||
pCodecCtx->get_format = get_hw_dec_format_cu;
|
||||
break;
|
||||
case 3:
|
||||
hw_de_av_device_type = AV_HWDEVICE_TYPE_DXVA2;
|
||||
pCodecCtx->get_format = get_hw_dec_format_dx;
|
||||
|
||||
@@ -203,9 +203,18 @@ void FFmpegWriter::SetVideoOptions(bool has_video, string codec, Fraction fps, i
|
||||
hw_en_av_device_type = AV_HWDEVICE_TYPE_DXVA2;
|
||||
}
|
||||
else {
|
||||
new_codec = avcodec_find_encoder_by_name(codec.c_str());
|
||||
hw_en_on = 0;
|
||||
hw_en_supported = 0;
|
||||
if ( (strcmp(codec.c_str(),"h264_nvenc") == 0)) {
|
||||
new_codec = avcodec_find_encoder_by_name(codec.c_str());
|
||||
hw_en_on = 1;
|
||||
hw_en_supported = 1;
|
||||
hw_en_av_pix_fmt = AV_PIX_FMT_CUDA;
|
||||
hw_en_av_device_type = AV_HWDEVICE_TYPE_CUDA;
|
||||
}
|
||||
else {
|
||||
new_codec = avcodec_find_encoder_by_name(codec.c_str());
|
||||
hw_en_on = 0;
|
||||
hw_en_supported = 0;
|
||||
}
|
||||
}
|
||||
#elif defined(__APPLE__)
|
||||
if ( (strcmp(codec.c_str(),"h264_qsv") == 0)) {
|
||||
|
||||
Reference in New Issue
Block a user