aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaZderMind <git@mazdermind.de>2015-08-29 19:23:54 +0200
committerMaZderMind <git@mazdermind.de>2015-08-29 19:23:54 +0200
commit5b29fca06e8a4910676dca71874d1df531c86198 (patch)
tree93566d6279344ffcc7c19311ea28ea6992b72732
parentcb93b84fc636fcedfe55bb4be65f79faad39881a (diff)
remove capsfilter and videoscaler, use these features from compositor instead
this not only solved the sync-mixing-issue but also the non-square-pixel problems
-rwxr-xr-xvoctocore/experiments/sync-videomix.py21
-rw-r--r--voctocore/lib/videomix.py46
2 files changed, 21 insertions, 46 deletions
diff --git a/voctocore/experiments/sync-videomix.py b/voctocore/experiments/sync-videomix.py
index ce8eb1e..e496091 100755
--- a/voctocore/experiments/sync-videomix.py
+++ b/voctocore/experiments/sync-videomix.py
@@ -17,19 +17,13 @@ class Example:
pipeline = """
videotestsrc pattern=red !
{caps} !
- videoscale !
- capsfilter name=caps0 !
- identity sync=true signal-handoffs=false !
mix.
videotestsrc pattern=green !
{caps} !
- videoscale !
- capsfilter name=caps1 !
- identity sync=true signal-handoffs=false !
mix.
- videomixer name=mix !
+ compositor name=mix !
{caps} !
identity name=sig !
videoconvert !
@@ -60,9 +54,6 @@ class Example:
self.pad0 = self.pipeline.get_by_name('mix').get_static_pad('sink_0')
self.pad1 = self.pipeline.get_by_name('mix').get_static_pad('sink_1')
- self.caps0 = self.pipeline.get_by_name('caps0')
- self.caps1 = self.pipeline.get_by_name('caps1')
-
self.state = False
def reconfigure(self, object, buffer):
@@ -70,25 +61,23 @@ class Example:
if self.state:
padA = self.pad0
padB = self.pad1
- capsA = self.caps0
- capsB = self.caps1
else:
padA = self.pad1
padB = self.pad0
- capsA = self.caps1
- capsB = self.caps0
padA.set_property('xpos', 10)
padA.set_property('ypos', 10)
padA.set_property('alpha', 1.0)
padA.set_property('zorder', 1)
- capsA.set_property('caps', Gst.Caps.from_string('video/x-raw,width=320,height=180'))
+ padA.set_property('width', 0)
+ padA.set_property('height', 0)
padB.set_property('xpos', 310)
padB.set_property('ypos', 170)
padB.set_property('alpha', 1.0)
padB.set_property('zorder', 2)
- capsB.set_property('caps', Gst.Caps.from_string('video/x-raw,width=480,height=270'))
+ padB.set_property('width', 480)
+ padB.set_property('height', 270)
self.state = not self.state
return True
diff --git a/voctocore/lib/videomix.py b/voctocore/lib/videomix.py
index ac00d6d..e0beefb 100644
--- a/voctocore/lib/videomix.py
+++ b/voctocore/lib/videomix.py
@@ -12,8 +12,6 @@ class CompositeModes(Enum):
picture_in_picture = 3
class PadState(object):
- noScaleCaps = Gst.Caps.from_string('video/x-raw')
-
def __init__(self):
self.reset()
@@ -22,7 +20,8 @@ class PadState(object):
self.xpos = 0
self.ypos = 0
self.zorder = 1
- self.scaleCaps = PadState.noScaleCaps
+ self.width = 0
+ self.height = 0
class VideoMix(object):
log = logging.getLogger('VideoMix')
@@ -62,9 +61,6 @@ class VideoMix(object):
for idx, name in enumerate(self.names):
pipeline += """
intervideosrc channel=video_{name}_mixer !
- {caps} !
- videoscale !
- capsfilter name=caps_{idx} caps=video/x-raw !
mix.
""".format(
name=name,
@@ -161,23 +157,21 @@ class VideoMix(object):
xa = 0
xb = width - targetWidth
- scaleCaps = Gst.Caps.from_string('video/x-raw,width=%u,height=%u,pixel-aspect-ratio=1/1' % (targetWidth, targetHeight))
-
for idx, name in enumerate(self.names):
pad = self.padState[idx]
pad.reset()
+ pad.ypos = y
+ pad.width = targetWidth
+ pad.height = targetHeight
+
if idx == self.sourceA:
pad.xpos = xa
- pad.ypos = y
pad.zorder = 1
- pad.scaleCaps = scaleCaps
elif idx == self.sourceB:
pad.xpos = xb
- pad.ypos = y
pad.zorder = 2
- pad.scaleCaps = scaleCaps
else:
pad.alpha = 0
@@ -228,22 +222,19 @@ class VideoMix(object):
]
self.log.debug('B-Video-Position calculated to %u/%u', bpos[0], bpos[1])
- aCaps = Gst.Caps.from_string('video/x-raw,width=%u,height=%u' % tuple(asize))
- bCaps = Gst.Caps.from_string('video/x-raw,width=%u,height=%u' % tuple(bsize))
-
for idx, name in enumerate(self.names):
pad = self.padState[idx]
pad.reset()
if idx == self.sourceA:
pad.xpos, pad.ypos = apos
+ pad.width, pad.height = asize
pad.zorder = 1
- pad.scaleCaps = aCaps
elif idx == self.sourceB:
pad.xpos, pad.ypos = bpos
+ pad.width, pad.height = bsize
pad.zorder = 2
- pad.scaleCaps = bCaps
else:
pad.alpha = 0
@@ -274,8 +265,6 @@ class VideoMix(object):
]
self.log.debug('PIP-Position calculated to %u/%u', pippos[0], pippos[1])
- scaleCaps = Gst.Caps.from_string('video/x-raw,width=%u,height=%u,pixel-aspect-ratio=1/1' % tuple(pipsize))
-
for idx, name in enumerate(self.names):
pad = self.padState[idx]
pad.reset()
@@ -284,28 +273,25 @@ class VideoMix(object):
pass
elif idx == self.sourceB:
pad.xpos, pad.ypos = pippos
+ pad.width, pad.height = pipsize
pad.zorder = 2
- pad.scaleCaps = scaleCaps
else:
pad.alpha = 0
- def getMixerpadAndCapsfilter(self, idx):
- # mixerpad 0 = background
- mixerpad = self.mixingPipeline.get_by_name('mix').get_static_pad('sink_%u' % (idx+1))
- capsfilter = self.mixingPipeline.get_by_name('caps_%u' % idx)
- return mixerpad, capsfilter
-
def applyMixerState(self):
for idx, state in enumerate(self.padState):
- mixerpad, capsfilter = self.getMixerpadAndCapsfilter(idx)
- self.log.debug('Reconfiguring Mixerpad %u to x/y=%u/%u, alpha=%0.2f, zorder=%u', idx, state.xpos, state.ypos, state.alpha, state.zorder)
- self.log.debug('Reconfiguring Capsfilter %u to %s', idx, state.scaleCaps.to_string())
+ # mixerpad 0 = background
+ mixerpad = self.mixingPipeline.get_by_name('mix').get_static_pad('sink_%u' % (idx+1))
+
+ self.log.debug('Reconfiguring Mixerpad %u to x/y=%u/%u, w/h=%u/%u alpha=%0.2f, zorder=%u', \
+ idx, state.xpos, state.ypos, state.width, state.height, state.alpha, state.zorder)
mixerpad.set_property('xpos', state.xpos)
mixerpad.set_property('ypos', state.ypos)
+ mixerpad.set_property('width', state.width)
+ mixerpad.set_property('height', state.height)
mixerpad.set_property('alpha', state.alpha)
mixerpad.set_property('zorder', state.zorder)
- capsfilter.set_property('caps', state.scaleCaps)
def on_handoff(self, object, buffer):
if self.padStateDirty: