@@ -252,6 +252,68 @@ Enabled by default.
@end table
+@section cc_dec_raw_608
+
+Closed Caption decoder.
+Decodes "raw 608 byte pairs" closed captions.
+
+@subsection Options
+
+@table @option
+@item real_time
+Specifies if the decoder should output "the current screen"
+after each new character appears (in general, with closed
+captions, one new character can appear per frame).
+Default is false, decoder outputs "the current screen"
+only when a line feed occurs.
+
+@item rollup_override_line_count
+Specifies the number of lines to output (if the closed
+caption is using rollup, which is common).
+Typically the stream itself designates how many lines of
+closed caption material to display on the screen.
+This is typically more than one and means some lines are
+repeated in the output, since output occurs with each carriage
+return.
+Default is "0" (starts in rollup mode with line count 2,
+then then changes to whatever the closed caption stream
+later specifies).
+If you want a line output (no duplication), set this value to "1".
+
+@end table
+
+@section dvbsub
+@section cc_dec
+
+Closed Caption decoder.
+
+Decodes "608 over 708" closed captions.
+
+@subsection Options
+
+@table @option
+@item real_time
+Specifies if the decoder should output "the current screen"
+after each new character appears (in general, with closed
+captions, one new character can appear per frame).
+Default is false, decoder outputs "the current screen"
+only when a line feed occurs.
+
+@item rollup_override_line_count
+Specifies the number of lines to output (if the closed
+caption is using rollup, which is common).
+Typically the stream itself designates how many lines of
+closed caption material to display on the screen.
+This is typically more than one and means some lines are
+repeated in the output, since output occurs with each carriage
+return.
+Default is "0" (starts in rollup mode with line count 2,
+then then changes to whatever the closed caption stream
+later specifies).
+If you want a line output (no duplication), set this value to "1".
+
+@end table
+
@section dvbsub
@subsection Options
@@ -238,6 +238,7 @@ typedef struct CCaptionSubContext {
AVBPrint buffer;
int buffer_changed;
int rollup;
+ int rollup_override_line_count;
enum cc_mode mode;
int64_t start_time;
/* visible screen time */
@@ -261,7 +262,7 @@ static av_cold int init_decoder(AVCodecContext *avctx)
av_bprint_init(&ctx->buffer, 0, AV_BPRINT_SIZE_UNLIMITED);
/* taking by default roll up to 2 */
ctx->mode = CCMODE_ROLLUP;
- ctx->rollup = 2;
+ ctx->rollup = ctx->rollup_override_line_count || 2;
ctx->cursor_row = 10;
ret = ff_ass_subtitle_header(avctx, "Monospace",
ASS_DEFAULT_FONT_SIZE,
@@ -697,7 +698,12 @@ static void process_cc608(CCaptionSubContext *ctx, int64_t pts, uint8_t hi, uint
case 0x25:
case 0x26:
case 0x27:
- ctx->rollup = lo - 0x23;
+ if (ctx->rollup_override_line_count) {
+ ctx->rollup = ctx->rollup_override_line_count;
+ } else {
+ ctx->rollup = (lo - 0x23);
+ }
+ av_log(ctx, AV_LOG_DEBUG, "setting rollup to %d, requested from stream was %d, override is %d\n", ctx->rollup, (lo - 0x23), ctx->rollup_override_line_count);
ctx->mode = CCMODE_ROLLUP;
break;
case 0x29:
@@ -842,6 +848,7 @@ static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avp
#define SD AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_DECODING_PARAM
static const AVOption options[] = {
{ "real_time", "emit subtitle events as they are decoded for real-time display", OFFSET(real_time), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, SD },
+ { "rollup_override_line_count", "force number of rollup lines [overrides any number specified by the captions themselves]", OFFSET(rollup_override_line_count), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, SD },
{NULL}
};
--
2.17.1
I didn't actually *need* this but thought the functionality was very nice to have, so here's my contribution. It allows for forcing "rollup" style closed captions to output one line at a time (basically, when there is a carriage return, it outputs a line), so there is never any duplication in the output, for instance if it's converted to .srt or .vtt files. Without this you have output like this: 00:01.536 --> 00:03.605 AND AS A SECONDARY QUESTION, I 00:03.605 --> 00:05.707 AND AS A SECONDARY QUESTION, I WOULD ASK YOU HOW OUR VETERANS 00:05.706 --> 00:09.343 WOULD ASK YOU HOW OUR VETERANS AND ACTIVE DUTY MILITARY HAVE 00:09.344 --> 00:10.412 AND ACTIVE DUTY MILITARY HAVE FARED UNDER THIS COMMANDER IN With it set to "1" you get output like this: 00:02.014 --> 00:03.049 SOLDIERS HOME IN HOLYOKE, 00:03.048 --> 00:04.116 MASSACHUSETTS, HAVE LOST 73. 00:04.116 --> 00:04.850 ANOTHER FACILITY IN NEW ORLEANS, 00:04.850 --> 00:06.184 53. 00:06.184 --> 00:07.753 VETERANS ARE IN REAL PERIL 00:07.753 --> 00:14.193 BECAUSE OF A LACK OF PREPARATION 00:14.193 --> 00:15.727 AND THEN THE SAME DYSFUNCTION ... Thanks. Signed-off-by: rogerdpack <rogerpack2005@gmail.com> --- doc/decoders.texi | 62 +++++++++++++++++++++++++++++++++++++++ libavcodec/ccaption_dec.c | 11 +++++-- 2 files changed, 71 insertions(+), 2 deletions(-)