diff options
author | Jan Ekström <jeebjp@gmail.com> | 2019-09-18 21:26:05 +0300 |
---|---|---|
committer | Jan Ekström <jeebjp@gmail.com> | 2019-09-19 00:02:03 +0300 |
commit | 1b9370ff92a7fdf347d087db7c29bf682abadb9e (patch) | |
tree | 644772429f2d9dfd73b64ffd9f1bfcbd22c37e79 /sub/lavc_conv.c | |
parent | 80c4aaa2a4e7ada6530ad4f16172283cd82fcc1d (diff) | |
download | mpv-1b9370ff92a7fdf347d087db7c29bf682abadb9e.tar.bz2 mpv-1b9370ff92a7fdf347d087db7c29bf682abadb9e.tar.xz |
sub/lavc_conv: switch to the newer "ass" subtitle decoding mode
Existing since 2016, this removes timestamps from the lines,
and gives more precision in the timestamps (1:1000).
Diffstat (limited to 'sub/lavc_conv.c')
-rw-r--r-- | sub/lavc_conv.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/sub/lavc_conv.c b/sub/lavc_conv.c index 75c127cc82..7077116180 100644 --- a/sub/lavc_conv.c +++ b/sub/lavc_conv.c @@ -85,6 +85,7 @@ struct lavc_conv *lavc_conv_create(struct mp_log *log, const char *codec_name, goto error; if (mp_lavc_set_extradata(avctx, extradata, extradata_len) < 0) goto error; + av_dict_set(&opts, "sub_text_format", "ass", 0); if (strcmp(codec_name, "eia_608") == 0) av_dict_set(&opts, "real_time", "1", 0); if (avcodec_open2(avctx, codec, &opts) < 0) @@ -227,8 +228,11 @@ static int parse_webvtt(AVPacket *in, AVPacket *pkt) #endif -// Return a NULL-terminated list of ASS event lines. -char **lavc_conv_decode(struct lavc_conv *priv, struct demux_packet *packet) +// Return a NULL-terminated list of ASS event lines and have +// the AVSubtitle display PTS and duration set to input +// double variables. +char **lavc_conv_decode(struct lavc_conv *priv, struct demux_packet *packet, + double *sub_pts, double *sub_duration) { AVCodecContext *avctx = priv->avctx; AVPacket pkt; @@ -254,6 +258,12 @@ char **lavc_conv_decode(struct lavc_conv *priv, struct demux_packet *packet) if (ret < 0) { MP_ERR(priv, "Error decoding subtitle\n"); } else if (got_sub) { + *sub_pts = packet->pts + mp_pts_from_av(priv->cur.start_display_time, + &avctx->time_base); + *sub_duration = mp_pts_from_av(priv->cur.end_display_time - + priv->cur.start_display_time, + &avctx->time_base); + for (int i = 0; i < priv->cur.num_rects; i++) { if (priv->cur.rects[i]->w > 0 && priv->cur.rects[i]->h > 0) MP_WARN(priv, "Ignoring bitmap subtitle.\n"); |