Explorar el Código

obs-ffmpeg: Free remaining NVENC frames on exit

This clears out remaining NVENC frames to ensure that the encoder has
finished processing before shutting down.
jp9000 hace 9 años
padre
commit
c5c1e34d09
Se han modificado 1 ficheros con 10 adiciones y 0 borrados
  1. 10 0
      plugins/obs-ffmpeg/obs-ffmpeg-nvenc.c

+ 10 - 0
plugins/obs-ffmpeg/obs-ffmpeg-nvenc.c

@@ -231,6 +231,16 @@ static bool nvenc_update(void *data, obs_data_t *settings)
 static void nvenc_destroy(void *data)
 {
 	struct nvenc_encoder *enc = data;
+	AVPacket pkt = {0};
+	int r_pkt = 1;
+
+	while (r_pkt) {
+		if (avcodec_encode_video2(enc->context, &pkt, NULL, &r_pkt) < 0)
+			break;
+
+		if (r_pkt)
+			av_free_packet(&pkt);
+	}
 
 	avcodec_close(enc->context);
 	av_frame_free(&enc->vframe);