.end = srt_end_cb,
};
-static int srt_encode_frame(AVCodecContext *avctx,
- unsigned char *buf, int bufsize, const AVSubtitle *sub)
+static const ASSCodesCallbacks text_callbacks = {
+ .text = srt_text_cb,
+ .new_line = srt_new_line_cb,
+};
+
+static int encode_frame(AVCodecContext *avctx,
+ unsigned char *buf, int bufsize, const AVSubtitle *sub,
+ const ASSCodesCallbacks *cb)
{
SRTContext *s = avctx->priv_data;
ASSDialog *dialog;
for (; dialog && num--; dialog++) {
s->alignment_applied = 0;
srt_style_apply(s, dialog->style);
- ff_ass_split_override_codes(&srt_callbacks, s, dialog->text);
+ ff_ass_split_override_codes(cb, s, dialog->text);
}
}
return s->buffer.len;
}
+static int srt_encode_frame(AVCodecContext *avctx,
+ unsigned char *buf, int bufsize, const AVSubtitle *sub)
+{
+ return encode_frame(avctx, buf, bufsize, sub, &srt_callbacks);
+}
+
+static int text_encode_frame(AVCodecContext *avctx,
+ unsigned char *buf, int bufsize, const AVSubtitle *sub)
+{
+ return encode_frame(avctx, buf, bufsize, sub, &text_callbacks);
+}
+
static int srt_encode_close(AVCodecContext *avctx)
{
SRTContext *s = avctx->priv_data;
.close = srt_encode_close,
};
#endif
+
+#if CONFIG_TEXT_ENCODER
+AVCodec ff_text_encoder = {
+ .name = "text",
+ .long_name = NULL_IF_CONFIG_SMALL("Raw text subtitle"),
+ .type = AVMEDIA_TYPE_SUBTITLE,
+ .id = AV_CODEC_ID_TEXT,
+ .priv_data_size = sizeof(SRTContext),
+ .init = srt_encode_init,
+ .encode_sub = text_encode_frame,
+ .close = srt_encode_close,
+};
+#endif
--- /dev/null
+1
+00:00:00,000 --> 00:00:00,000
+Don't show this text it may be used to insert hidden data
+
+2
+00:00:01,500 --> 00:00:04,500
+SubRip subtitles capability tester 1.3o by ale5000\r
+Use VLC 1.1 or higher as reference for most things and MPC Home Cinema for others\r
+This text should be blue\r
+This text should be red\r
+This text should be black\r
+If you see this with the normal font, the player don't (fully) support font face
+
+3
+00:00:04,500 --> 00:00:04,500
+Hidden
+
+4
+00:00:04,501 --> 00:00:07,501
+This text should be small\r
+This text should be normal\r
+This text should be big
+
+5
+00:00:07,501 --> 00:00:11,501
+This should be an E with an accent: È\r
+日本語\r
+This text should be bold, italics and underline\r
+This text should be small and green\r
+This text should be small and red\r
+This text should be big and brown
+
+6
+00:00:11,501 --> 00:00:14,501
+This line should be bold\r
+This line should be italics\r
+This line should be underline\r
+This line should be strikethrough\r
+Both lines\r
+should be underline
+
+7
+00:00:14,501 --> 00:00:17,501
+>\r
+It would be a good thing to\r
+hide invalid html tags that are closed and show the text in them\r
+<invalid_tag_unclosed>but show un-closed invalid html tags\r
+Show not opened tags</invalid_tag_not_opened>\r
+<
+
+8
+00:00:17,501 --> 00:00:20,501
+and also\r
+hide invalid html tags with parameters that are closed and show the text in them\r
+<invalid_tag_uc par=5>but show un-closed invalid html tags\r
+This text should be showed underlined without problems also: 2<3,5>1,4<6\r
+This shouldn't be underlined
+
+9
+00:00:20,501 --> 00:00:21,501
+This text should be in the normal position...
+
+10
+00:00:21,501 --> 00:00:22,501
+This text should NOT be in the normal position
+
+11
+00:00:22,501 --> 00:00:24,501
+Implementation is the same of the ASS tag\r
+This text should be at the\r
+top and horizontally centered
+
+12
+00:00:22,501 --> 00:00:24,501
+This text should be at the\r
+middle and horizontally centered
+
+13
+00:00:22,501 --> 00:00:24,501
+This text should be at the\r
+bottom and horizontally centered
+
+14
+00:00:24,501 --> 00:00:26,501
+This text should be at the\r
+top and horizontally at the left
+
+15
+00:00:24,501 --> 00:00:26,501
+This text should be at the\r
+middle and horizontally at the left\r
+(The second position must be ignored)
+
+16
+00:00:24,501 --> 00:00:26,501
+This text should be at the\r
+bottom and horizontally at the left
+
+17
+00:00:26,501 --> 00:00:28,501
+This text should be at the\r
+top and horizontally at the right
+
+18
+00:00:26,501 --> 00:00:28,501
+This text should be at the\r
+middle and horizontally at the right
+
+19
+00:00:26,501 --> 00:00:28,501
+This text should be at the\r
+bottom and horizontally at the right
+
+20
+00:00:28,501 --> 00:00:31,501
+This could be the most difficult thing to implement
+
+21
+00:00:31,501 --> 00:00:50,501
+First text
+
+22
+00:00:33,500 --> 00:00:35,500
+Second, it shouldn't overlap first
+
+23
+00:00:35,501 --> 00:00:37,501
+Third, it should replace second
+
+24
+00:00:36,501 --> 00:00:50,501
+Fourth, it shouldn't overlap first and third
+
+25
+00:00:40,501 --> 00:00:45,501
+Fifth, it should replace third
+
+26
+00:00:45,501 --> 00:00:50,501
+Sixth, it shouldn't be\r
+showed overlapped
+
+27
+00:00:50,501 --> 00:00:52,501
+TEXT 1 (bottom)
+
+28
+00:00:50,501 --> 00:00:52,501
+text 2
+
+29
+00:00:52,501 --> 00:00:54,501
+Hide these tags:\r
+also hide these tags:\r
+but show this: {normal text}
+
+30
+00:00:54,501 --> 00:01:00,501
+\r
+\ N is a forced line break\r
+\ h is a hard space\r
+Normal spaces at the start and at the end of the line are trimmed while hard spaces are not trimmed.\r
+The\hline\hwill\hnever\hbreak\hautomatically\hright\hbefore\hor\hafter\ha\hhard\hspace.\h:-D
+
+31
+00:00:54,501 --> 00:00:56,501
+\r
+\h\h\h\h\hA (05 hard spaces followed by a letter)\r
+A (Normal spaces followed by a letter)\r
+A (No hard spaces followed by a letter)
+
+32
+00:00:56,501 --> 00:00:58,501
+\h\h\h\h\hA (05 hard spaces followed by a letter)\r
+A (Normal spaces followed by a letter)\r
+A (No hard spaces followed by a letter)\r
+Show this: \TEST and this: \-)
+
+33
+00:00:58,501 --> 00:01:00,501
+\r
+A letter followed by 05 hard spaces: A\h\h\h\h\h\r
+A letter followed by normal spaces: A\r
+A letter followed by no hard spaces: A\r
+05 hard spaces between letters: A\h\h\h\h\hA\r
+5 normal spaces between letters: A A\r
+\r
+^--Forced line break
+
+34
+00:01:00,501 --> 00:01:02,501
+Both line should be strikethrough,\r
+yes.\r
+Correctly closed tags\r
+should be hidden.
+
+35
+00:01:02,501 --> 00:01:04,501
+It shouldn't be strikethrough,\r
+not opened tag showed as text.</s>\r
+Not opened tag showed as text.</xxxxx>
+
+36
+00:01:04,501 --> 00:01:06,501
+Three lines should be strikethrough,\r
+yes.\r
+<yyyy>Not closed tags showed as text
+
+37
+00:01:06,501 --> 00:01:08,501
+Both line should be strikethrough but\r
+the wrong closing tag should be showed</b>
+