33 #if CONFIG_SUBTITLES_FILTER
61 #define OFFSET(x) offsetof(AssContext, x)
62 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
64 #define COMMON_OPTIONS \
65 {"filename", "set the filename of file to read", OFFSET(filename), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, \
66 {"f", "set the filename of file to read", OFFSET(filename), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, \
67 {"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 }, \
98 ass->
library = ass_library_init();
119 ass_free_track(ass->
track);
123 ass_library_done(ass->
library);
138 ass_set_frame_size (ass->
renderer, inlink->
w, inlink->
h);
140 ass_set_aspect_ratio(ass->
renderer, (
double)inlink->
w / inlink->
h,
147 #define AR(c) ( (c)>>24)
148 #define AG(c) (((c)>>16)&0xFF)
149 #define AB(c) (((c)>>8) &0xFF)
150 #define AA(c) ((0xFF-c) &0xFF)
153 const ASS_Image *image)
155 for (; image; image = image->next) {
156 uint8_t rgba_color[] = {
AR(image->color),
AG(image->color),
AB(image->color),
AA(image->color)};
162 image->bitmap, image->stride, image->w, image->h,
163 3, 0, image->dst_x, image->dst_y);
172 int detect_change = 0;
174 ASS_Image *image = ass_render_frame(ass->
renderer, ass->
track,
175 time_ms, &detect_change);
204 #if CONFIG_ASS_FILTER
206 static const AVOption ass_options[] = {
222 ass_set_fonts(ass->
renderer, NULL, NULL, 1, NULL, 1);
227 "Could not create a libass track when reading file '%s'\n",
236 .description =
NULL_IF_CONFIG_SMALL(
"Render ASS subtitles onto input video using the libass library."),
243 .priv_class = &ass_class,
247 #if CONFIG_SUBTITLES_FILTER
249 static const AVOption subtitles_options[] = {
257 static const char *font_mimetypes[] = {
258 "application/x-truetype-font",
259 "application/vnd.ms-opentype",
260 "application/x-font-ttf",
264 static int attachment_is_font(
AVStream * st)
272 for (n = 0; font_mimetypes[
n]; n++) {
345 attachment_is_font(st)) {
358 "Font attachment has no filename, ignored.\n");
364 ass_set_fonts(ass->
renderer, NULL, NULL, 1, NULL, 1);
377 "Only text based subtitles are currently supported\n");
388 ass_process_codec_private(ass->
track,
403 }
else if (got_subtitle) {
408 ass_process_data(ass->
track, ass_line, strlen(ass_line));
427 .description =
NULL_IF_CONFIG_SMALL(
"Render text subtitles onto input video using the libass library."),
429 .
init = init_subtitles,
434 .priv_class = &subtitles_class,