Skip to content
Open
Show file tree
Hide file tree
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
25 changes: 22 additions & 3 deletions src/lib_ccx/ccx_encoders_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,9 +709,17 @@ void dinit_encoder(struct encoder_ctx **arg, LLONG current_fts)
return;
for (i = 0; i < ctx->nb_out; i++)
{
if (ctx->end_credits_text != NULL)
try_to_add_end_credits(ctx, ctx->out + i, current_fts);
write_subtitle_file_footer(ctx, ctx->out + i);
struct ccx_s_write *out = ctx->out + i;
if (out->wrote_data)
{
if (ctx->end_credits_text != NULL)
try_to_add_end_credits(ctx, out, current_fts);
write_subtitle_file_footer(ctx, out);
}
else if (ctx->generates_file && out->filename != NULL && out->fh != STDOUT_FILENO)
{
remove(out->filename);
}
}

free_encoder_context(ctx->prev);
Expand Down Expand Up @@ -940,6 +948,7 @@ int encode_sub(struct encoder_ctx *context, struct cc_subtitle *sub)
}
freep(&data->xds_str);
write_newline(context, 0);
out->wrote_data = 1;
continue;
}

Expand Down Expand Up @@ -1015,7 +1024,10 @@ int encode_sub(struct encoder_ctx *context, struct cc_subtitle *sub)
break;
}
if (wrote_something)
{
out->wrote_data = 1;
context->last_displayed_subs_ms = data->end_time;
}

if (context->gui_mode_reports)
write_cc_buffer_to_gui(sub->data, context);
Expand Down Expand Up @@ -1093,6 +1105,9 @@ int encode_sub(struct encoder_ctx *context, struct cc_subtitle *sub)
default:
break;
}

if (wrote_something && context->nb_out > 0)
context->out->wrote_data = 1;
break;
case CC_RAW:
if (context->send_to_srv)
Expand All @@ -1105,6 +1120,8 @@ int encode_sub(struct encoder_ctx *context, struct cc_subtitle *sub)
mprint("WARNING: Loss of data\n");
}
}
context->out->wrote_data = 1;
wrote_something = 1;
sub->nb_data = 0;
break;
case CC_TEXT:
Expand Down Expand Up @@ -1147,6 +1164,8 @@ int encode_sub(struct encoder_ctx *context, struct cc_subtitle *sub)
default:
break;
}
if (wrote_something && context->nb_out > 0)
context->out->wrote_data = 1;
sub->nb_data = 0;
break;
}
Expand Down
1 change: 1 addition & 0 deletions src/lib_ccx/ccx_encoders_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct ccx_s_write
char *semaphore_filename;
int with_playlist; // For m3u8 /webvtt: If 1, we'll generate a playlist and segments
char *playlist_filename;
int wrote_data; // Tracks whether any payload was written so empty outputs can be skipped
int renaming_extension; // Used for file rotations
int append_mode; /* Append the file. Prevent overwriting of files */
};
Expand Down
Loading