Advertisement
simonedare_

Untitled

Dec 12th, 2023
1,206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.41 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. import time
  3. import sys
  4. import gi
  5.  
  6. gi.require_version("Gst", "1.0")
  7.  
  8. from gi.repository import Gst
  9.  
  10.  
  11. def main():
  12.  
  13.     Gst.init(sys.argv)  # init gstreamer
  14.     Gst.debug_set_default_threshold(Gst.DebugLevel.WARNING)
  15.  
  16.     serial = None
  17.  
  18.     pipeline = Gst.parse_launch("tcambin name=bin"
  19.                                 " ! video/x-raw,format=BGRx,width=1920,height=1080,framerate=1/1"
  20.                                 " ! videoconvert"
  21.                                 " ! avimux"
  22.                                 " ! filesink name=fsink")
  23.  
  24.     # serial is defined, thus make the source open that device
  25.     if serial is not None:
  26.         camera = pipeline.get_by_name("bin")
  27.         camera.set_property("serial", serial)
  28.  
  29.         names = camera.get_tcam_property_names()
  30.  
  31.         for name in property_names:
  32.             try:
  33.                 base = self.source.get_tcam_property(name)
  34.                 print("{}\t{}".format(base.get_display_name(), name))
  35.             except Exception as error:
  36.                 raise RuntimeError(f"Failed to get property '{name}'") from error
  37.  
  38.     file_location = "/root/recordings/test-sdr-" + str(int(time.time())) + ".avi"
  39.  
  40.     fsink = pipeline.get_by_name("fsink")
  41.     fsink.set_property("location", file_location)
  42.  
  43.     pipeline.set_state(Gst.State.PLAYING)
  44.  
  45.     print("recording 5 secs..")
  46.  
  47.     time.sleep(5)
  48.     print("stop recording")
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement