From b37ad86488a125d3ef87a2900fd7fcee5537a6ed Mon Sep 17 00:00:00 2001 From: Josh Allmann Date: Wed, 8 Jan 2020 22:42:54 +0000 Subject: [PATCH] fixup! ffmpeg: Reuse transcode session for GPU encoding. --- ffmpeg/lpms_ffmpeg.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ffmpeg/lpms_ffmpeg.c b/ffmpeg/lpms_ffmpeg.c index a80c918505..09e8ae063a 100644 --- a/ffmpeg/lpms_ffmpeg.c +++ b/ffmpeg/lpms_ffmpeg.c @@ -681,8 +681,7 @@ static int open_output(struct output_ctx *octx, struct input_ctx *ictx) if (octx->fps.den) vc->framerate = av_buffersink_get_frame_rate(octx->vf.sink_ctx); else vc->framerate = ictx->vc->framerate; if (octx->fps.den) vc->time_base = av_buffersink_get_time_base(octx->vf.sink_ctx); - else if (ictx->vc->time_base.num && ictx->vc->time_base.den) vc->time_base -= ictx->vc->time_base; + else if (ictx->vc->time_base.num && ictx->vc->time_base.den) vc->time_base = ictx->vc->time_base; else vc->time_base = ictx->ic->streams[ictx->vi]->time_base; if (octx->bitrate) vc->rc_min_rate = vc->rc_max_rate = vc->rc_buffer_size = octx->bitrate; if (av_buffersink_get_hw_frames_ctx(octx->vf.sink_ctx)) { @@ -970,12 +969,10 @@ int encode(AVCodecContext* encoder, AVFrame *frame, struct output_ctx* octx, AVS else if (ret < 0) encode_err("Error sending frame to encoder"); } -#ifdef __linux__ if (AVMEDIA_TYPE_VIDEO == ost->codecpar->codec_type && AV_HWDEVICE_TYPE_CUDA == octx->hw_type && !frame) { - if (!strcmp("nvenc", encoder->codec->wrapper_name)) av_nvenc_flush(encoder); + avcodec_flush_buffers(encoder); } -#endif /* __linux__ */ while (1) { av_init_packet(&pkt);