<commit_before>#!/usr/bin/python

# gslevels.py
# report audio levels
# to figure out what files are messed up

# http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-good-plugins/html/gst-plugins-good-plugins-level.html

# gst-launch-1.0 uridecodebin name=decode uri="file://$PWD/SC1ATK103.mov" ! audioconvert ! level name=wavelevel post-messages=true ! fakesink --messages

# gst-launch-1.0 filesrc location="SC1ATK105.mov" ! qtdemux ! audioconvert ! level name=wavelevel post-messages=true ! fakesink --messages

import optparse
import numpy
import os

from gi.repository import Gst, GLib
Gst.init(None)

class AudioPreviewer:

    count = 0
    interval = 1.0  ## buffer size in seconds 
    verbose = False
    uri = None
    location = None

    def mk_pipe(self):

        # self.pipeline = Gst.parse_launch( "uridecodebin name=decode ! audioconvert ! level name=wavelevel ! fakesink name=faked" )
        self.pipeline = Gst.parse_launch( 
            "filesrc name=filesrc ! qtdemux ! audioconvert ! level name=wavelevel ! fakesink"
            )

        # if self.uri.startswith('/'):
        #    self.uri = "file://" + self.uri
        # decode = self.pipeline.get_by_name("decode")
        # decode.set_property( 'uri', self.uri )

        filesrc = self.pipeline.get_by_name("filesrc")
        filesrc.set_property( 'location', self.location )

        wavelevel = self.pipeline.get_by_name( 'wavelevel' )
        wavelevel.set_property( 'interval', int(self.interval * Gst.SECOND))
        wavelevel.set_property( 'post-messages', True )

        bus = self.pipeline.get_bus()
        bus.add_signal_watch()
        bus.connect("message", self._messageCb)

        return

    def process(self, levs):
        # hook for more useful things.
        print(self.count, levs)
        self.count += 1
        return
<commit_msg>replace quick time demuxer with auto-magic decodebin.<commit_after>#!/usr/bin/python

# gslevels.py
# report audio levels
# to figure out what files are messed up

# http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-good-plugins/html/gst-plugins-good-plugins-level.html

# gst-launch-1.0 uridecodebin name=decode uri="file://$PWD/SC1ATK103.mov" ! audioconvert ! level name=wavelevel post-messages=true ! fakesink --messages

# gst-launch-1.0 filesrc location="SC1ATK105.mov" ! qtdemux ! audioconvert ! level name=wavelevel post-messages=true ! fakesink --messages

import optparse
import numpy
import os

import gi
gi.require_version('Gst', '1.0')
from gi.repository import Gst, GLib
Gst.init(None)

class AudioPreviewer:

    count = 0
    interval = 1.0  ## buffer size in seconds 
    verbose = False
    uri = None
    location = None

    def mk_pipe(self):

        # self.pipeline = Gst.parse_launch( "uridecodebin name=decode ! audioconvert ! level name=wavelevel ! fakesink name=faked" )
        # self.pipeline = Gst.parse_launch( "filesrc name=filesrc ! qtdemux ! audioconvert ! level name=wavelevel ! fakesink")
        self.pipeline = Gst.parse_launch( 
            "filesrc name=filesrc ! decodebin ! audioconvert ! level name=wavelevel ! fakesink"
            )

        # if self.uri.startswith('/'):
        #    self.uri = "file://" + self.uri
        # decode = self.pipeline.get_by_name("decode")
        # decode.set_property( 'uri', self.uri )

        filesrc = self.pipeline.get_by_name("filesrc")
        filesrc.set_property( 'location', self.location )

        wavelevel = self.pipeline.get_by_name( 'wavelevel' )
        wavelevel.set_property( 'interval', int(self.interval * Gst.SECOND))
        wavelevel.set_property( 'post-messages', True )

        bus = self.pipeline.get_bus()
        bus.add_signal_watch()
        bus.connect("message", self._messageCb)

        return

    def process(self, levs):
        # hook for more useful things.
        print(self.count, levs)
        self.count += 1
        return

{'fraction_non_alphanumeric': 0.11748216106014271, 'fraction_numerical': 0.008664627930682976, 'mean_word_length': 2.948692152917505, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2925635', 'n_tokens_mistral': 1320, 'n_tokens_neox': 1269, 'n_words': 271}