diff --git a/src/mod/applications/mod_av/avformat.c b/src/mod/applications/mod_av/avformat.c index 1f2c273690..e598e756f4 100644 --- a/src/mod/applications/mod_av/avformat.c +++ b/src/mod/applications/mod_av/avformat.c @@ -2244,10 +2244,10 @@ static switch_status_t av_file_close(switch_file_handle_t *handle) } if (context->fc) { - if (context->has_video) { + if (context->has_video && switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE)) { av_write_trailer(context->fc); } - + mod_avformat_destroy_output_context(context); }