Guest User

Untitled

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