Thursday 15 March 2012

Concatenating video files in gstreamer (in python) -



Concatenating video files in gstreamer (in python) -

i trying take series of video segment files (in .flv format, identical audio/video encodings), , concatenate them new file (in .mp4 format). encoding pipeline works fine normal single-segment files, 1 time add together sec segment, having no end of difficulty getting work correctly.

with current implementation, have message handler eos messages such:

def on_eos(self, bus, msg): remain = len(self.metadata['localsegments']) logger.warning("hit eos probe: %d segments left" % remain) if remain == 0: self.abort = true self.mainloop.quit() homecoming duration = self.pipeline.query_duration(gst.format(gst.format.time))[1] self.offset += duration logger.info("duration: %s, new offset: %s" % (gst.time_args(duration), gst.time_args(self.offset))) self.pipeline.set_state(gst.state.ready) self.localinfile = self.metadata['localsegments'].pop(0) logger.info("starting new file: %s" % self.localinfile) self.elem_src.set_property('location', self.localinfile) self.elem_src_src.set_offset(self.offset) self.pipeline.set_state(gst.state.playing)

this shows duration of lastly segment, , attempts set offset of next segment beingness end of previous segment. transcode ok, seeking origin of output file , overwriting previous contents. not giving output want!

is there missed here? i've tried pad probe, won't allow me stop , restart pipeline own thread, , crashes miserably (telling me in message handler, have now).

filesink overwriting existing file. want here append new segment existing mp4 file (and don't want append mp4 file end of existing one).

what have have grab eos event (not message) on srcpad right in front end of muxer via pad probe. pad probe callback unlink srcpad , muxer's sinkpad. dynamically link in new input , link muxer, while setting pad offset do. don't ever alter state of pipeline, , lastly segment allow eos event go through , wait eos message (not event!) posted on bus. shut downwards pipeline.

now tricky part of want clean old segments. can't pad probe callback eos sent streaming thread. need here (after unlinking pad probe callback!) remove elements related old segment pipeline thread, set state gst_state_null , unref them.

python video concatenation gstreamer

No comments:

Post a Comment