Memory grow up when playback

Stephenwei lofy.stephen at gmail.com
Thu Feb 22 03:29:28 UTC 2018


Hi,
I try to playback .mkv files and repeat restart it. 
But the memory seems grow up.

Can anyone give the suggestion?

Thanks

=====================================================================
def playback_memoryleaks(m_channel_param):
    
    for i in range(8):
        gst_playback_del(g_pipeline[i])
        watch_id[i] = None
        time.sleep(1)
    
    for i in range(8):
        print(i)
        g_pipeline[i], watch_id[i] = gst_serving_bin_new("channel", i,
m_channel_param[i])
        g_pipeline[i].set_state(Gst.State.PLAYING)
    a = time.time()
    st = time.time()
    no = time.time()
    while True:
        no = time.time()
        if (no - st) > 10:
            print("recreate playback new")
            for i in range(8):
                gst_playback_del(g_pipeline[i])
                watch_id[i] = None
                time.sleep(1)
                g_pipeline[i], watch_id[i] = gst_serving_bin_new("channel",
i, m_channel_param[i])
                g_pipeline[i].set_state(Gst.State.PLAYING)
            st = time.time()
            no = time.time()

def gst_mkvfile_playback_new(name, filepath, m_channel_param):
    pipeline = Gst.Pipeline.new(str(name))
    filesrc = Gst.ElementFactory.make("filesrc", "src")
    demuxer = Gst.ElementFactory.make("matroskademux", "demux")
    filesrc.set_property("location", filepath)
    decodebin = Gst.ElementFactory.make("vaapidecodebin", "decodebin")
    videorate = Gst.ElementFactory.make("videorate", "videorate")
    videoscale = Gst.ElementFactory.make("videoscale", "videoscale")
    xvimagesink = Gst.ElementFactory.make("ximagesink", "sink")
    xvimagesink.set_property("force-aspect-ratio", True)
    xvimagesink.set_property("qos", False)

    xvimagesink.set_property("handle-expose", False)  
    watch_id = demuxer.connect("pad-added", cb_mkvdemuxer_newpad, decodebin)

    elements = [filesrc, demuxer, decodebin, videoscale, videorate,
xvimagesink ]
    for element in elements:
        pipeline.add(element)

    filesrc.link(demuxer)
    decodebin.link(videoscale)
    videoscale.link(videorate)
    videorate.link(xvimagesink)

    return pipeline, watch_id

def gst_playback_del(bin):
    bin.set_state(Gst.State.NULL)
    fmt = Gst.Format.TIME
    timeout = 1000
    usleep = lambda x: time.sleep(x / 1000000.0)

    usleep(10)  # sleep during 100μs
    while bin.get_state(0)[1] != Gst.State.NULL and timeout:
        if bin.get_state(0)[0] == Gst.StateChangeReturn.FAILURE:
            break
        usleep(10)
        timeout -= 10
    bin = None



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/


More information about the gstreamer-devel mailing list