Skip to content

Commit

Permalink
fixup! ffmpeg: Reuse transcode session for GPU encoding.
Browse files Browse the repository at this point in the history
  • Loading branch information
j0sh committed Jan 8, 2020
1 parent c423f33 commit b37ad86
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions ffmpeg/lpms_ffmpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit b37ad86

Please sign in to comment.