diff mbox

[FFmpeg-devel] ffmpeg: prevent premature EOF in sub2video with nullptr AVSubtitles

Message ID 20180328215318.30201-1-jeebjp@gmail.com
State Superseded
Headers show

Commit Message

Jan Ekström March 28, 2018, 9:53 p.m. UTC
From: Jan Ekström <jan.ekstrom@aminocom.com>

With some streams multiple nullptr AVSubtitles can get pushed
into sub2video_update() in a row.

This causes end_pts, and on the next round pts, to become
INT64_MAX, latter of which signals EOF in framesync, leading to
complete loss of subtitles from that point on.

Thus, utilize the previous sub2video.end_pts as both the pts and
end_pts in case a nullptr AVSubtitle is received. This lets further
incoming subtitle packets be properly processed, as EOF is not hit
in framesync.

Signed-off-by: Jan Ekström <jan.ekstrom@aminocom.com>
---
 fftools/ffmpeg.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Jan Ekström March 28, 2018, 11:30 p.m. UTC | #1
On Thu, Mar 29, 2018 at 12:53 AM, Jan Ekström <jeebjp@gmail.com> wrote:
> From: Jan Ekström <jan.ekstrom@aminocom.com>
>
> With some streams multiple nullptr AVSubtitles can get pushed
> into sub2video_update() in a row.
>
> This causes end_pts, and on the next round pts, to become
> INT64_MAX, latter of which signals EOF in framesync, leading to
> complete loss of subtitles from that point on.
>
> Thus, utilize the previous sub2video.end_pts as both the pts and
> end_pts in case a nullptr AVSubtitle is received. This lets further
> incoming subtitle packets be properly processed, as EOF is not hit
> in framesync.

For context, this seems to mostly be happening at commercial breaks
with some TV channels where a filter chain re-configuration happens at
the beginning and the end due to input format changes (usually with
audio, main programme having 5.1 and advertisements having stereo for
example). Filter chain re-configuration seems related as this does not
seem to happen when the audio filter is removed from the chain.

For example:
- Without audio ("[0:v:0][0:s:0]overlay=eof_action=pass[overlay_out]")
[dvbsub] normal AVSubtitle: utilized values: pts=10949137,
end_pts=13649137, num_rects=0
[dvbsub] nullptr AVSubtitle: utilized values: pts=13649137,
end_pts=9223372036854775807
<no reconfig>
[dvbsub] normal AVSubtitle: utilized values: pts=18783049,
end_pts=21483049, num_rects=2

- With audio ("[0:v:0][0:s:0]overlay=eof_action=pass[overlay_out];[0:a:0]aresample=48000[a_out]")
[dvbsub] normal AVSubtitle: utilized values: pts=10949137,
end_pts=13649137, num_rects=0
[dvbsub] nullptr AVSubtitle: utilized values: pts=13649137,
end_pts=9223372036854775807
<audio reconfig to stereo>
[graph_0_in_0_1] tb:1/48000 samplefmt:fltp samplerate:48000 chlayout:0x3
[Parsed_aresample_4] ch:2 chl:stereo fmt:fltp r:48000Hz -> ch:2
chl:stereo fmt:fltp r:48000Hz
[auto_scaler_0] w:720 h:576 fmt:bgra sar:0/1 -> w:720 h:576
fmt:yuva420p sar:0/1 flags:0x2
[dvbsub] nullptr AVSubtitle: utilized values: pts=9223372036854775807,
end_pts=9223372036854775807
<audio reconfig to 5.1>
[graph_0_in_0_1] tb:1/48000 samplefmt:fltp samplerate:48000 chlayout:0x60f
[Parsed_aresample_4] ch:6 chl:5.1(side) fmt:fltp r:48000Hz -> ch:2
chl:stereo fmt:fltp r:48000Hz
[dvbsub] nullptr AVSubtitle: utilized values: pts=9223372036854775807,
end_pts=9223372036854775807
[dvbsub] normal AVSubtitle: utilized values: pts=18783049,
end_pts=21483049, num_rects=2

Best regards,
Jan
diff mbox

Patch

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 1b2e37b8d8..398ed278d7 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -248,8 +248,7 @@  void sub2video_update(InputStream *ist, AVSubtitle *sub)
                                  AV_TIME_BASE_Q, ist->st->time_base);
         num_rects = sub->num_rects;
     } else {
-        pts       = ist->sub2video.end_pts;
-        end_pts   = INT64_MAX;
+        pts       = end_pts = ist->sub2video.end_pts;
         num_rects = 0;
     }
     if (sub2video_get_blank_frame(ist) < 0) {