[Tutor] os.system vs subprocess.Popen args problems

Oscar Benjamin oscar.j.benjamin at gmail.com
Tue Sep 3 17:42:34 CEST 2013


On 3 September 2013 14:48, eryksun <eryksun at gmail.com> wrote:
>> It occurs to me that another possibility is if ffmpeg isn't really an
>> .exe on PATH but rather a .bat file or something. In that case
>> os.system or subprocess shell=True would pick it up but subprocess
>> shell=False might not. I say "might" because at least on some version
>> of Windows CreateProcess can run .bat files directly but I've never
>> seen this documented anywhere.
>
> cmd tries each PATHEXT extension, but CreateProcess only tries .exe,
> and finds ffmpeg.exe.
>
> As to batch files, "Windows Internals" (Microsoft Press) documents
> that CreateProcess starts cmd.exe to run .bat and .cmd files.

Okay, I see. So it can run a .bat if you give the extension but not
implicitly via PATHEXT. In which case anything without an extension
would have to be an .exe file. And of course this wouldn't explain the
OP's problem anyway since they're getting output from ffmpeg.

Testing the OP's actual commands out with ffmpeg I see that the
problem is with the quotes. But, as you pointed out in your first
post, it is the unnecessary additional quotes that are the problem
rather than any missing ones. i.e. when I test it I get:

# os.system output
[dshow @ 02548460] Could not enumerate video devices.
video=video: Input/output error

# subprocess.Popen output
[dshow @ 02548460] Could not enumerate video devices.
video="video": Input/output error

So the extra quotes used for the video and audio arguments do actually
get passed through to ffmpeg causing confusion. (I don't have any
video devices here so it's an error either way on this machine).


Oscar


More information about the Tutor mailing list