Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only include cues that start within the VTT segment #18

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading