Skip to content

SSA and SubRip in-progress cue is not rendered when subtitle track is selected after cue's start time #2309

Closed

Description

@leesangyoon93

When selecting a subtitle track after playback has passed the cue’s start time, and the subtitle file contains only one cue, no subtitle is rendered.

However, if the subtitle file has two or more cues, the same behavior works correctly — the cue that overlaps with current playback time is displayed as expected.

Expected behavior

Even if a subtitle file contains only one cue, and the track is selected after the cue’s start time but before its end time, the cue should be rendered if it's currently active.

Steps to reproduce

  1. Create a .vtt file with only one cue:
1
00:00:00,000 --> 00:00:10,000
Hello world!
  1. Start playback and seek to 5 seconds (after the cue's start time).
  2. Select the subtitle track at 5 seconds.
  3. Observe that no subtitles are shown.
  4. Check onCues(List) — it is triggered but receives an empty list.

Root Cause Hypothesis

ExoPlayer’s internal logic likely relies on multiple cues to construct a timeline for cue scheduling.

When only one cue exists, and the current playback position is past its start time, there’s no scheduling opportunity, so the cue is skipped.

This results in onCues() being called with an empty list, even though the cue should be active.

Activity

  1. peerless2012 commented on Apr 10, 2025

    @peerless2012
    Contributor

    I noticed same issue.

  2. icbaker commented on Apr 25, 2025

    @icbaker
    Collaborator

    When selecting a subtitle track after playback has passed the cue’s start time, and the subtitle file contains only one cue, no subtitle is rendered.

    I can reproduce this using the provided subrip snippet.

    However, if the subtitle file has two or more cues, the same behavior works correctly — the cue that overlaps with current playback time is displayed as expected.

    I can't reproduce this. When I modify the subrip file to the following, and then repeat your steps, I don't see "Hello world!" displayed, only "Hello two" when playback reaches 11s.

    1
    00:00:00,000 --> 00:00:10,000
    Hello world!
    
    2
    00:00:11,000 --> 00:00:20,000
    Hello two
    

    1. Create a .vtt file with only one cue:
    1
    00:00:00,000 --> 00:00:10,000
    Hello world!
    

    Aside: This doesn't look like a valid WebVTT file - it looks like maybe SubRip? To be be WebVTT it must start with WEBVTT and then a blank line before the cues - and the cue timestamps must use . for the separator between seconds and milliseconds.

    When I use the following two WebVTT snippets (single cue and two cues), I see the subtitles appear when the track is enabled at 5s (i.e. the issue doesn't repro).

    WEBVTT
    
    00:00:00.000 --> 00:00:10.000
    Hello world!
    
    WEBVTT
    
    00:00:00.000 --> 00:00:10.000
    Hello world!
    
    00:00:11.000 --> 00:00:20.000
    Hello two
    

    So in summary: This issue repros with SubRip but not with WebVTT (regardless of the number of cues).

    This happens because of these comparisons with cue 'start time' instead of 'end time'. I've sent a change for review which changes this (and same in SsaParser too), which results in the cues showing up as soon as the subtitles are enabled at 5s.

    if (outputOptions.startTimeUs == C.TIME_UNSET || startTimeUs >= outputOptions.startTimeUs) {
    output.accept(
    new CuesWithTiming(
    ImmutableList.of(buildCue(text, alignmentTag)),
    startTimeUs,
    /* durationUs= */ endTimeUs - startTimeUs));

    if (seekTimeUs == C.TIME_UNSET || cuesWithTiming.startTimeUs >= seekTimeUs) {
    writeToOutput(sample);
    }

  3. peerless2012 commented on Apr 25, 2025

    @peerless2012
    Contributor

    Does this change fix for aas subtitles?

  4. icbaker commented on Apr 25, 2025

    @icbaker
    Collaborator

    Does this change fix for aas subtitles?

    My change modifies the equivalent startTimeUs >= outputOptions.startTimeUs check in both SubripParser and SsaParser.

  5. changed the title [-]Subtitle cue not rendered when subtitle track contains only one cue and selected after cue's start time[/-] [+]SSA and SubRip in-progress cue is not rendered when subtitle track is selected after cue's start time[/+] on Apr 25, 2025
  6. locked and limited conversation to collaborators on Jun 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions