Skip to content

Commit

Permalink
Hardware encoding not working.
Browse files Browse the repository at this point in the history
  • Loading branch information
ggarra13 committed Feb 8, 2024
1 parent 9e188ad commit 48ea1f4
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lib/tlIO/FFmpegWrite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,13 +609,19 @@ namespace tl
default: break;
}

const AVCodec* avCodec = avcodec_find_encoder(avCodecID);
const AVCodec* avCodec = nullptr;
if (avCodecID == AV_CODEC_ID_VP9)
{
avCodec = avcodec_find_encoder_by_name("vp9_qsv");
if (!avCodec)
avCodec = avcodec_find_encoder_by_name("libvpx-vp9");
}
if (avCodecID == AV_CODEC_ID_H264)
{
avCodec = avcodec_find_encoder_by_name("h264_nvenc");
}
if (!avCodec)
avCodec = avcodec_find_encoder(avCodecID);
if (!avCodec)
{
throw std::runtime_error(string::Format("{0}: Cannot find encoder").arg(p.fileName));
Expand Down Expand Up @@ -688,6 +694,18 @@ namespace tl

av_dict_free(&codecOptions);

if (p.avCodecContext->codec && p.avCodecContext->codec->name)
{
if (auto logSystem = _logSystem.lock())
{
logSystem->print(
"tl::io::ffmpeg::Plugin::Write",
string::Format("{0}: Opened codec {1}.")
.arg(p.fileName)
.arg(p.avCodecContext->codec->name));
}
}

r = avcodec_parameters_from_context(p.avVideoStream->codecpar, p.avCodecContext);
if (r < 0)
{
Expand Down

0 comments on commit 48ea1f4

Please sign in to comment.