-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
46752a8
commit 11b0ee9
Showing
4 changed files
with
62 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import gi | ||
|
||
gi.require_version('Gst', '1.0') | ||
from gi.repository import Gst, GLib | ||
|
||
Gst.init(None) | ||
|
||
pipeline = Gst.parse_launch(""" | ||
filesrc location=examples/music.mp3 ! mpegaudioparse ! mpg123audiodec ! \ | ||
ebur128 name=ebur128 momentary=true shortterm=true global=true window=5000 range=true sample-peak=true true-peak=true ! \ | ||
autoaudiosink | ||
""") | ||
|
||
element = pipeline.get_by_name("ebur128") | ||
|
||
def on_message(bus, message): | ||
if message.type == Gst.MessageType.ELEMENT and message.src == element: | ||
structure = message.get_structure() | ||
|
||
success, timestamp = structure.get_uint64("timestamp") | ||
success, momentary_loudness = structure.get_double("momentary") | ||
success, shortterm_loudness = structure.get_double("shortterm") | ||
success, global_loudness = structure.get_double("global") | ||
success, window_loudness = structure.get_double("window") | ||
success, loudness_range = structure.get_double("range") | ||
true_peak = structure.get_value("true-peak") | ||
sample_peak = structure.get_value("true-peak") | ||
|
||
print({ | ||
"timestamp": timestamp, | ||
"momentary_loudness": momentary_loudness, | ||
"shortterm_loudness": shortterm_loudness, | ||
"global_loudness": global_loudness, | ||
"window_loudness": window_loudness, | ||
"loudness_range": loudness_range, | ||
"true_peak": true_peak, | ||
"sample_peak": sample_peak | ||
}) | ||
|
||
bus = pipeline.get_bus() | ||
bus.add_signal_watch() | ||
bus.connect("message", on_message) | ||
|
||
pipeline.set_state(Gst.State.PLAYING) | ||
|
||
mainloop = GLib.MainLoop() | ||
mainloop.run() |
File renamed without changes.