I was able to solve the problem with the advice and sample code generously given to me by Profile - Honey_Patouceul - GStreamer Discourse
The code doesn’t
address the GstCodecVideoAlphaMeta question because it’s not necessary to set up manually if one sets up the pipelines as Honey has demonstrated.
#!/usr/bin/env python
import time
import gi
gi.require_version('Gst', '1.0')
from gi.repository import Gst
Gst.init(None)
# Background video source pipeline
p1 = Gst.parse_launch ('filesrc location=background.avi ! decodebin ! videoconvert ! video/x-raw,format=RGBA,width=1920,height=1080,framerate=24/1 ! intervideosink channel=background')
if not p1:
print('Failed to launch p1')
exit(-1)
# Video overlay pipeline
p2 = Gst.parse_launch ('filesrc location=movie-webm.webm ! matroskademux ! queue ! parsebin ! vp9alphadecodebin ! video/x-raw,format=A420 ! videoconvert ! video/x-raw,format=RGBA ! videoscale ! videorate ! video/x-raw,format=RGBA,width=1920,height=1080,framerate=24/1 ! intervideosink channel=overlay')
if not p2:
print('Failed to launch p2')
exit(-1)
# Composing pipeline
p3 = Gst.parse_launch ('compositor name=comp sink_0::zorder=1 sink_1::width=1920 sink_1::height=1080 sink_1::zorder=2 ! video/x-raw,format=RGBA,width=1920,height=1080,framerate=24/1 ! videoconvert ! autovideosink intervideosrc channel=background ! comp.sink_0')
if not p3:
print('Failed to launch p3')
exit(-1)
comp = p3.get_by_name("comp");
print('Starting without overlay')
p1.set_state(Gst.State.PLAYING)
p3.set_state(Gst.State.PLAYING)
# Run for 3s
time.sleep(3)
print('Add overlay')
p3.set_state(Gst.State.PAUSED)
newSinkPad = comp.request_pad_simple("sink_1")
overlay = Gst.ElementFactory.make("intervideosrc")
overlay.set_property("channel", "overlay")
p3.add(overlay)
overlay.sync_state_with_parent()
newSrcPad = overlay.get_static_pad("src")
t = newSrcPad.link(newSinkPad);
p2.set_state(Gst.State.PLAYING)
p3.set_state(Gst.State.PLAYING)
# Run for 5s
time.sleep(5)
print('Remove overlay')
p2.set_state(Gst.State.PAUSED)
p3.set_state(Gst.State.PAUSED)
newSrcPad.unlink(newSinkPad)
comp.remove_pad(newSinkPad);
p3.remove(overlay)
p3.set_state(Gst.State.PLAYING)
# Wait for 3s
time.sleep(3)
# Add overlay
print('Add overlay')
p3.set_state(Gst.State.PAUSED)
newSinkPad = comp.request_pad_simple("sink_1")
overlay = Gst.ElementFactory.make("intervideosrc")
overlay.set_property("channel", "overlay")
p3.add(overlay)
overlay.sync_state_with_parent()
newSrcPad = overlay.get_static_pad("src")
t = newSrcPad.link(newSinkPad);
p2.set_state(Gst.State.PLAYING)
p3.set_state(Gst.State.PLAYING)
# Run for 5s
time.sleep(5)
print('Done. Bye')
“the background video is first played alone, after 3s it adds the overlay, plays for 5s, removes the overlay, runs for 3s, adds again the overlay and plays for 5s.”
Thank you, Honey_Patouceul!