问题
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:
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.
回答2:
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"])
来源:https://stackoverflow.com/questions/21188114/open-video-file-in-vlc-through-python