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

learner404 learner404 at gmail.com
Wed Sep 4 11:14:08 CEST 2013


Thanks a lot Oscar and Eryksun for all the explanations and answers, I
really appreciate.

"So the extra quotes used for the video and audio arguments do actually
get passed through to ffmpeg causing confusion."

Yes, this worked :)
subprocess.Popen(["ffmpeg","-f","dshow","-i","video="+videoinputName,"-f","dshow","-i","audio="+audioinputName,"-q","5","%s"%videoFileOutput],shell=True)



On Tue, Sep 3, 2013 at 5:42 PM, Oscar Benjamin
<oscar.j.benjamin at gmail.com>wrote:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130904/070dfb0e/attachment.html>


More information about the Tutor mailing list