Commit 40b198e9 authored by Eejya Singh's avatar Eejya Singh Committed by Clément Bœsch

lavfi/subtitles: add force_style option

Signed-off-by: 's avatarEejya Singh <singh.eejya@gmail.com>
Signed-off-by: 's avatarClément Bœsch <u@pkh.me>
parent 5ae140c0
...@@ -8554,6 +8554,10 @@ useful if not UTF-8. ...@@ -8554,6 +8554,10 @@ useful if not UTF-8.
@item stream_index, si @item stream_index, si
Set subtitles stream index. @code{subtitles} filter only. Set subtitles stream index. @code{subtitles} filter only.
@item force_style
Override default style or script info parameters of the subtitles. It accepts a
string containing ASS style format @code{KEY=VALUE} couples separated by ",".
@end table @end table
If the first key is not specified, it is assumed that the first value 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,6 +8584,12 @@ To render the second subtitles stream from that file, use:
subtitles=video.mkv:si=1 subtitles=video.mkv:si=1
@end example @end example
To make the subtitles stream from @file{sub.srt} appear in transparent green
@code{DejaVu Serif}, use:
@example
subtitles=sub.srt:force_style='FontName=DejaVu Serif,PrimaryColour=&HAA00FF00'
@end example
@section super2xsai @section super2xsai
Scale the input by 2x and smooth using the Super2xSaI (Scale and Scale the input by 2x and smooth using the Super2xSaI (Scale and
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#define LIBAVFILTER_VERSION_MAJOR 5 #define LIBAVFILTER_VERSION_MAJOR 5
#define LIBAVFILTER_VERSION_MINOR 9 #define LIBAVFILTER_VERSION_MINOR 9
#define LIBAVFILTER_VERSION_MICRO 103 #define LIBAVFILTER_VERSION_MICRO 104
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
LIBAVFILTER_VERSION_MINOR, \ LIBAVFILTER_VERSION_MINOR, \
......
...@@ -51,6 +51,7 @@ typedef struct { ...@@ -51,6 +51,7 @@ typedef struct {
ASS_Track *track; ASS_Track *track;
char *filename; char *filename;
char *charenc; char *charenc;
char *force_style;
int stream_index; int stream_index;
uint8_t rgba_map[4]; uint8_t rgba_map[4];
int pix_step[4]; ///< steps per pixel for each plane of the main output int pix_step[4]; ///< steps per pixel for each plane of the main output
...@@ -260,6 +261,7 @@ static const AVOption subtitles_options[] = { ...@@ -260,6 +261,7 @@ static const AVOption subtitles_options[] = {
{"charenc", "set input character encoding", OFFSET(charenc), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS}, {"charenc", "set input character encoding", OFFSET(charenc), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS},
{"stream_index", "set stream index", OFFSET(stream_index), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS}, {"stream_index", "set stream index", OFFSET(stream_index), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS},
{"si", "set stream index", OFFSET(stream_index), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS}, {"si", "set stream index", OFFSET(stream_index), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS},
{"force_style", "force subtitle style", OFFSET(force_style), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS},
{NULL}, {NULL},
}; };
...@@ -392,6 +394,27 @@ static av_cold int init_subtitles(AVFilterContext *ctx) ...@@ -392,6 +394,27 @@ static av_cold int init_subtitles(AVFilterContext *ctx)
if (ret < 0) if (ret < 0)
goto end; goto end;
if (ass->force_style) {
char **list = NULL;
char *temp = NULL;
char *ptr = av_strtok(ass->force_style, ",", &temp);
int i = 0;
while (ptr) {
av_dynarray_add(&list, &i, ptr);
if (!list) {
ret = AVERROR(ENOMEM);
goto end;
}
ptr = av_strtok(NULL, ",", &temp);
}
av_dynarray_add(&list, &i, NULL);
if (!list) {
ret = AVERROR(ENOMEM);
goto end;
}
ass_set_style_overrides(ass->library, list);
av_free(list);
}
/* Decode subtitles and push them into the renderer (libass) */ /* Decode subtitles and push them into the renderer (libass) */
if (dec_ctx->subtitle_header) if (dec_ctx->subtitle_header)
ass_process_codec_private(ass->track, ass_process_codec_private(ass->track,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment