Search code examples
pythonsubprocessvlc

executing a subprocess from python


I think something is getting subtly mangeled when I attempt to execute a subprocess from a python script

I attempt to execute vlc with some (a lot) of arguments.

the instance of vlc that arises complains:

Your input can't be opened: VLC is unable to open the MRL ' -vvv rtsp://192.168.1.201:554/ch0_multicast_one --sout=#transcode{acodec=none}:duplicate{dst=rtp{sdp=rtsp://:5544/user_hash.sdp},dst=display} :no-sout-rtp-sap :no-sout-standard-sap :ttl=1 :sout-keep'. Check the log for details.

Here is the python code

pid = subprocess.Popen(["vlc "," -vvv rtsp://%s" % target_nvc.ip_address + ":554/ch0_multicast_one --sout=#transcode{acodec=none}:duplicate{dst=rtp{sdp=rtsp://:5544/user_hash.sdp},dst=display} :no-sout-rtp-sap :no-sout-standard-sap :ttl=1 :sout-keep" ], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)

I have examined the output of the subprocess function (using a shell), and if I copy paste that string into my cmd window, the vlc instance works fine... Is this a privilege thing?


Solution

  • You should use this...

    pid = subprocess.Popen(["vlc", "-vvv", 
        "rtsp://%s" % target_nvc.ip_address + ":554/ch0_multicast_one", 
        "--sout=#transcode{acodec=none}:duplicate{dst=rtp{sdp=rtsp://:5544/user_hash.sdp},dst=display}", 
        ":no-sout-rtp-sap", ":no-sout-standard-sap", 
        ":ttl=1", ":sout-keep" ], stdout=subprocess.PIPE, 
        stderr=subprocess.PIPE, stdin=subprocess.PIPE)