mirror of
https://mirror.skon.top/https://github.com/FFmpeg/FFmpeg
synced 2026-04-20 21:00:41 +08:00
doc/examples: fix output context cleanup in transcode examples
avformat_close_input() is designed for input format contexts only. Using it on output contexts is API misuse — it accesses iformat (which is NULL for output contexts) and does not follow the correct output cleanup path. Replace with the proper pattern already used in remux.c and transcode.c: avio_closep() to close the IO handle, followed by avformat_free_context() to free the format context. Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user