Signed-off-by: Eejya Singh <singh.eejya@gmail.com>
Signed-off-by: Clément Bœsch <u@pkh.me>
... | ... |
@@ -8554,6 +8554,10 @@ useful if not UTF-8. |
8554 | 8554 |
|
8555 | 8555 |
@item stream_index, si |
8556 | 8556 |
Set subtitles stream index. @code{subtitles} filter only. |
8557 |
+ |
|
8558 |
+@item force_style |
|
8559 |
+Override default style or script info parameters of the subtitles. It accepts a |
|
8560 |
+string containing ASS style format @code{KEY=VALUE} couples separated by ",". |
|
8557 | 8561 |
@end table |
8558 | 8562 |
|
8559 | 8563 |
If the first key is not specified, it is assumed that the first value |
... | ... |
@@ -8580,6 +8584,12 @@ To render the second subtitles stream from that file, use: |
8580 | 8580 |
subtitles=video.mkv:si=1 |
8581 | 8581 |
@end example |
8582 | 8582 |
|
8583 |
+To make the subtitles stream from @file{sub.srt} appear in transparent green |
|
8584 |
+@code{DejaVu Serif}, use: |
|
8585 |
+@example |
|
8586 |
+subtitles=sub.srt:force_style='FontName=DejaVu Serif,PrimaryColour=&HAA00FF00' |
|
8587 |
+@end example |
|
8588 |
+ |
|
8583 | 8589 |
@section super2xsai |
8584 | 8590 |
|
8585 | 8591 |
Scale the input by 2x and smooth using the Super2xSaI (Scale and |
... | ... |
@@ -31,7 +31,7 @@ |
31 | 31 |
|
32 | 32 |
#define LIBAVFILTER_VERSION_MAJOR 5 |
33 | 33 |
#define LIBAVFILTER_VERSION_MINOR 9 |
34 |
-#define LIBAVFILTER_VERSION_MICRO 103 |
|
34 |
+#define LIBAVFILTER_VERSION_MICRO 104 |
|
35 | 35 |
|
36 | 36 |
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ |
37 | 37 |
LIBAVFILTER_VERSION_MINOR, \ |
... | ... |
@@ -51,6 +51,7 @@ typedef struct { |
51 | 51 |
ASS_Track *track; |
52 | 52 |
char *filename; |
53 | 53 |
char *charenc; |
54 |
+ char *force_style; |
|
54 | 55 |
int stream_index; |
55 | 56 |
uint8_t rgba_map[4]; |
56 | 57 |
int pix_step[4]; ///< steps per pixel for each plane of the main output |
... | ... |
@@ -260,6 +261,7 @@ static const AVOption subtitles_options[] = { |
260 | 260 |
{"charenc", "set input character encoding", OFFSET(charenc), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS}, |
261 | 261 |
{"stream_index", "set stream index", OFFSET(stream_index), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS}, |
262 | 262 |
{"si", "set stream index", OFFSET(stream_index), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS}, |
263 |
+ {"force_style", "force subtitle style", OFFSET(force_style), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS}, |
|
263 | 264 |
{NULL}, |
264 | 265 |
}; |
265 | 266 |
|
... | ... |
@@ -392,6 +394,27 @@ static av_cold int init_subtitles(AVFilterContext *ctx) |
392 | 392 |
if (ret < 0) |
393 | 393 |
goto end; |
394 | 394 |
|
395 |
+ if (ass->force_style) { |
|
396 |
+ char **list = NULL; |
|
397 |
+ char *temp = NULL; |
|
398 |
+ char *ptr = av_strtok(ass->force_style, ",", &temp); |
|
399 |
+ int i = 0; |
|
400 |
+ while (ptr) { |
|
401 |
+ av_dynarray_add(&list, &i, ptr); |
|
402 |
+ if (!list) { |
|
403 |
+ ret = AVERROR(ENOMEM); |
|
404 |
+ goto end; |
|
405 |
+ } |
|
406 |
+ ptr = av_strtok(NULL, ",", &temp); |
|
407 |
+ } |
|
408 |
+ av_dynarray_add(&list, &i, NULL); |
|
409 |
+ if (!list) { |
|
410 |
+ ret = AVERROR(ENOMEM); |
|
411 |
+ goto end; |
|
412 |
+ } |
|
413 |
+ ass_set_style_overrides(ass->library, list); |
|
414 |
+ av_free(list); |
|
415 |
+ } |
|
395 | 416 |
/* Decode subtitles and push them into the renderer (libass) */ |
396 | 417 |
if (dec_ctx->subtitle_header) |
397 | 418 |
ass_process_codec_private(ass->track, |