diff --git a/src/lib_ccx/ccx_encoders_webvtt.c b/src/lib_ccx/ccx_encoders_webvtt.c index 68f161579..0f48704ff 100644 --- a/src/lib_ccx/ccx_encoders_webvtt.c +++ b/src/lib_ccx/ccx_encoders_webvtt.c @@ -230,13 +230,37 @@ void write_webvtt_header(struct encoder_ctx *context) else { // Must have another newline if X-TIMESTAMP-MAP is not used - if (ccx_options.enc_cfg.line_terminator_lf == 1) // If -lf parameter is set. + // if (ccx_options.enc_cfg.line_terminator_lf == 1) // If -lf parameter is set. + // { + // write_wrapped(context->out->fh, "\n", 1); + // } + // else + // { + // write_wrapped(context->out->fh, "\r\n", 2); + // } + // Issue #1743: write default X-TIMESTAMP-MAP when timing info is unavailable + if (ccx_options.timestamp_map) { - write_wrapped(context->out->fh, "\n", 1); + const char *default_header = + ccx_options.enc_cfg.line_terminator_lf + ? "X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:0\n\n" + : "X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:0\r\n\r\n"; + + write_wrapped(context->out->fh, + default_header, + strlen(default_header)); } else { - write_wrapped(context->out->fh, "\r\n", 2); + // Must have another newline if X-TIMESTAMP-MAP is not used + if (ccx_options.enc_cfg.line_terminator_lf == 1) + { + write_wrapped(context->out->fh, "\n", 1); + } + else + { + write_wrapped(context->out->fh, "\r\n", 2); + } } } diff --git a/src/lib_ccx/ttml.c b/src/lib_ccx/ttml.c new file mode 100644 index 000000000..28f9a47f4 --- /dev/null +++ b/src/lib_ccx/ttml.c @@ -0,0 +1,124 @@ +#include "ttml.h" +#include "ccx_encoders_common.h" +#include "utility.h" +#include "ccx_common_timing.h" +#include +#include +#include + +// Initialize TTML encoder context +void ttml_init(struct ttml_ctx *ctx, struct encoder_ctx *parent) +{ + ctx->parent = parent; + ctx->wrote_header = 0; + ctx->last_start_time = 0; + ctx->last_end_time = 0; +} + +// Write TTML XML header +int ttml_write_header(struct ttml_ctx *ctx) +{ + if (ctx->wrote_header) + return 0; + + const char *header = + "\n" + "\n" + " \n" + " \n" + "