Merge remote-tracking branch 'cus/stable'
* cus/stable: ffmpeg: ensure that -fix_sub_duration doesnt create subtitles with zero duration ffmpeg: free empty subtitles as well in transcode_subtitles ffmpeg: do not pass possibly undefined subtitles to sub2video_update Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
18
ffmpeg.c
18
ffmpeg.c
@ -1807,25 +1807,32 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ist->fix_sub_duration) {
|
if (ist->fix_sub_duration) {
|
||||||
|
int end = 1;
|
||||||
if (ist->prev_sub.got_output) {
|
if (ist->prev_sub.got_output) {
|
||||||
int end = av_rescale(subtitle.pts - ist->prev_sub.subtitle.pts,
|
end = av_rescale(subtitle.pts - ist->prev_sub.subtitle.pts,
|
||||||
1000, AV_TIME_BASE);
|
1000, AV_TIME_BASE);
|
||||||
if (end < ist->prev_sub.subtitle.end_display_time) {
|
if (end < ist->prev_sub.subtitle.end_display_time) {
|
||||||
av_log(ist->st->codec, AV_LOG_DEBUG,
|
av_log(ist->st->codec, AV_LOG_DEBUG,
|
||||||
"Subtitle duration reduced from %d to %d\n",
|
"Subtitle duration reduced from %d to %d%s\n",
|
||||||
ist->prev_sub.subtitle.end_display_time, end);
|
ist->prev_sub.subtitle.end_display_time, end,
|
||||||
|
end <= 0 ? ", dropping it" : "");
|
||||||
ist->prev_sub.subtitle.end_display_time = end;
|
ist->prev_sub.subtitle.end_display_time = end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FFSWAP(int, *got_output, ist->prev_sub.got_output);
|
FFSWAP(int, *got_output, ist->prev_sub.got_output);
|
||||||
FFSWAP(int, ret, ist->prev_sub.ret);
|
FFSWAP(int, ret, ist->prev_sub.ret);
|
||||||
FFSWAP(AVSubtitle, subtitle, ist->prev_sub.subtitle);
|
FFSWAP(AVSubtitle, subtitle, ist->prev_sub.subtitle);
|
||||||
|
if (end <= 0)
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!*got_output)
|
||||||
|
return ret;
|
||||||
|
|
||||||
sub2video_update(ist, &subtitle);
|
sub2video_update(ist, &subtitle);
|
||||||
|
|
||||||
if (!*got_output || !subtitle.num_rects)
|
if (!subtitle.num_rects)
|
||||||
return ret;
|
goto out;
|
||||||
|
|
||||||
for (i = 0; i < nb_output_streams; i++) {
|
for (i = 0; i < nb_output_streams; i++) {
|
||||||
OutputStream *ost = output_streams[i];
|
OutputStream *ost = output_streams[i];
|
||||||
@ -1836,6 +1843,7 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output)
|
|||||||
do_subtitle_out(output_files[ost->file_index]->ctx, ost, ist, &subtitle);
|
do_subtitle_out(output_files[ost->file_index]->ctx, ost, ist, &subtitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
avsubtitle_free(&subtitle);
|
avsubtitle_free(&subtitle);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user