Hello.
Recently I used ffmpeg to embed subtitles, and I needed to scale them.
I thought "original_size" option scales subtitles, but it does not.
So I wrote a short patch for it to do that (attached)
If that is considered too complex/bad idea I've also attached another patch
that adds a "font_scale" option instead.
I hope you like one of these.
--
diff -ur ffmpeg-HEAD-649b7a9/libavfilter/vf_subtitles.c ffmpeg-HEAD-649b7a9.new/libavfilter/vf_subtitles.c
--- ffmpeg-HEAD-649b7a9/libavfilter/vf_subtitles.c 2014-09-10 00:07:59.000000000 +0000
+++ ffmpeg-HEAD-649b7a9.new/libavfilter/vf_subtitles.c 2014-09-10 00:11:26.000000000 +0000
@@ -136,9 +136,11 @@
ff_draw_init(&ass->draw, inlink->format, 0);
ass_set_frame_size (ass->renderer, inlink->w, inlink->h);
- if (ass->original_w && ass->original_h)
+ if (ass->original_w && ass->original_h) {
ass_set_aspect_ratio(ass->renderer, (double)inlink->w / inlink->h,
(double)ass->original_w / ass->original_h);
+ ass_set_font_scale(ass->renderer, (inlink->w + inlink->h) * 1.0 / (ass->original_w + ass->original_h));
+ }
return 0;
}
diff -ur ffmpeg-HEAD-649b7a9/libavfilter/vf_subtitles.c ffmpeg-HEAD-649b7a9.new/libavfilter/vf_subtitles.c
--- ffmpeg-HEAD-649b7a9/libavfilter/vf_subtitles.c 2014-09-10 01:02:49.000000000 +0000
+++ ffmpeg-HEAD-649b7a9.new/libavfilter/vf_subtitles.c 2014-09-10 03:34:19.000000000 +0000
@@ -55,6 +55,7 @@
uint8_t rgba_map[4];
int pix_step[4]; ///< steps per pixel for each plane of the main output
int original_w, original_h;
+ double font_scale;
FFDrawContext draw;
} AssContext;
@@ -65,6 +66,7 @@
{"filename", "set the filename of file to read", OFFSET(filename), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, \
{"f", "set the filename of file to read", OFFSET(filename), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, \
{"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 }, \
+ {"font_scale", "set font scale", OFFSET(font_scale), AV_OPT_TYPE_DOUBLE, {.dbl = 1}, 0.01, 99, FLAGS }, \
/* libass supports a log level ranging from 0 to 7 */
static const int ass_libavfilter_log_level_map[] = {
@@ -139,6 +141,7 @@
if (ass->original_w && ass->original_h)
ass_set_aspect_ratio(ass->renderer, (double)inlink->w / inlink->h,
(double)ass->original_w / ass->original_h);
+ ass_set_font_scale(ass->renderer, ass->font_scale);
return 0;
}
_______________________________________________
ffmpeg-devel mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel