ffmpeg: fix memleak and corruption of AVSubtitle with multiple outputs
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
97578f5f3b
commit
3639343478
4
ffmpeg.c
4
ffmpeg.c
@ -805,6 +805,8 @@ static void do_subtitle_out(AVFormatContext *s,
|
|||||||
if (output_files[ost->file_index]->start_time != AV_NOPTS_VALUE)
|
if (output_files[ost->file_index]->start_time != AV_NOPTS_VALUE)
|
||||||
pts -= output_files[ost->file_index]->start_time;
|
pts -= output_files[ost->file_index]->start_time;
|
||||||
for (i = 0; i < nb; i++) {
|
for (i = 0; i < nb; i++) {
|
||||||
|
unsigned save_num_rects = sub->num_rects;
|
||||||
|
|
||||||
ost->sync_opts = av_rescale_q(pts, AV_TIME_BASE_Q, enc->time_base);
|
ost->sync_opts = av_rescale_q(pts, AV_TIME_BASE_Q, enc->time_base);
|
||||||
if (!check_recording_time(ost))
|
if (!check_recording_time(ost))
|
||||||
return;
|
return;
|
||||||
@ -821,6 +823,8 @@ static void do_subtitle_out(AVFormatContext *s,
|
|||||||
|
|
||||||
subtitle_out_size = avcodec_encode_subtitle(enc, subtitle_out,
|
subtitle_out_size = avcodec_encode_subtitle(enc, subtitle_out,
|
||||||
subtitle_out_max_size, sub);
|
subtitle_out_max_size, sub);
|
||||||
|
if (i == 1)
|
||||||
|
sub->num_rects = save_num_rects;
|
||||||
if (subtitle_out_size < 0) {
|
if (subtitle_out_size < 0) {
|
||||||
av_log(NULL, AV_LOG_FATAL, "Subtitle encoding failed\n");
|
av_log(NULL, AV_LOG_FATAL, "Subtitle encoding failed\n");
|
||||||
exit_program(1);
|
exit_program(1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user