From dbc00297cc36e8470ff9996111077a72ab8a4a5f Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 3 Jan 2015 03:37:05 +0100 Subject: vf_vapoursynth: pass through container FPS value This is basically a hack; but apparently a needed one, since many vapoursynth filters insist on having a FPS set. We need to apply the FPS override before creating the filters. Also change some terminal output related to the FPS value. --- DOCS/man/vf.rst | 9 +++++++++ player/video.c | 18 ++++++++---------- video/filter/vf.h | 2 ++ video/filter/vf_vapoursynth.c | 1 + 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/DOCS/man/vf.rst b/DOCS/man/vf.rst index 4750c76c6f..322412dae8 100644 --- a/DOCS/man/vf.rst +++ b/DOCS/man/vf.rst @@ -921,6 +921,15 @@ Available filters are: Display size of the video. Can be different from video size if the video does not use square pixels (e.g. DVD). + ``container_fps`` + FPS value as reported by file headers. This value can be wrong or + completely broken (e.g. 0 or NaN). Even if the value is correct, + if another filter changes the real FPS (by dropping or inserting + frames), the value of this variable might not be useful. Note that + the ``--fps`` command line option overrides this value. + + Useful for some filters which insist on having a FPS. + ``vapoursynth-lazy`` The same as ``vapoursynth``, but doesn't load Python scripts. Instead, a custom backend using Lua and the raw VapourSynth API is used. The syntax diff --git a/player/video.c b/player/video.c index 49476b7235..fd8df9cead 100644 --- a/player/video.c +++ b/player/video.c @@ -180,6 +180,7 @@ static void recreate_video_filters(struct MPContext *mpctx) d_video->vfilter->hwdec = d_video->hwdec_info; d_video->vfilter->wakeup_callback = wakeup_playloop; d_video->vfilter->wakeup_callback_ctx = mpctx; + d_video->vfilter->container_fps = d_video->fps; vf_append_filter_list(d_video->vfilter, opts->vf_settings); @@ -289,6 +290,13 @@ int reinit_video_chain(struct MPContext *mpctx) d_video->fps = sh->video->fps; d_video->vo = mpctx->video_out; + if (opts->force_fps) { + d_video->fps = opts->force_fps; + MP_INFO(mpctx, "FPS forced to %5.3f.\n", d_video->fps); + MP_INFO(mpctx, "Use --no-correct-pts to force FPS based timing.\n"); + } + update_fps(mpctx); + vo_control(mpctx->video_out, VOCTRL_GET_HWDEC_INFO, &d_video->hwdec_info); recreate_video_filters(mpctx); @@ -312,16 +320,6 @@ int reinit_video_chain(struct MPContext *mpctx) reset_video_state(mpctx); reset_subtitle_state(mpctx); - if (opts->force_fps) { - d_video->fps = opts->force_fps; - MP_INFO(mpctx, "FPS forced to be %5.3f.\n", d_video->fps); - } - if (!sh->video->fps && !opts->force_fps && !opts->correct_pts) { - MP_ERR(mpctx, "FPS not specified in the " - "header or invalid, use the -fps option.\n"); - } - update_fps(mpctx); - return 1; err_out: diff --git a/video/filter/vf.h b/video/filter/vf.h index 4ff8398229..37ad4ca29c 100644 --- a/video/filter/vf.h +++ b/video/filter/vf.h @@ -123,6 +123,8 @@ struct vf_chain { struct mp_image_params output_params; uint8_t allowed_output_formats[IMGFMT_END - IMGFMT_START]; + double container_fps; + struct mp_log *log; struct MPOpts *opts; struct mpv_global *global; diff --git a/video/filter/vf_vapoursynth.c b/video/filter/vf_vapoursynth.c index 30fd992071..4b06d28b76 100644 --- a/video/filter/vf_vapoursynth.c +++ b/video/filter/vf_vapoursynth.c @@ -590,6 +590,7 @@ static int reinit_vs(struct vf_instance *vf) p->vsapi->propSetInt(vars, "video_in_dw", p->fmt_in.d_w, 0); p->vsapi->propSetInt(vars, "video_in_dh", p->fmt_in.d_h, 0); + p->vsapi->propSetFloat(vars, "container_fps", vf->chain->container_fps, 0); if (p->drv->load(vf, vars) < 0) goto error; -- cgit v1.2.3