Guest User

Untitled

a guest
Feb 3rd, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.60 KB | None | 0 0
  1. commit 99f7e327d6d034b855ae4a663ff5ac73dbbb22f7
  2. Author: Eejya Singh <[email protected]>
  3. Date: Wed Jan 28 17:41:42 2015 +0530
  4.  
  5. Adding Force Style option in Subtitles Filter
  6.  
  7. Signed-off-by: Eejya Singh <[email protected]>
  8.  
  9. diff --git a/doc/filters.texi b/doc/filters.texi
  10. index 261fd24..893b2f4 100644
  11. --- a/doc/filters.texi
  12. +++ b/doc/filters.texi
  13. @@ -8470,6 +8470,10 @@ useful if not UTF-8.
  14.  
  15. @item stream_index, si
  16. Set subtitles stream index. @code{subtitles} filter only.
  17. +
  18. +@item force_style
  19. +Set desired style for the customization of subtitles.It follows ASS style format.
  20. +
  21. @end table
  22.  
  23. If the first key is not specified, it is assumed that the first value
  24. @@ -8496,6 +8500,16 @@ To render the second subtitles stream from that file, use:
  25. subtitles=video.mkv:si=1
  26. @end example
  27.  
  28. +To change the font of subtitles stream from file, use:
  29. +@example
  30. +subtitles=video.mkv:force_style=FontName=Arial
  31. +@end example
  32. +
  33. +To change the color and formatting of subtitles stream from file, use:
  34. +@example
  35. +subtitles='video.mkv:force_style=FontName=Arial,PrimaryColour=255'
  36. +@end example
  37. +
  38. @section super2xsai
  39.  
  40. Scale the input by 2x and smooth using the Super2xSaI (Scale and
  41. diff --git a/libavfilter/version.h b/libavfilter/version.h
  42. index 50967f4..7ec374d 100644
  43. --- a/libavfilter/version.h
  44. +++ b/libavfilter/version.h
  45. @@ -31,7 +31,7 @@
  46.  
  47. #define LIBAVFILTER_VERSION_MAJOR 5
  48. #define LIBAVFILTER_VERSION_MINOR 6
  49. -#define LIBAVFILTER_VERSION_MICRO 100
  50. +#define LIBAVFILTER_VERSION_MICRO 101
  51.  
  52. #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
  53. LIBAVFILTER_VERSION_MINOR, \
  54. diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c
  55. index be4c6a5..948348a 100644
  56. --- a/libavfilter/vf_subtitles.c
  57. +++ b/libavfilter/vf_subtitles.c
  58. @@ -51,6 +51,7 @@ typedef struct {
  59. ASS_Track *track;
  60. char *filename;
  61. char *charenc;
  62. + char *force_style;
  63. int stream_index;
  64. uint8_t rgba_map[4];
  65. int pix_step[4]; ///< steps per pixel for each plane of the main output
  66. @@ -260,6 +261,7 @@ static const AVOption subtitles_options[] = {
  67. {"charenc", "set input character encoding", OFFSET(charenc), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS},
  68. {"stream_index", "set stream index", OFFSET(stream_index), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS},
  69. {"si", "set stream index", OFFSET(stream_index), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS},
  70. + {"force_style", "force subtitle style", OFFSET(force_style), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS},
  71. {NULL},
  72. };
  73.  
  74. @@ -389,6 +391,25 @@ static av_cold int init_subtitles(AVFilterContext *ctx)
  75. if (ass->charenc)
  76. av_dict_set(&codec_opts, "sub_charenc", ass->charenc, 0);
  77. ret = avcodec_open2(dec_ctx, dec, &codec_opts);
  78. +
  79. + if (ass->force_style) {
  80. + char **list = NULL;
  81. + char *temp = NULL;
  82. + char *ptr = av_strtok(ass->force_style, ",", &temp);
  83. + int i = 0;
  84. + while(ptr)
  85. + {
  86. + av_dynarray_add(&list, &i, ptr);
  87. + if(!list)
  88. + av_log(ctx, 0, "Error forcing style\n");
  89. + ptr = av_strtok(NULL, ",", &temp);
  90. + }
  91. + av_dynarray_add(&list, &i, NULL);
  92. + if(!list)
  93. + av_log(ctx, 0, "Error forcing style\n");
  94. + ass_set_style_overrides(ass->library, list);
  95. + av_free(list);
  96. + }
  97. if (ret < 0)
  98. goto end;
Advertisement
Add Comment
Please, Sign In to add comment