[FIX] Multitrack, WebVTT, and Segfault issues (#1332)

* [FIX] Must have two newlines after WEBVTT header

Bug introduced in #1092

* [FIX] segfault with multitrack reports

* [FIX] segfault with unsupported file reports

* [FIX] Write subtitle header to multitrack outputs

* [FIX] Write multitrack files to the output file directory
This commit is contained in:
emkman99
2021-05-19 17:28:06 -04:00
committed by GitHub
parent 24b90970c7
commit 5b29ef281a
5 changed files with 27 additions and 3 deletions

View File

@@ -28,6 +28,9 @@
for this.
- Fix: Segmentation fault on Windows
- Update: Updated libGPAC to 1.0.1
- Fix: Segmentation fault with unsupported and multitrack file reports
- Fix: Write subtitle header to multitrack outputs
- Fix: Write multitrack files to the output file directory
0.88 (2019-05-21)
-----------------

View File

@@ -92,7 +92,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", NULL};
static const char *webvtt_header[] = {"WEBVTT", "\r\n", "\r\n", NULL};
static const char *simple_xml_header = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<captions>\r\n";
@@ -1448,6 +1448,12 @@ unsigned int get_font_encoded(struct encoder_ctx *ctx, unsigned char *buffer, in
void switch_output_file(struct lib_ccx_ctx *ctx, struct encoder_ctx *enc_ctx, int track_id)
{
// Do nothing when in "report" mode
if (enc_ctx == NULL || enc_ctx->out == NULL)
{
return;
}
if (enc_ctx->out->filename != NULL)
{ // Close and release the previous handle
free(enc_ctx->out->filename);
@@ -1456,8 +1462,15 @@ void switch_output_file(struct lib_ccx_ctx *ctx, struct encoder_ctx *enc_ctx, in
const char *ext = get_file_extension(ctx->write_format);
char suffix[32];
sprintf(suffix, "_%d", track_id);
enc_ctx->out->filename = create_outfilename(get_basename(enc_ctx->first_input_file), suffix, ext);
enc_ctx->out->fh = open(enc_ctx->out->filename, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, S_IREAD | S_IWRITE);
char *basename = get_basename(enc_ctx->out->original_filename);
if (basename != NULL)
{
enc_ctx->out->filename = create_outfilename(basename, suffix, ext);
enc_ctx->out->fh = open(enc_ctx->out->filename, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, S_IREAD | S_IWRITE);
free(basename);
}
write_subtitle_file_header(enc_ctx, enc_ctx->out);
// Reset counters as we switch output file.
enc_ctx->cea_708_counter = 0;

View File

@@ -18,6 +18,7 @@ struct ccx_s_write
int fh;
int temporarily_closed; // 1 means the file was created OK before but we released the handle
char *filename;
char *original_filename;
void* spupng_data;
int with_semaphore; // 1 means create a .sem file when the file is open and delete it when it's closed
char *semaphore_filename;

View File

@@ -12,6 +12,7 @@ void dinit_write(struct ccx_s_write *wb)
if (wb->fh > 0)
close(wb->fh);
freep(&wb->filename);
freep(&wb->original_filename);
if (wb->with_semaphore && wb->semaphore_filename)
unlink(wb->semaphore_filename);
freep(&wb->semaphore_filename);
@@ -50,6 +51,7 @@ int init_write(struct ccx_s_write *wb, char *filename, int with_semaphore)
wb->fh = -1;
wb->temporarily_closed = 0;
wb->filename = filename;
wb->original_filename = strdup(filename);
wb->with_semaphore = with_semaphore;
wb->append_mode = ccx_options.enc_cfg.append_mode;

View File

@@ -269,6 +269,11 @@ void print_file_report(struct lib_ccx_ctx *ctx)
return;
}
if (ctx->current_file >= ctx->num_input_files)
{
return;
}
printf("%s\n", ctx->inputfile[ctx->current_file]);
break;
case CCX_DS_STDIN: