flacenc + seek
Platon
platoshko at gmail.com
Wed Nov 2 06:16:26 PDT 2011
hi guys!
I'm writing an audio encoder, and I'm having trouble.
When I encode an audio segment to flac, the encoder generates invalid file.
$./encoder.py
(encoder.py:10109): GStreamer-CRITICAL **: _gst_util_uint64_scale:
assertion `denom != 0' failed
True
eos
$ file dest.flac
file dest.flac: MPEG ADTS, AAC, v2 LC, 24 kHz, stereo+center+LFE
Thanks
Platon
#!/usr/bin/python
import pygst
pygst.require("0.10")
import gst
import gobject
import sys
from urllib import quote
from threading import Semaphore, Thread
FILE="/media/love/lossless/The Lovin' Spoonful/The Very Best Of/The
Lovin' Spoonful - The Very Best Of.ape"
sem = Semaphore(0)
eos = Semaphore(0)
state = None
def on_message(bus, message):
t = message.type
src = message.src.get_name()
global sem,eos, state
if src == 'pipeline' and t == gst.MESSAGE_STATE_CHANGED:
os,ns,pn = message.parse_state_changed()
if ns == state:
state = None
sem.release()
elif t == gst.MESSAGE_EOS:
print "eos"
eos.release()
elif t == gst.MESSAGE_ERROR:
print "Error"
eos.release()
sem.release()
sys.exit(1)
def encode():
start = 3673626666666L
stop = 3785800000000L
pipeline = gst.element_factory_make("playbin", "pipeline")
pipeline.set_property("uri", 'file://' + quote(FILE) )
fakesink = gst.element_factory_make("fakesink", "fakesink")
abin = gst.Bin()
enc = gst.element_factory_make("flacenc", "encoder")
sink = gst.element_factory_make("filesink", "sink")
sink.set_property("location", "dest.flac")
abin.add(enc, sink)
gst.element_link_many(enc, sink)
sinkpad = enc.get_static_pad("sink")
abin.add_pad(gst.GhostPad('sink', sinkpad))
pipeline.set_property("audio-sink", abin)
pipeline.set_property("video-sink", fakesink)
bus = pipeline.get_bus()
bus.add_signal_watch()
bus.connect("message", on_message)
global state, sem
state = gst.STATE_PAUSED
pipeline.set_state(gst.STATE_NULL)
pipeline.set_state(gst.STATE_PAUSED)
sem.acquire()
print pipeline.seek(1.0, gst.Format(gst.FORMAT_TIME),
gst.SEEK_FLAG_FLUSH, gst.SEEK_TYPE_SET, start, gst.SEEK_TYPE_SET, stop)
pipeline.set_state(gst.STATE_PLAYING)
eos.acquire()
pipeline.set_state(gst.STATE_NULL)
loop.quit()
gobject.threads_init()
loop = gobject.MainLoop()
Thread(target=encode).start()
loop.run()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20111102/d3b1263a/attachment.html>
More information about the gstreamer-devel
mailing list