diff --git a/doc/examples/qsv_transcode.c b/doc/examples/qsv_transcode.c index c3f507e8e6..b4230e7a38 100644 --- a/doc/examples/qsv_transcode.c +++ b/doc/examples/qsv_transcode.c @@ -430,7 +430,9 @@ int main(int argc, char **argv) end: avformat_close_input(&ifmt_ctx); - avformat_close_input(&ofmt_ctx); + if (ofmt_ctx && !(ofmt_ctx->oformat->flags & AVFMT_NOFILE)) + avio_closep(&ofmt_ctx->pb); + avformat_free_context(ofmt_ctx); avcodec_free_context(&decoder_ctx); avcodec_free_context(&encoder_ctx); av_buffer_unref(&hw_device_ctx); diff --git a/doc/examples/vaapi_transcode.c b/doc/examples/vaapi_transcode.c index e1b7a43883..dba37d4bcb 100644 --- a/doc/examples/vaapi_transcode.c +++ b/doc/examples/vaapi_transcode.c @@ -294,7 +294,9 @@ int main(int argc, char **argv) end: avformat_close_input(&ifmt_ctx); - avformat_close_input(&ofmt_ctx); + if (ofmt_ctx && !(ofmt_ctx->oformat->flags & AVFMT_NOFILE)) + avio_closep(&ofmt_ctx->pb); + avformat_free_context(ofmt_ctx); avcodec_free_context(&decoder_ctx); avcodec_free_context(&encoder_ctx); av_buffer_unref(&hw_device_ctx);