summaryrefslogtreecommitdiffstats
path: root/demux/demux_lavf.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-03-04 00:28:10 +0100
committerwm4 <wm4@nowhere>2014-03-04 00:28:10 +0100
commit5606cf29482b096df7a6b4b515c9ecb3d40fdf89 (patch)
tree94445a6a8ffe27ccaed6c39677f1478a37950580 /demux/demux_lavf.c
parent43e997ca07f43598f49e1a0f1f3c52e08a9179f3 (diff)
downloadmpv-5606cf29482b096df7a6b4b515c9ecb3d40fdf89.tar.bz2
mpv-5606cf29482b096df7a6b4b515c9ecb3d40fdf89.tar.xz
sub: use new FFmpeg API to check MicroDVD FPS
Before this, it wasn't possible to distinguish MicroDVD subtitles without FPS header, and subtitles with FPS header equal to FFmpeg's fallback FPS.
Diffstat (limited to 'demux/demux_lavf.c')
-rw-r--r--demux/demux_lavf.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c
index d85e4b8095..cc503383ea 100644
--- a/demux/demux_lavf.c
+++ b/demux/demux_lavf.c
@@ -461,11 +461,19 @@ static void handle_stream(demuxer_t *demuxer, int i)
sh_sub->w = codec->width;
sh_sub->h = codec->height;
- // Hack for MicroDVD: if time_base matches the ffmpeg microdvd reader's
- // default FPS (23.976), assume the MicroDVD file did not declare a
- // FPS, and the MicroDVD file uses frame based timing.
- if (codec->time_base.num == 125 && codec->time_base.den == 2997)
- sh_sub->frame_based = true;
+ if (matches_avinputformat_name(priv, "microdvd")) {
+ AVRational r;
+ if (av_opt_get_q(avfc, "subfps", AV_OPT_SEARCH_CHILDREN, &r) >= 0) {
+ // File headers don't have a FPS set.
+ if (r.num < 1 || r.den < 1)
+ sh_sub->frame_based = av_q2d(av_inv_q(codec->time_base));
+ } else {
+ // Older libavcodec versions. If the FPS matches the microdvd
+ // reader's default, assume it uses frame based timing.
+ if (codec->time_base.num == 125 && codec->time_base.den == 2997)
+ sh_sub->frame_based = 23.976;
+ }
+ }
break;
}
case AVMEDIA_TYPE_ATTACHMENT: {