0

I'm trying to run this code that should open the selected mp3 with VLC, use Line 1 as the audio output, and close when it's done. But the arguments don't all seem to be getting through.

Python code

import subprocess
vlcpath = "C:\\Program Files (x86)\\VideoLAN\\VLC\\vlc.exe"
audiopath = "C:\\Users\\Aidan\\Desktop\\test.mp3"
args = [vlcpath, audiopath, "--aout=waveout", '--waveout-audio-device="Line 1 (Virtual Audio Cable) ($1,$64)"', "--play-and-exit"]
subprocess.call(args, shell=True)
for i in args:  #for diagnostic purposes
    print(i)

Which should run similarly to this command line input

"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" C:\Users\Aidan\Desktop\test.mp3 --aout=waveout --waveout-audio-device="Line 1 (Virtual Audio Cable) ($1,$64)" --play-and-exit

The command line input plays and exits properly, and plays to Line 1. The python code plays and exits, but not to Line 1.

Edit: I should mention I'm using python 3.4.4

jamd315
  • 18
  • 4

1 Answers1

0

Since shell is true the string representation of the list is passed to the command line which is not what you want. Look closely at the examples on this page https://docs.python.org/2/library/subprocess.html

cs01
  • 5,287
  • 1
  • 29
  • 28
  • I tried both removing the shell argument and using shell=False but neither fixed it. Reading on the page you linked about the security problems caused by shell=True though means I'll leave shell=False – jamd315 Aug 14 '16 at 18:06