33 #if CONFIG_SUBTITLES_FILTER
60 #define OFFSET(x) offsetof(AssContext, x)
61 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
63 #define COMMON_OPTIONS \
64 {"filename", "set the filename of file to read", OFFSET(filename), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, \
65 {"f", "set the filename of file to read", OFFSET(filename), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, \
66 {"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 }, \
80 static void ass_log(
int ass_level,
const char *
fmt, va_list args,
void *ctx)
91 static const char *shorthand[] = {
"filename",
NULL };
105 ass->
library = ass_library_init();
128 ass_free_track(ass->
track);
132 ass_library_done(ass->
library);
147 ass_set_frame_size (ass->
renderer, inlink->
w, inlink->
h);
149 ass_set_aspect_ratio(ass->
renderer, (
double)inlink->
w / inlink->
h,
156 #define AR(c) ( (c)>>24)
157 #define AG(c) (((c)>>16)&0xFF)
158 #define AB(c) (((c)>>8) &0xFF)
159 #define AA(c) ((0xFF-c) &0xFF)
162 const ASS_Image *image)
164 for (; image; image = image->next) {
165 uint8_t rgba_color[] = {
AR(image->color),
AG(image->color),
AB(image->color),
AA(image->color)};
171 image->bitmap, image->stride, image->w, image->h,
172 3, 0, image->dst_x, image->dst_y);
181 int detect_change = 0;
183 ASS_Image *image = ass_render_frame(ass->
renderer, ass->
track,
184 time_ms, &detect_change);
213 #if CONFIG_ASS_FILTER
215 static const AVOption ass_options[] = {
225 int ret =
init(ctx, args, &ass_class);
233 "Could not create a libass track when reading file '%s'\n",
242 .description =
NULL_IF_CONFIG_SMALL(
"Render ASS subtitles onto input video using the libass library."),
249 .priv_class = &ass_class,
253 #if CONFIG_SUBTITLES_FILTER
255 static const AVOption subtitles_options[] = {
276 ret =
init(ctx, args, &subtitles_class);
316 "Only text based subtitles are currently supported\n");
327 ass_process_codec_private(ass->
track,
342 }
else if (got_subtitle) {
347 ass_process_data(ass->
track, ass_line, strlen(ass_line));
366 .description =
NULL_IF_CONFIG_SMALL(
"Render text subtitles onto input video using the libass library."),
368 .
init = init_subtitles,
373 .priv_class = &subtitles_class,