Open Video file in VLC through Python

…衆ロ難τιáo~ 提交于 2020-01-15 06:07:22

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!