Skip to content
Permalink
Browse files

[FIX] Added the option to disable timestamps for WebVTT (#1176)

* Added the option to disable timestamps for WebVTT

* Mentioned in changelog

* Added the option to params.c

* Encoder checks its context nwo

* Encoder checks its context
  • Loading branch information
dhrumilp15 authored and cfsmp3 committed Jan 13, 2020
1 parent 987c5cd commit 79f18b996b2556403c84550975ba9739dbdfe697
@@ -18,6 +18,7 @@
- Fix: lib_ccx.c: Initialize fatal error logging function before first usage in init_libraries
- Fix: Added italics, underline, and color rendering support for -out=spupng with EIA608/teletext
- Fix: Change inet_ntop to inet_ntoa for Windows XP compatibility
- FIX: Added an option to disable timestamps for WebVTT (In response to issue #1127)

0.88 (2019-05-21)
-----------------
@@ -40,6 +40,8 @@ void init_options (struct ccx_s_options *options)
options->live_stream=0; // 0 -> A regular file
options->messages_target=1; // 1=stdout
options->print_file_reports=0;
options->no_timestamp_map = 0; // Enable timestamps by default

/* Levenshtein's parameters, for string comparison */
options->dolevdist = 1; // By default attempt to correct typos
options->levdistmincnt=2; // Means 2 fails or less is "the same"...
@@ -38,6 +38,7 @@ struct encoder_cfg
int force_flush; // Force flush on content write
int append_mode; // Append mode for output files
int ucla; // 1 if -UCLA used, 0 if not
int no_timestamp_map; // 1 if timestamps disabled for WebVTT

enum ccx_encoding_type encoding;
enum ccx_output_date_format date_format;
@@ -71,7 +72,7 @@ struct encoder_cfg
LLONG subs_delay; // ms to delay (or advance) subs
int program_number;
unsigned char in_format;
int nospupngocr; // 1 if we don't want to OCR bitmaps to add the text as comments in the XML file in spupng
int nospupngocr; // 1 if we don't want to OCR bitmaps to add the text as comments in the XML file in spupng

// MCC File
int force_dropframe; // 1 if dropframe frame count should be used. defaults to no drop frame.
@@ -115,6 +116,7 @@ struct ccx_s_options // Options from user parameters
>0 -> Live stream with a timeout of this value in seconds */
char *filter_profanity_file; // Extra profanity word file
int messages_target; // 0 = nowhere (quiet), 1=stdout, 2=stderr
int no_timestamp_map; // 1 for no timestamps for WebVTT, 0 for the timestamp header
/* Levenshtein's parameters, for string comparison */
int dolevdist; // 0 => don't attempt to correct typos with this algorithm
int levdistmincnt, levdistmaxpct; // Means 2 fails or less is "the same", 10% or less is also "the same"
@@ -958,6 +958,7 @@ struct encoder_ctx *init_encoder(struct encoder_cfg *opt)
ctx->srt_counter = 0;
ctx->cea_708_counter = 0;
ctx->wrote_webvtt_header = 0;
ctx->no_timestamp_map = opt->no_timestamp_map;

ctx->program_number = opt->program_number;
ctx->send_to_srv = opt->send_to_srv;
@@ -82,6 +82,8 @@ struct encoder_ctx
int force_flush;
/* Keep track of whether -UCLA used */
int ucla;
/* Disable timestamps for WebVTT */
int no_timestamp_map;

struct ccx_common_timing_ctx *timing; /* Some encoders need access to PTS, such as WebVTT */

@@ -214,9 +214,19 @@ int write_webvtt_header(struct encoder_ctx *context)
int used;
unsigned h1, m1, s1, ms1;
millis_to_time(context->timing->sync_pts2fts_fts, &h1, &m1, &s1, &ms1);
sprintf(header_string, "X-TIMESTAMP-MAP=MPEGTS:%ld,LOCAL:%02u:%02u:%02u.%03u%s",
context->timing->sync_pts2fts_pts, h1, m1, s1, ms1,
ccx_options.enc_cfg.line_terminator_lf ? "\n\n" : "\r\n\r\n");

// If the user has not disabled X-TIMESTAMP-MAP
if (!context->no_timestamp_map)
{
sprintf(header_string, "X-TIMESTAMP-MAP=MPEGTS:%ld,LOCAL:%02u:%02u:%02u.%03u%s",
context->timing->sync_pts2fts_pts, h1, m1, s1, ms1,
ccx_options.enc_cfg.line_terminator_lf ? "\n\n" : "\r\n\r\n");
}
else {
sprintf(header_string,
context->timing->sync_pts2fts_pts, h1, m1, s1, ms1,
ccx_options.enc_cfg.line_terminator_lf ? "\n\n" : "\r\n\r\n");
}
used = encode_line(context, context->buffer, (unsigned char *)header_string);
write(context->out->fh, context->buffer, used);

@@ -554,6 +554,7 @@ void print_usage (void)
mprint(" less or equal than the max allowed..\n");
mprint("-anvid --analyzevideo Analyze the video stream even if it's not used for\n");
mprint(" subtitles. This allows to provide video information.\n");
mprint(" --no-timestamp-map Use this flag to disable the X-TIMESTAMP-MAP header for WebVTT\n");
mprint("Levenshtein distance:\n\n");
mprint(" When processing teletext files CCExtractor tries to correct typos by\n");
mprint(" comparing consecutive lines. If line N+1 is almost identical to line N except\n");
@@ -1492,6 +1493,12 @@ int parse_parameters (struct ccx_s_options *opt, int argc, char *argv[])
continue;
}

if (strcmp(argv[i], "--no-timestamp-map") == 0 || strcmp(argv[i], "-ntm") == 0)
{
opt->no_timestamp_map = 1;
continue;
}

/* Input file formats */
if (strcmp(argv[i], "-es") == 0 ||
strcmp(argv[i], "-ts") == 0 ||

0 comments on commit 79f18b9

Please sign in to comment.
You can’t perform that action at this time.