From 7ea95d0a10bd9ddc1adb6d73eda43454f92814d5 Mon Sep 17 00:00:00 2001 From: Sebastien Chauvin Date: Fri, 20 Jan 2023 07:52:28 +0100 Subject: [PATCH 1/5] fix: build --- vod/hds/hds_amf0_encoder.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/vod/hds/hds_amf0_encoder.c b/vod/hds/hds_amf0_encoder.c index d20b79d2..f587b1c4 100644 --- a/vod/hds/hds_amf0_encoder.c +++ b/vod/hds/hds_amf0_encoder.c @@ -127,7 +127,6 @@ hds_amf0_write_metadata(u_char* p, media_set_t* media_set, media_track_t** track uint64_t duration; uint32_t timescale; uint32_t count; - uint32_t bitrate = 0; uint8_t sound_format; count = AMF0_COMMON_FIELDS_COUNT; @@ -155,7 +154,6 @@ hds_amf0_write_metadata(u_char* p, media_set_t* media_set, media_track_t** track if (tracks[MEDIA_TYPE_VIDEO] != NULL) { media_info = &tracks[MEDIA_TYPE_VIDEO]->media_info; - bitrate += media_info->bitrate; p = hds_amf0_append_array_number_value(p, &amf0_width, media_info->u.video.width); p = hds_amf0_append_array_number_value(p, &amf0_height, media_info->u.video.height); p = hds_amf0_append_array_number_value(p, &amf0_videodatarate, (double)media_info->bitrate / 1000.0); @@ -166,7 +164,6 @@ hds_amf0_write_metadata(u_char* p, media_set_t* media_set, media_track_t** track if (tracks[MEDIA_TYPE_AUDIO] != NULL) { media_info = &tracks[MEDIA_TYPE_AUDIO]->media_info; - bitrate += media_info->bitrate; p = hds_amf0_append_array_number_value(p, &amf0_audiodatarate, (double)media_info->bitrate / 1000.0); p = hds_amf0_append_array_number_value(p, &amf0_audiosamplerate, media_info->u.audio.sample_rate); p = hds_amf0_append_array_number_value(p, &amf0_audiosamplesize, media_info->u.audio.bits_per_sample); From 85160c3a3c6b02a314c1f5ad8ef48cb8c5037d3d Mon Sep 17 00:00:00 2001 From: Sebastien Chauvin Date: Fri, 20 Jan 2023 16:32:40 +0100 Subject: [PATCH 2/5] feat: adjust vtt timestamps to be clipped to the segment --- vod/subtitle/webvtt_builder.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/vod/subtitle/webvtt_builder.c b/vod/subtitle/webvtt_builder.c index 73a266a2..c0f4a299 100644 --- a/vod/subtitle/webvtt_builder.c +++ b/vod/subtitle/webvtt_builder.c @@ -30,7 +30,9 @@ webvtt_builder_build( media_track_t* first_track = media_set->filtered_tracks; input_frame_t* cur_frame; input_frame_t* last_frame; - uint64_t start_time; + uint64_t start_time; + uint64_t segment_start_time = media_set->segment_start_time; + uint64_t segment_end_time = media_set->segment_start_time + media_set->segment_duration; uint32_t id_size; size_t result_size; u_char* end; @@ -92,10 +94,19 @@ webvtt_builder_build( p = vod_copy(p, src, id_size); src += id_size; + + uint64_t vtt_start_time = start_time; + if (start_time < segment_start_time) { + vtt_start_time = segment_start_time; + } + uint64_t vtt_end_time = start_time + cur_frame->pts_delay; + if (vtt_end_time > segment_end_time) { + vtt_end_time = segment_end_time; + } // cue timings - p = webvtt_builder_write_timestamp(p, start_time); + p = webvtt_builder_write_timestamp(p, vtt_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); + p = webvtt_builder_write_timestamp(p, vtt_end_time); start_time += cur_frame->duration; // cue settings list + cue payload From 5355d52a0bb3cea95d1905ebeda3ba220d4cef11 Mon Sep 17 00:00:00 2001 From: Sebastien Chauvin Date: Fri, 20 Jan 2023 17:00:51 +0100 Subject: [PATCH 3/5] feat: do not output cues that started before the segment --- vod/subtitle/webvtt_builder.c | 37 +++++++++++++++-------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/vod/subtitle/webvtt_builder.c b/vod/subtitle/webvtt_builder.c index c0f4a299..cea10ee6 100644 --- a/vod/subtitle/webvtt_builder.c +++ b/vod/subtitle/webvtt_builder.c @@ -32,7 +32,7 @@ webvtt_builder_build( input_frame_t* last_frame; uint64_t start_time; uint64_t segment_start_time = media_set->segment_start_time; - uint64_t segment_end_time = media_set->segment_start_time + media_set->segment_duration; + //uint64_t segment_end_time = media_set->segment_start_time + media_set->segment_duration; uint32_t id_size; size_t result_size; u_char* end; @@ -87,30 +87,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); - uint64_t vtt_start_time = start_time; - if (start_time < segment_start_time) { - vtt_start_time = segment_start_time; + // cue settings list + cue payload + p = vod_copy(p, src, cur_frame->size - id_size); } - uint64_t vtt_end_time = start_time + cur_frame->pts_delay; - if (vtt_end_time > segment_end_time) { - vtt_end_time = segment_end_time; - } - // cue timings - p = webvtt_builder_write_timestamp(p, vtt_start_time); - p = vod_copy(p, WEBVTT_TIMESTAMP_DELIM, sizeof(WEBVTT_TIMESTAMP_DELIM) - 1); - p = webvtt_builder_write_timestamp(p, vtt_end_time); - start_time += cur_frame->duration; - - // cue settings list + cue payload - p = vod_copy(p, src, cur_frame->size - id_size); + + start_time += cur_frame->duration; } } From f4bf3b4c01709ebecdd672287fbf04a41c8b3b83 Mon Sep 17 00:00:00 2001 From: Sebastien Chauvin Date: Mon, 23 Jan 2023 08:16:15 +0100 Subject: [PATCH 4/5] style: fix tabs --- vod/subtitle/webvtt_builder.c | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/vod/subtitle/webvtt_builder.c b/vod/subtitle/webvtt_builder.c index cea10ee6..4dfe65d4 100644 --- a/vod/subtitle/webvtt_builder.c +++ b/vod/subtitle/webvtt_builder.c @@ -30,9 +30,9 @@ webvtt_builder_build( media_track_t* first_track = media_set->filtered_tracks; input_frame_t* cur_frame; input_frame_t* last_frame; - uint64_t start_time; - uint64_t segment_start_time = media_set->segment_start_time; - //uint64_t segment_end_time = media_set->segment_start_time + media_set->segment_duration; + uint64_t start_time; + uint64_t segment_start_time = media_set->segment_start_time; + //uint64_t segment_end_time = media_set->segment_start_time + media_set->segment_duration; uint32_t id_size; size_t result_size; u_char* end; @@ -87,25 +87,25 @@ webvtt_builder_build( last_frame = part->last_frame; } - if (start_time >= segment_start_time) { - 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); + // 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; + start_time += cur_frame->duration; } } From 1cabf663273ab283ea48c3dd79fecbe7682b17ee Mon Sep 17 00:00:00 2001 From: Sebastien Chauvin Date: Mon, 23 Jan 2023 10:53:49 +0100 Subject: [PATCH 5/5] ci: .idea files --- .idea/.gitignore | 8 ++++++++ .idea/modules.xml | 8 ++++++++ .idea/nginx-vod-module.iml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ 4 files changed, 30 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/modules.xml create mode 100644 .idea/nginx-vod-module.iml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..13566b81 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..6e5b384c --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/nginx-vod-module.iml b/.idea/nginx-vod-module.iml new file mode 100644 index 00000000..bc2cd874 --- /dev/null +++ b/.idea/nginx-vod-module.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..35eb1ddf --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file