summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRicardo Constantino <wiiaboo@gmail.com>2017-08-21 17:33:02 +0100
committerRicardo Constantino <wiiaboo@gmail.com>2017-08-21 18:12:10 +0100
commit371000108acb40a99412316fe1bba2883441c38a (patch)
treef07b844cf2e689ba7dce1c48de16cb0b38dc5d1d
parent0bfeba2d9a0f7d76e3a93ec79734c50512ea7048 (diff)
downloadmpv-371000108acb40a99412316fe1bba2883441c38a.tar.bz2
mpv-371000108acb40a99412316fe1bba2883441c38a.tar.xz
TOOLS/lua/autodeint: update to lavfi-bridge
Also use lavfi setfield instead of removed field-dominance. Remove missing remainder of field-dominance in docs.
-rw-r--r--DOCS/man/vf.rst1
-rw-r--r--TOOLS/lua/autodeint.lua65
2 files changed, 38 insertions, 28 deletions
diff --git a/DOCS/man/vf.rst b/DOCS/man/vf.rst
index 0c43698149..3a5ba7109c 100644
--- a/DOCS/man/vf.rst
+++ b/DOCS/man/vf.rst
@@ -838,7 +838,6 @@ Available mpv-only filters are:
the mode selected with ``deint-mode``.
``deint-mode=<first-field|bob|temporal|temporal-spatial>``
Select deinterlacing mode (default: temporal).
- All modes respect ``--field-dominance``.
Note that there's currently a mechanism that allows the ``vdpau`` VO to
change the ``deint-mode`` of auto-inserted ``vdpaupp`` filters. To avoid
diff --git a/TOOLS/lua/autodeint.lua b/TOOLS/lua/autodeint.lua
index cde30db5e8..b891c9a838 100644
--- a/TOOLS/lua/autodeint.lua
+++ b/TOOLS/lua/autodeint.lua
@@ -3,13 +3,13 @@
-- currently playing video.
--
-- It registers the key-binding ctrl+d, which when pressed, inserts the filters
--- ``vf=lavfi=idet,pullup,vf=lavfi=idet``. After 4 seconds, it removes these
+-- ``vf=idet,lavfi-pullup,idet``. After 4 seconds, it removes these
-- filters and decides whether the content is progressive, interlaced, or
-- telecined and the interlacing field dominance.
--
-- Based on this information, it may set mpv's ``deinterlace`` property (which
-- usually inserts the yadif filter), or insert the ``pullup`` filter if the
--- content is telecined. It also sets mpv's ``field-dominance`` property.
+-- content is telecined. It also sets field dominance with lavfi setfield.
--
-- OPTIONS:
-- The default detection time may be overridden by adding
@@ -22,16 +22,14 @@
-- To see counts of the various types of frames for each detection phase,
-- the verbosity can be increased with
--
--- --msg-level autodeint=v
---
--- This script requires a recent version of ffmpeg for which the idet
--- filter adds the required metadata.
+-- --msg-level=autodeint=v
require "mp.msg"
script_name = mp.get_script_name()
detect_label = string.format("%s-detect", script_name)
pullup_label = string.format("%s", script_name)
+dominance_label = string.format("%s-dominance", script_name)
ivtc_detect_label = string.format("%s-ivtc-detect", script_name)
-- number of seconds to gather cropdetect data
@@ -55,6 +53,10 @@ function del_filter_if_present(label)
return false
end
+local function add_vf(label, filter)
+ return mp.command(('vf add @%s:%s'):format(label, filter))
+end
+
function start_detect()
-- exit if detection is already in progress
if timer then
@@ -64,11 +66,13 @@ function start_detect()
mp.set_property("deinterlace","no")
del_filter_if_present(pullup_label)
+ del_filter_if_present(dominance_label)
- -- insert the detection filter
- local cmd = string.format('vf add @%s:lavfi=graph="idet",@%s:pullup,@%s:lavfi=graph="idet"',
- detect_label, pullup_label, ivtc_detect_label)
- if not mp.command(cmd) then
+ -- insert the detection filters
+ if not (add_vf(detect_label, 'idet') and
+ add_vf(dominance_label, 'setfield=mode=auto') and
+ add_vf(pullup_label, 'lavfi-pullup') and
+ add_vf(ivtc_detect_label, 'idet')) then
mp.msg.error("failed to insert detection filters")
return
end
@@ -88,12 +92,12 @@ progressive, interlaced_tff, interlaced_bff, interlaced = 0, 1, 2, 3, 4
function judge(label)
-- get the metadata
local result = mp.get_property_native(string.format("vf-metadata/%s", label))
- num_tff = tonumber(result["lavfi.idet.multiple.tff"])
- num_bff = tonumber(result["lavfi.idet.multiple.bff"])
- num_progressive = tonumber(result["lavfi.idet.multiple.progressive"])
- num_undetermined = tonumber(result["lavfi.idet.multiple.undetermined"])
- num_interlaced = num_tff + num_bff
- num_determined = num_interlaced + num_progressive
+ local num_tff = tonumber(result["lavfi.idet.multiple.tff"])
+ local num_bff = tonumber(result["lavfi.idet.multiple.bff"])
+ local num_progressive = tonumber(result["lavfi.idet.multiple.progressive"])
+ local num_undetermined = tonumber(result["lavfi.idet.multiple.undetermined"])
+ local num_interlaced = num_tff + num_bff
+ local num_determined = num_interlaced + num_progressive
mp.msg.verbose(label.." progressive = "..num_progressive)
mp.msg.verbose(label.." interlaced-tff = "..num_tff)
@@ -116,26 +120,33 @@ end
function select_filter()
-- handle the first detection filter results
- verdict = judge(detect_label)
+ local verdict = judge(detect_label)
+ local ivtc_verdict = judge(ivtc_detect_label)
+ local dominance = "auto"
if verdict == progressive then
mp.msg.info("progressive: doing nothing")
stop_detect()
+ del_filter_if_present(dominance_label)
+ del_filter_if_present(pullup_label)
return
- elseif verdict == interlaced_tff then
- mp.set_property("field-dominance", "top")
- elseif verdict == interlaced_bff then
- mp.set_property("field-dominance", "bottom")
- elseif verdict == interlaced then
- mp.set_property("field-dominance", "auto")
+ else
+ if verdict == interlaced_tff then
+ dominance = "tff"
+ add_vf(dominance_label, 'setfield=mode='..dominance)
+ elseif verdict == interlaced_bff then
+ dominance = "bff"
+ add_vf(dominance_label, 'setfield=mode='..dominance)
+ else
+ del_filter_if_present(dominance_label)
+ end
end
-- handle the ivtc detection filter results
- verdict = judge(ivtc_detect_label)
- if verdict == progressive then
- mp.msg.info(string.format("telecinied with %s field dominance: using pullup", mp.get_property("field-dominance")))
+ if ivtc_verdict == progressive then
+ mp.msg.info(string.format("telecined with %s field dominance: using pullup", dominance))
stop_detect()
else
- mp.msg.info(string.format("interlaced with %s field dominance: setting deinterlace property", mp.get_property("field-dominance")))
+ mp.msg.info(string.format("interlaced with %s field dominance: setting deinterlace property", dominance))
del_filter_if_present(pullup_label)
mp.set_property("deinterlace","yes")
stop_detect()