mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2024-12-25 04:11:38 +00:00
Add -lf support | make line terminator consistent
This commit is contained in:
parent
7c2483d73e
commit
73f3c83940
@ -95,8 +95,7 @@ static const char *smptett_header = "<?xml version=\"1.0\" encoding=\"UTF-8\" st
|
||||
" <body>\n"
|
||||
" <div>\n";
|
||||
|
||||
static const char *webvtt_header = "WEBVTT\r\n"
|
||||
"\r\nSTYLE\r\n";
|
||||
static const char *webvtt_header[] = {"WEBVTT","\r\n","\r\n","STYLE","\r\n"};
|
||||
|
||||
static const char *simple_xml_header = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<captions>\r\n";
|
||||
|
||||
@ -423,7 +422,7 @@ static int write_subtitle_file_header(struct encoder_ctx *ctx, struct ccx_s_writ
|
||||
{
|
||||
int used;
|
||||
int ret = 0;
|
||||
|
||||
int header_size = 0;
|
||||
switch (ctx->write_format)
|
||||
{
|
||||
case CCX_OF_SRT: // Subrip subtitles have no header
|
||||
@ -449,15 +448,32 @@ static int write_subtitle_file_header(struct encoder_ctx *ctx, struct ccx_s_writ
|
||||
ret = write_bom(ctx, out);
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
REQUEST_BUFFER_CAPACITY(ctx, strlen (webvtt_header)*3);
|
||||
used = encode_line (ctx, ctx->buffer,(unsigned char *) webvtt_header);
|
||||
ret = write (out->fh, ctx->buffer,used);
|
||||
if(ret < used)
|
||||
for(int i = 0; i < sizeof(webvtt_header)/sizeof(webvtt_header[0]);i++)
|
||||
{
|
||||
mprint("WARNING: Unable to write complete Buffer \n");
|
||||
return -1;
|
||||
header_size += strlen(webvtt_header[i]);
|
||||
if(ccx_options.enc_cfg.line_terminator_lf == 1 && strcmp(webvtt_header[i],"\r\n")==0)
|
||||
{
|
||||
header_size--;
|
||||
}
|
||||
}
|
||||
REQUEST_BUFFER_CAPACITY(ctx, header_size*3);
|
||||
for(int i = 0; i < sizeof(webvtt_header)/sizeof(webvtt_header[0]);i++)
|
||||
{
|
||||
if(ccx_options.enc_cfg.line_terminator_lf == 1 && strcmp(webvtt_header[i],"\r\n")==0)
|
||||
{
|
||||
used = encode_line (ctx, ctx->buffer,(unsigned char *) "\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
used = encode_line (ctx, ctx->buffer,(unsigned char *) webvtt_header[i]);
|
||||
}
|
||||
ret = write (out->fh, ctx->buffer,used);
|
||||
if(ret < used)
|
||||
{
|
||||
mprint("WARNING: Unable to write complete Buffer \n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case CCX_OF_SAMI: // This header brought to you by McPoodle's CCASDI
|
||||
//fprintf_encoded (wb->fh, sami_header);
|
||||
|
@ -113,7 +113,7 @@ static const char *webvtt_inline_css = "/* default values */\n"
|
||||
"}\n"
|
||||
"::cue(c.bg_black.bg_semi-transparent) {\n"
|
||||
" background-color: rgba(0, 0, 0, 0.5);\n"
|
||||
"}\n\r\n";
|
||||
"}";
|
||||
|
||||
static const char** webvtt_pac_row_percent[] = { "10", "15.33", "20.66", "26", "31.33", "36.66", "42",
|
||||
"47.33", "52.66", "58", "63.33", "68.66", "74", "79.33", "84.66" };
|
||||
@ -227,6 +227,14 @@ int write_webvtt_header(struct encoder_ctx *context)
|
||||
write (context->out->fh, outline_css_file, strlen(outline_css_file));
|
||||
} else {
|
||||
write(context->out->fh, webvtt_inline_css, strlen(webvtt_inline_css));
|
||||
if(ccx_options.enc_cfg.line_terminator_lf == 1)
|
||||
{
|
||||
write(context->out->fh, "\n", 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
write(context->out->fh,"\r\n",2);
|
||||
}
|
||||
}
|
||||
|
||||
write(context->out->fh, "##\n", 3);
|
||||
|
Loading…
Reference in New Issue
Block a user