Latest News

Follow the latest news on OpenShot Video Editor!


,

The Gstreamer framework is multi-threaded, which means it runs in a different thread (or many threads)... and thus you can not directly communicate with it via Python. Requests have to be sent to the pipeline, and they are completed as soon as possible. However, it goes both ways. When Gstreamer wants to communicate with your program, it must send messages through what they call a "bus".

Think of the bus as a signal. All you have to do in Python is create a signal handler method and connect it to the bus signal.

def on_message(self, bus, message):
self.bus = self.pipeline.get_bus()
self.bus.enable_sync_message_emission()
self.bus.add_signal_watch()
self.bus.connect('sync-message::element', self.on_sync_message)
self.bus.connect('message', self.on_message)

def on_message(self, bus, message):
print message

All sorts of interesting information is passed through the bus, such as:
  • MP3 Tags: Artist, Album, Track, Genre, etc...
  • Codec
  • Bitrate
  • and many more...
The pipeline will only send messages through the bus when media has been pre-rolled, which is a term that means it's been put in a "PAUSED" state... thus, it has started to buffer. I'm still working on my media inspector Python program, and it will use the bus heavily to figure out the details of a specific media file (video or audio).

Share to Facebook Share to Twitter Share to MySpace Stumble It Share to Reddit Share to Delicious More...

0 comments

Subscribe to: Post Comments (Atom)