3
import subprocess import os print os.path.exists("C:/Users/Dhruv/Desktop/Motivation/RiseShine.mp4") p = subprocess.Popen(["C:/Program Files (x86)/VideoLAN/VLC/vlc.exe","C:/Users/Dhruv/Desktop/Motivation/RiseShine.mp4"]) 

The code above is to open a video file in VLC player using python. The VLC player opens up, but does not run the video. I have checked the video location, it is correct. Can somebody tell me how to make this work?

1
  • any error messages? This worked here so i'm not able to reproduce your error. Commented Jan 17, 2014 at 14:37

4 Answers 4

8

This worked for me (Python 3.4):

p = subprocess.Popen(["C:/Program Files (x86)/VideoLAN/VLC/vlc.exe","\\E:\Movies\\" + title + '.mp4']) 

The video tested was definitely in mp4 format, btw.

Sign up to request clarification or add additional context in comments.

Comments

0

According to https://wiki.videolan.org/VLC_command-line_help, you should specify a file stream as follows:

p = subprocess.Popen(["C:/Program Files (x86)/VideoLAN/VLC/vlc.exe","file:\\\Users\Dhruv\Desktop\Motivation\RiseShine.mp4"]) 

Comments

0
subprocess.Popen(["C:/Program Files (x86)/VideoLAN/VLC/vlc.exe","C:\\Users\\USERNAME\\Desktop\\videos\\example.mp4"]) 

The difference is in the way to put the: ' \ ' , ' // '

Comments

0

Raw Strings and Back Slashes are your friend here:

path = r"C:\Users\Dhruv\Desktop\Motivation\RiseShine.mp4" print(path) 

Output, a correctly formatted for the command-line string:

'C:\\Users\\Dhruv\\Desktop\\Motivation\\RiseShine.mp4' 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.