0

I have the following command which works without issue in the Windows CLI:

"G:\VLC\vlc" --dshow-vdev="Video (00 Pro Capture HDMI 4K+)" --dshow-size=1920x1080 -V dummy --intf=dummy --dummy-quiet --video-filter=scene --no-audio --scene-path="C:\<User>\My location" --scene-format=jpeg --scene-prefix=test_file --scene-replace --run-time=1 --scene-ratio=24 "dshow://" vlc://quit

This takes a snapshot of whatever my capture card is displaying and saves this to file. When I try the same with Python as so:

import os
import subprocess

path = "C:\\<User>\\My location"
fname = "test_file"

os.chdir('G:\\VLC')
process = subprocess.Popen(['vlc', ' --dshow-vdev="Video (00 Pro Capture HDMI 4K+)"', ' --dshow-size=1920x1080', ' -V dummy', ' --intf=dummy', \
                            ' --dummy-quiet', ' --video-filter=scene', \
                            ' --no-audio' ,path, ' --scene-format=jpeg', ' --scene-prefix=', fname, \
                            ' --scene-replace', ' --run-time=1', ' --scene-ratio=24', ' "dshow://"', ' vlc://quit'])

I get the following in the VLC log and no screenshot captured:

filesystem error: cannot open file G:\VLC\ --dshow-vdev="Video (00 Pro Capture HDMI 4K+)" (Invalid argument)
dvdnav error: Could not open G:\VLC\ --dshow-vdev="Video (00 Pro Capture HDMI 4K+)" with libdvdcss.
dvdnav error: Can't open G:\VLC\ --dshow-vdev="Video (00 Pro Capture HDMI 4K+)" for reading
dvdnav error: vm: failed to open/read the DVD

Can anyone explain to me what the issue is?

gdogg371
  • 3,879
  • 14
  • 63
  • 107

3 Answers3

0

shlex can help you out, with this sort of thing.

The shlex class makes it easy to write lexical analyzers for simple syntaxes resembling that of the Unix shell. This will often be useful for writing minilanguages, (for example, in run control files for Python applications) or for parsing quoted strings.

import shlex
shlex.split(string) suggests something along the lines of:

['G:\\VLC\\vlc', '--dshow-vdev=Video (00 Pro Capture HDMI 4K+)', '--dshow-size=1920x1080', '-V', 'dummy', '--intf=dummy', '--dummy-quiet', '--video-filter=scene', '--no-audio', '--scene-path=C:\\<User>\\My location', '--scene-format=jpeg', '--scene-prefix=test_file', '--scene-replace', '--run-time=1', '--scene-ratio=24', 'dshow://', 'vlc://quit']

Rolf of Saxony
  • 21,661
  • 5
  • 39
  • 60
  • hi - thanks for replying. i will give that a go later and accept the answer if it works. i was aware of the shlex module, but not what it was used for. this is useful info for future reference. thanks. – gdogg371 Jan 09 '21 at 16:51
0

I got the same problem and couldn´t solve it with shlex. My Code:

import os
import shlex
import subprocess

cwd = os.getcwd()                         #working directory: video to be played is stored here
cmd = shlex.split("--random --no-loop")   #additional commands for vlc

p = subprocess.Popen(["C:/Program Files/VideoLAN/VLC/vlc.exe", cwd, cmd], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)

I also tried:

cmd = '--random --no-loop'

and

cmd = "--random --no-loop"

both won´t work. Starting:

vlc.exe --random --no-loop 

via command-prompt in windows works without errors though. Has anybody an idea how to solve this without using a *.bat file?

  • Answer is not an answer, but piggybacking on the original question. – LukasNeugebauer Mar 10 '22 at 14:58
  • This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/31258345) – Peter Trcka Mar 10 '22 at 15:55
  • Thank you, I´am new and didn´t know that. – damien_1437 Mar 12 '22 at 10:11
0

I apologize for the missunderstanding befor. Now i actually have an Answer:

I got it working with the following Syntax:

# Play Video without Loop, Random and start Paused
cmd1 = "--random"
cmd2 = "--no-loop"
cmd3 = "--start-paused"

cwd = os.getcwd() 

p = subprocess.Popen(["C:/Program Files/VideoLAN/VLC/vlc.exe", cwd, cmd1, cmd2, cmd3], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)

As you can see, the commands musn´t include spaces in the Syntax and i seperated the strings in different variables. Furthermore, it probably doesn´t matter if you use ' or " for the commands. It works both ways.

  • it's actually so long since i asked this question that i cant remember whether i resolved it on my own or not. if not, i will try out your answer and see how i do. thanks. – gdogg371 Mar 13 '22 at 08:34