33 #if CONFIG_SUBTITLES_FILTER
62 #define OFFSET(x) offsetof(AssContext, x)
63 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
65 #define COMMON_OPTIONS \
66 {"filename", "set the filename of file to read", OFFSET(filename), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, \
67 {"f", "set the filename of file to read", OFFSET(filename), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, \
68 {"original_size", "set the size of the original video (used to scale fonts)", OFFSET(original_w), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, \
84 const int ass_level_clip = av_clip(ass_level, 0,
101 ass->
library = ass_library_init();
122 ass_free_track(ass->
track);
126 ass_library_done(ass->
library);
141 ass_set_frame_size (ass->
renderer, inlink->
w, inlink->
h);
143 ass_set_aspect_ratio(ass->
renderer, (
double)inlink->
w / inlink->
h,
152 #define AR(c) ( (c)>>24)
153 #define AG(c) (((c)>>16)&0xFF)
154 #define AB(c) (((c)>>8) &0xFF)
155 #define AA(c) ((0xFF-c) &0xFF)
158 const ASS_Image *image)
160 for (; image; image = image->next) {
161 uint8_t rgba_color[] = {
AR(image->color),
AG(image->color),
AB(image->color),
AA(image->color)};
167 image->bitmap, image->stride, image->w, image->h,
168 3, 0, image->dst_x, image->dst_y);
177 int detect_change = 0;
179 ASS_Image *image = ass_render_frame(ass->
renderer, ass->
track,
180 time_ms, &detect_change);
209 #if CONFIG_ASS_FILTER
211 static const AVOption ass_options[] = {
215 {
"simple",
"simple shaping", 0,
AV_OPT_TYPE_CONST, {.i64 = ASS_SHAPING_SIMPLE}, INT_MIN, INT_MAX,
FLAGS,
"shaping_mode"},
216 {
"complex",
"complex shaping", 0,
AV_OPT_TYPE_CONST, {.i64 = ASS_SHAPING_COMPLEX}, INT_MIN, INT_MAX,
FLAGS,
"shaping_mode"},
231 ass_set_fonts(ass->
renderer, NULL, NULL, 1, NULL, 1);
236 "Could not create a libass track when reading file '%s'\n",
245 .description =
NULL_IF_CONFIG_SMALL(
"Render ASS subtitles onto input video using the libass library."),
256 #if CONFIG_SUBTITLES_FILTER
258 static const AVOption subtitles_options[] = {
266 static const char *
const font_mimetypes[] = {
267 "application/x-truetype-font",
268 "application/vnd.ms-opentype",
269 "application/x-font-ttf",
273 static int attachment_is_font(
AVStream * st)
281 for (n = 0; font_mimetypes[
n]; n++) {
354 attachment_is_font(st)) {
367 "Font attachment has no filename, ignored.\n");
373 ass_set_fonts(ass->
renderer, NULL, NULL, 1, NULL, 1);
386 "Only text based subtitles are currently supported\n");
397 ass_process_codec_private(ass->
track,
412 }
else if (got_subtitle) {
417 ass_process_data(ass->
track, ass_line, strlen(ass_line));
436 .description =
NULL_IF_CONFIG_SMALL(
"Render text subtitles onto input video using the libass library."),
438 .
init = init_subtitles,
443 .priv_class = &subtitles_class,