Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- commit f5efd1170f27857aca3720a12f154a880ad152e4
- Author: Eejya Singh <[email protected]>
- Date: Wed Jan 28 17:41:42 2015 +0530
- Adding Force Style option in Subtitles Filter
- Signed-off-by: Eejya Singh <[email protected]>
- diff --git a/doc/filters.texi b/doc/filters.texi
- index 261fd24..fe26025 100644
- --- a/doc/filters.texi
- +++ b/doc/filters.texi
- @@ -8468,6 +8468,9 @@ changed.
- Set subtitles input character encoding. @code{subtitles} filter only. Only
- useful if not UTF-8.
- +@item force-style
- +Set desired style for the customization of subtitles.
- +
- @item stream_index, si
- Set subtitles stream index. @code{subtitles} filter only.
- @end table
- @@ -8496,6 +8499,16 @@ To render the second subtitles stream from that file, use:
- subtitles=video.mkv:si=1
- @end example
- +To change the font of subtitles stream from file, use:
- +@example
- +subtitles=video.mkv:force-style=FontName=Arial
- +@end example
- +
- +To change the color and formatting of subtitles stream from file, use:
- +@example
- +subtitles='video.mkv:force-style=FontName=Arial,PrimaryColour=255'
- +@end example
- +
- @section super2xsai
- Scale the input by 2x and smooth using the Super2xSaI (Scale and
- diff --git a/libavfilter/version.h b/libavfilter/version.h
- index 50967f4..7ec374d 100644
- --- a/libavfilter/version.h
- +++ b/libavfilter/version.h
- @@ -31,7 +31,7 @@
- #define LIBAVFILTER_VERSION_MAJOR 5
- #define LIBAVFILTER_VERSION_MINOR 6
- -#define LIBAVFILTER_VERSION_MICRO 100
- +#define LIBAVFILTER_VERSION_MICRO 101
- #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
- LIBAVFILTER_VERSION_MINOR, \
- diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c
- index be4c6a5..351ab50 100644
- --- a/libavfilter/vf_subtitles.c
- +++ b/libavfilter/vf_subtitles.c
- @@ -51,6 +51,7 @@ typedef struct {
- ASS_Track *track;
- char *filename;
- char *charenc;
- + char *force_style;
- int stream_index;
- uint8_t rgba_map[4];
- int pix_step[4]; ///< steps per pixel for each plane of the main output
- @@ -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},
- {"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},
- + {"force_style", "force subtitle style", OFFSET(force_style), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS},
- {NULL},
- };
- @@ -389,6 +391,20 @@ static av_cold int init_subtitles(AVFilterContext *ctx)
- if (ass->charenc)
- av_dict_set(&codec_opts, "sub_charenc", ass->charenc, 0);
- ret = avcodec_open2(dec_ctx, dec, &codec_opts);
- +
- + 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);
- + ptr = av_strtok(NULL, ",", &temp);
- + }
- + av_dynarray_add(&list, &i, NULL);
- + ass_set_style_overrides(ass->library, list);
- + }
- if (ret < 0)
- goto end;
Advertisement
Add Comment
Please, Sign In to add comment