33 #if CONFIG_SUBTITLES_FILTER
63 #define OFFSET(x) offsetof(AssContext, x)
64 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
66 #define COMMON_OPTIONS \
67 {"filename", "set the filename of file to read", OFFSET(filename), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, \
68 {"f", "set the filename of file to read", OFFSET(filename), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, \
69 {"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 }, \
85 const int ass_level_clip = av_clip(ass_level, 0,
102 ass->
library = ass_library_init();
123 ass_free_track(ass->
track);
127 ass_library_done(ass->
library);
142 ass_set_frame_size (ass->
renderer, inlink->
w, inlink->
h);
144 ass_set_aspect_ratio(ass->
renderer, (
double)inlink->
w / inlink->
h,
153 #define AR(c) ( (c)>>24)
154 #define AG(c) (((c)>>16)&0xFF)
155 #define AB(c) (((c)>>8) &0xFF)
156 #define AA(c) ((0xFF-(c)) &0xFF)
159 const ASS_Image *image)
161 for (; image; image = image->next) {
162 uint8_t rgba_color[] = {
AR(image->color),
AG(image->color),
AB(image->color),
AA(image->color)};
168 image->bitmap, image->stride, image->w, image->h,
169 3, 0, image->dst_x, image->dst_y);
178 int detect_change = 0;
180 ASS_Image *image = ass_render_frame(ass->
renderer, ass->
track,
181 time_ms, &detect_change);
210 #if CONFIG_ASS_FILTER
212 static const AVOption ass_options[] = {
216 {
"simple",
"simple shaping", 0,
AV_OPT_TYPE_CONST, {.i64 = ASS_SHAPING_SIMPLE}, INT_MIN, INT_MAX,
FLAGS,
"shaping_mode"},
217 {
"complex",
"complex shaping", 0,
AV_OPT_TYPE_CONST, {.i64 = ASS_SHAPING_COMPLEX}, INT_MIN, INT_MAX,
FLAGS,
"shaping_mode"},
237 "Could not create a libass track when reading file '%s'\n",
246 .description =
NULL_IF_CONFIG_SMALL(
"Render ASS subtitles onto input video using the libass library."),
257 #if CONFIG_SUBTITLES_FILTER
259 static const AVOption subtitles_options[] = {
268 static const char *
const font_mimetypes[] = {
269 "application/x-truetype-font",
270 "application/vnd.ms-opentype",
271 "application/x-font-ttf",
275 static int attachment_is_font(
AVStream * st)
283 for (n = 0; font_mimetypes[
n]; n++) {
356 attachment_is_font(st)) {
369 "Font attachment has no filename, ignored.\n");
388 "Only text based subtitles are currently supported\n");
415 ass_set_style_overrides(ass->
library, list);
420 ass_process_codec_private(ass->
track,
435 }
else if (got_subtitle) {
440 ass_process_data(ass->
track, ass_line, strlen(ass_line));
459 .description =
NULL_IF_CONFIG_SMALL(
"Render text subtitles onto input video using the libass library."),
461 .
init = init_subtitles,
466 .priv_class = &subtitles_class,