Bla-di-blabla or constructive feedback? It might be more helpful if you could tell me how to properly stop a recording in gstreamer/pygst Try 0.3.0, it should be better in closing the stream after recording it. It still won't play on my Win7 x64 VLC, but perhaps it does on Ubuntu now?
#! /usr/bin/env python import platform import gtk import gst class RecordMe: def __init__(self): window = gtk.Window(gtk.WINDOW_TOPLEVEL) window.set_title('A Recorder') window.connect('destroy', gtk.main_quit) vbox = gtk.VBox() window.add(vbox) self.movie_window = gtk.DrawingArea() vbox.add(self.movie_window) hbox = gtk.HBox() vbox.pack_start(hbox, False) hbox.set_border_width(10) hbox.pack_start(gtk.Label()) self.button = gtk.Button('Record') self.button.connect('clicked', self.start_stop) hbox.pack_start(self.button, False) self.button2 = gtk.Button('Quit') self.button2.connect('clicked', self.exit) hbox.pack_start(self.button2, False) hbox.add(gtk.Label()) window.show_all() self.machine = platform.uname()[4] sampleRate = 22050 if self.machine == 'armv7l': self.player = gst.Pipeline('ThePipe') src = gst.element_factory_make('pulsesrc','src') self.player.add(src) caps = gst.element_factory_make('capsfilter', 'caps') caps.set_property('caps', gst.caps_from_string( 'audio/x-raw-int,width=16,depth=16,\ rate=%d,channels=1'%sampleRate)) self.player.add(caps) enc = gst.element_factory_make('wavenc','enc') self.player.add(enc) sink = gst.element_factory_make('filesink', 'sink') sink.set_property('location','testme.wav') self.player.add(sink) pad = sink.get_pad('sink') pad.add_buffer_probe(self.doBuffer) src.link(caps) caps.link(enc) enc.link(sink) bus = self.player.get_bus() bus.add_signal_watch() bus.enable_sync_message_emission() bus.connect('message', self.on_message) def doBuffer(self, pad, buffer): n = len(buffer) if n == 44: print 'found WAV header' elif n > 0: self.totalAudioBytes = self.totalAudioBytes + n return True def start_stop(self, w): if self.button.get_label() == 'Record': self.totalAudioBytes = 0 self.button.set_label('Stop') self.player.set_state(gst.STATE_PLAYING) else: print 'total audio bytes',self.totalAudioBytes self.player.set_state(gst.STATE_NULL) self.button.set_label('Record') def exit(self, widget, data=None): gtk.main_quit() def on_message(self, bus, message): t = message.type if t == gst.MESSAGE_EOS: self.player.set_state(gst.STATE_NULL) self.button.set_label('Record') elif t == gst.MESSAGE_ERROR: err, debug = message.parse_error() print 'Error: %s' % err, debug self.player.set_state(gst.STATE_NULL) self.button.set_label('Record') if __name__ == '__main__': RecordMe() gtk.main()