-
-
Save SpirosArk/5ec7bd79855e3efc758d0a7802ae459c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gi | |
import sys | |
gi.require_version('Gst', '1.0') | |
from gi.repository import Gst | |
Gst.init(None) | |
appsrc = Gst.ElementFactory.make("appsrc", "appsrc") | |
filesink = Gst.ElementFactory.make("filesink", "filesink") | |
filesink.set_property("location", "test.dat") | |
pipeline = Gst.Pipeline() | |
pipeline.add(appsrc) | |
pipeline.add(filesink) | |
appsrc.link(filesink) | |
pipeline.set_state(Gst.State.PLAYING) | |
data = "1234" * 12 | |
print ("Using data: %s" % data) | |
buf = Gst.Buffer.new_wrapped(data.encode()) | |
appsrc.emit("push-buffer", buf) | |
pipeline.send_event(Gst.Event.new_eos()) | |
result = open("test.dat").read() | |
print ("Result : %s" % result) | |
pipeline.set_state(Gst.State.NULL) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Update: Code is finally working. instead of
new_allocate
i usednew_wrapped
in order for the data to been wrapped immediately.data.encode()
was used because data is not in range of 0 to 255, so if you triedint(data)
there were overflow issues.