Skip to content

Commit

Permalink
feat: do not output cues that started before the segment
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienChauvin committed Jul 17, 2024
1 parent 26f0687 commit d43b8a0
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions vod/subtitle/webvtt_builder.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ webvtt_builder_build(
input_frame_t* last_frame;
uint64_t start_time;
uint64_t base_time;
uint64_t segment_start_time = media_set->segment_start_time;
uint32_t id_size;
size_t result_size;
u_char* end;
Expand Down Expand Up @@ -115,21 +116,25 @@ webvtt_builder_build(
last_frame = part->last_frame;
}

src = (u_char*)(uintptr_t)cur_frame->offset;
if (start_time >= segment_start_time) {
src = (u_char * )(uintptr_t)
cur_frame->offset;

// cue identifier
id_size = cur_frame->key_frame;
p = vod_copy(p, src, id_size);
src += id_size;
// cue identifier
id_size = cur_frame->key_frame;
p = vod_copy(p, src, id_size);
src += id_size;

// cue timings
p = webvtt_builder_write_timestamp(p, start_time);
p = vod_copy(p, WEBVTT_TIMESTAMP_DELIM, sizeof(WEBVTT_TIMESTAMP_DELIM) - 1);
p = webvtt_builder_write_timestamp(p, start_time + cur_frame->pts_delay);
start_time += cur_frame->duration;
// cue timings
p = webvtt_builder_write_timestamp(p, start_time);
p = vod_copy(p, WEBVTT_TIMESTAMP_DELIM, sizeof(WEBVTT_TIMESTAMP_DELIM) - 1);
p = webvtt_builder_write_timestamp(p, start_time + cur_frame->pts_delay);

// cue settings list + cue payload
p = vod_copy(p, src, cur_frame->size - id_size);
}

// cue settings list + cue payload
p = vod_copy(p, src, cur_frame->size - id_size);
start_time += cur_frame->duration;
}
}

Expand Down

0 comments on commit d43b8a0

Please sign in to comment.