Reputation: 515
I have a very simple pipeline:
filesrc location=foo.wav ! decodebin ! ENCODER ! MUXER ! filesink location=bar.whatever
with ENCODER
being any gstreamer
encoder and MUXER
, whatever suitable muxer. The pipeline is working. For the sake of simplicity, assume there is only one audio stream coming from decodebin
.
Now,
decodebin
(i.e. the raw PCM size)?ENCODER
(i.e. the raw compressed size)?I am using Python with GI. I've tried with the appsink
element, to no avail, with the following pipeline:
filesrc location=foo.wav ! decodebin ! ENCODER ! tee name=tee \
tee. ! queue ! MUXER ! filesink location=bar.whatever \
tee. ! queue ! appsink
The relevant part with appsink
is the following:
counter = 0
appsink = Gst.ElementFactory.make('appsink', None)
appsink.set_property('emit-signals', True)
appsink.set_property('sync', False)
appsink.connect('new-sample', on_new_buffer)
appsink.connect('new-preroll', on_new_preroll)
def on_new_buffer(sample):
counter += sample.emit('pull-sample').get_buffer().get_size()
def on_new_preroll(sample):
counter += sample.emit('pull-preroll').get_buffer().get_size()
However this is really really slow (20x slower than just using filesink
).
Upvotes: 0
Views: 1838
Reputation: 2094
You can try using pad probes.
Add a pad probe for buffers and buffer lists on the pads where you want to count the number of bytes.
Upvotes: 1