[Tutor] 2.7.3 Popen argument issues

eryksun eryksun at gmail.com
Sun Aug 26 05:02:29 CEST 2012


On Sat, Aug 25, 2012 at 8:46 PM, Ray Jones <crawlzone at gmail.com> wrote:
>
> Here is my Python call to vlc (error response to follow):
>
> vlcExec = sp.Popen(['vlc', 'http://' + ip + ':' + port, '-I dummy',
> '--sout
> \'#duplicate{dst="transcode{vb=400}:std{access=file,mux=avi,dst=outFile
> + '.avi}",dst="std{access=http,mux=mpjpeg,dst=127.0.0.1:11300}"}\''])
>

Arguments are split on spaces. For example, it's ['-I', 'dummy'], not
['-I dummy']. You can put the command in a string and split() it.

Hopefully the following will work once you set the values you're using
for ip/port.

import subprocess

ip = "192.168.0.2"
port = "1234"

out_file = "testing.avi"
out_ip = "127.0.0.1"
out_port = "11300"
dst_file = '"transcode{vb=400}:std{access=file,mux=avi,dst=%s}"' % out_file
dst_http = '"std{access=http,mux=mpjpeg,dst=%s:%s}"' % (out_ip, out_port)
sout = "'#duplicate{dst=%s,dst=%s}'" % (dst_file, dst_http)

cmd = "vlc http://%s:%s -I dummy --sout %s" % (ip, port, sout)

p = subprocess.Popen(cmd.split())


To answer your initial question, you could call a Python script (or a
Bash script if you prefer) instead of vlc. In Python, just print out
the list sys.argv.

cmd = "python argtest.py http://%s:%s -I dummy --sout %s" % (ip, port, sout)
p = subprocess.Popen(cmd.split())

# argtest.py

import sys
print "\nArgs:"
for arg in sys.argv:
    print arg


More information about the Tutor mailing list