[vlc-devel] Re : vlc python bindings

Pluch' pluch001 at yahoo.fr
Tue Jul 21 20:03:10 CEST 2009


Hi,

I thought the "del player" line should free the memory but obviously not !
I tried your solution but ran into another problem which I described on the forum a few weeks ago :
http://forum.videolan.org/viewtopic.php?f=5&t=60394

In my application (multiple radio recording), I want to use two or more vlc instances and some of them are running/recording while other are waiting next time for recording.
So I think my problem is when a instance is starting with 
player = vlc.MediaControl([args])
I don't know how to change the args once the player is stopped with
player.stop()

If you have any idea about the script on the forum or the problem above, you're welcome ;-)

Thanks ,

Pluch'

I copy the script of the forum here :

#! /usr/bin/env python
# -*- coding: utf-8 -*-

import vlc, time,os

#array to store multiple players
enreg=[]


class one_player():
   def __init__(self,cmd):
      self.player= vlc.MediaControl(cmd)

   
for i in range(0,3):
   print "\n"+str(i)+"\n"
   lineCmd = []
   lineCmd.append("--volume=0")
 
 lineCmd.append("--sout=#transcode{acodec=mp3,ab=64,channels=1}:duplicate{dst=std{access=file,mux=raw,dst=/tmp/"+str(i)+".mp3}}")
   
   enreg.append(one_player(lineCmd))
   enreg[i].player.set_mrl("/tmp/test.mp3")
   enreg[i].player.start()   

   time.sleep(5)
   
#0.mp3, 1.mp3, 2.mp3 are running -->ok

#stop the players and remove the files --> ok
enreg[0].player.stop()
enreg[1].player.stop()
enreg[2].player.stop()

os.remove("/tmp/0.mp3")
os.remove("/tmp/1.mp3")
os.remove("/tmp/2.mp3")

time.sleep(5)   

# My BIG problem is here !!!
#start player number 1 but this restart number 2, why ?
enreg[1].player.start()   

time.sleep(5)   






________________________________
De : Olivier Aubert <olivier.aubert at liris.cnrs.fr>
À : Mailing list for VLC media player developers <vlc-devel at videolan.org>
Envoyé le : Lundi, 20 Juillet 2009, 22h49mn 07s
Objet : Re: [vlc-devel] vlc python bindings

Hi

Neither of both. You are simply reinstanciating a new VLC instance at
each invocation, and thus quickly wasting memory. Why not reuse the
existing one ?

Olivier

On Mon, 2009-07-20 at 19:35 +0000, Pluch' wrote:
> Hello,
> 
> 

> When I try the vlc Python Bindings in a loop, the memory used by my
> script increase each time I start a new player with
> player=vlc.MediaControl(). After about 50-55 starts on linux (about
> 150 starts on windows), the script runs out of memory.
> Is it a problem with the script below or is there something wrong with
> the bindings.
> 
> Thanks!
> 
> the script :
> 
> #! /usr/bin/env python
> 
> import vlc, time
> 
> idx=0
> 
> while True:
> 
>    idx+=1
>    player=vlc.MediaControl()
>    time.sleep(2)
>    print (str(idx)+"---")*10
> 
>    del player
>    time.sleep(1)

> 

_______________________________________________
vlc-devel mailing list
To unsubscribe or modify your subscription options:
http://mailman.videolan.org/listinfo/vlc-devel



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20090721/db15ea21/attachment.html>


More information about the vlc-devel mailing list