I need to merge two avi videos side by side and I succeeded with python + gstreamer as below code.
pipe = """
videomixer2 name=mix background=1
sink_0::xpos=0 sink_0::ypos=60 sink_0::zorder=0
sink_1::xpos=640 sink_1::ypos=60 sink_1::zorder=0 !
ffmpegcolorspace name=colorsp_saida !
video/x-raw-yuv, format=(fourcc)I420, width=1280, height=480, framerate=25/1 !
x264enc quantizer=45 speed-preset=6 profile=1 ! queue !
mp4mux name=mux ! queue ! filesink location="output.mp4"
filesrc location="video1.avi" ! decodebin2 name=dbvideo1 !
aspectratiocrop aspect-ratio=16/9 ! videoscale ! videorate !
ffmpegcolorspace name=colorsp_video1 !
video/x-raw-yuv, format=(fourcc)AYUV, framerate=25/1, width=640, height=360 !
mix.sink_0
filesrc location="video2.avi" ! decodebin2 name=dbvideo2 !
aspectratiocrop aspect-ratio=16/9 ! videoscale ! videorate !
ffmpegcolorspace name=colorsp_video2 !
video/x-raw-yuv, format=(fourcc)AYUV, framerate=25/1, width=640, height=360 !
mix.sink_1
"""
import gst
pipeline = gst.Pipeline()
bus = pipeline.get_bus()
gst_bin = gst.parse_bin_from_description(pipe, False)
pipeline.add(gst_bin)
pipeline.set_state(gst.STATE_PLAYING)
msg = bus.timed_pop_filtered(gst.CLOCK_TIME_NONE, gst.MESSAGE_ERROR | gst.MESSAGE_EOS)
pipeline.set_state(gst.STATE_NULL)
I am using ubuntu 12.04 LTS, python 2.7 and gstreamer.
I have few issues as below,
- when I use bigger input files(duration more than 30 minutes) program is hang on lator stage, but still its giving the output.mp4.
- this is very slow, if I convert 30 minutes, program also running for 20 -25 minutes
- two input files may have few seconds(10-20 seconds) time gap, will it be the issue?
If I have any other way to merge and convert this files, other than gstreamer also acceptable.
UPDATE 1:
After few days of works I found that program get hang on pipeline.set_state(gst.STATE_NULL)
line. Anyone have an idea ,how to overcome this.
Basically I need to free the resources of pipeline without any trouble.
UPDATE 2:
I need to merge two video(avi) files(either file will have a audio) side by side and convert to MP4 format, is a whole idea of this question. I tried with gstreamer and stuck on a place that I have described in above.