[FFmpeg-devel] subtitle filter
Iliya Bunov
panykeywr at gmail.com
Sat Apr 12 22:39:01 CEST 2014
It is impossible to make a screenshot with hardsubs.
ffmpeg -ss 00:10:57 -t 1 -i m.mkv -vf "ass=m.ass" -f mjpeg image01.png
Subtitles always start from the beginning (00:00 not 00:10:57).
Adding "ss" option can solve this problem.
ffmpeg -ss 00:10:57 -t 1 -i m.mkv -vf "ass=m.ass:ss='10\:57'" -f mjpeg
image01.png
PATCH
diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c
index e44f61d..c742155 100644
--- a/libavfilter/vf_subtitles.c
+++ b/libavfilter/vf_subtitles.c
@@ -54,6 +54,7 @@ typedef struct {
uint8_t rgba_map[4];
int pix_step[4]; ///< steps per pixel for each plane of the
main output
int original_w, original_h;
+ int64_t ss;
FFDrawContext draw;
} AssContext;
@@ -64,6 +65,7 @@ typedef struct {
{"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 }, \
+ {"ss", "set subtitle time offset",
OFFSET(ss), AV_OPT_TYPE_DURATION, {.i64 = 0.},
0, INT32_MAX, FLAGS }, \
/* libass supports a log level ranging from 0 to 7 */
static const int ass_libavfilter_log_level_map[] = {
@@ -170,7 +172,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
*picref)
AVFilterLink *outlink = ctx->outputs[0];
AssContext *ass = ctx->priv;
int detect_change = 0;
- double time_ms = picref->pts * av_q2d(inlink->time_base) * 1000;
+ double time_ms = picref->pts * av_q2d(inlink->time_base) * 1000 +
ass->ss / 1000;
ASS_Image *image = ass_render_frame(ass->renderer, ass->track,
time_ms, &detect_change);
More information about the ffmpeg-devel
mailing list