• <bdo id='xq1vd'></bdo><ul id='xq1vd'></ul>

    1. <small id='xq1vd'></small><noframes id='xq1vd'>

      <tfoot id='xq1vd'></tfoot>

      <legend id='xq1vd'><style id='xq1vd'><dir id='xq1vd'><q id='xq1vd'></q></dir></style></legend>
        <i id='xq1vd'><tr id='xq1vd'><dt id='xq1vd'><q id='xq1vd'><span id='xq1vd'><b id='xq1vd'><form id='xq1vd'><ins id='xq1vd'></ins><ul id='xq1vd'></ul><sub id='xq1vd'></sub></form><legend id='xq1vd'></legend><bdo id='xq1vd'><pre id='xq1vd'><center id='xq1vd'></center></pre></bdo></b><th id='xq1vd'></th></span></q></dt></tr></i><div id='xq1vd'><tfoot id='xq1vd'></tfoot><dl id='xq1vd'><fieldset id='xq1vd'></fieldset></dl></div>
      1. 通过python子进程的ffmpeg无法找到相机

        时间:2023-09-03
      2. <tfoot id='6zTAu'></tfoot>

        <small id='6zTAu'></small><noframes id='6zTAu'>

        • <bdo id='6zTAu'></bdo><ul id='6zTAu'></ul>
            <tbody id='6zTAu'></tbody>

          <legend id='6zTAu'><style id='6zTAu'><dir id='6zTAu'><q id='6zTAu'></q></dir></style></legend>
          • <i id='6zTAu'><tr id='6zTAu'><dt id='6zTAu'><q id='6zTAu'><span id='6zTAu'><b id='6zTAu'><form id='6zTAu'><ins id='6zTAu'></ins><ul id='6zTAu'></ul><sub id='6zTAu'></sub></form><legend id='6zTAu'></legend><bdo id='6zTAu'><pre id='6zTAu'><center id='6zTAu'></center></pre></bdo></b><th id='6zTAu'></th></span></q></dt></tr></i><div id='6zTAu'><tfoot id='6zTAu'></tfoot><dl id='6zTAu'><fieldset id='6zTAu'></fieldset></dl></div>

                1. 本文介绍了通过python子进程的ffmpeg无法找到相机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  这里有一个奇怪的问题,我使用这个命令通过 ffmpeg(通过 windows 上的 cmd)捕获我的网络摄像头:

                  Weird problem here, i use this command to capture my webcam through ffmpeg (through cmd on windows):

                  ffmpeg -y -t 300 -rtbufsize 1024M -f dshow -i video="Lenovo EasyCamera" -c:v libx264 -preset veryslow -crf 25 Desktop.mkv
                  

                  一切正常.但是当我通过 python 尝试相同的命令作为子进程时,它失败了.这是python代码:

                  and everything works fine. But when i try the very same command through python as a subprocess it fails. Here's the python code:

                  from subprocess import Popen
                  cmd = ['ffmpeg', '-y', '-t', '300', '-rtbufsize', '1024M', '-f', 'dshow', '-i', 'video="Lenovo EasyCamera"', '-c:v', 'libx264', '-preset', 'veryslow', '-crf', '25', 'Desktop.mkv']
                  p = Popen(cmd)
                  

                  输出以下错误并冻结:

                  [dshow @ 00000000023a2cc0] Could not find video device with name ["Lenovo EasyCamera"] among source devices of type video.
                  video="Lenovo EasyCamera": I/O error
                  

                  谁能解决这个问题并告诉我我做错了什么?还是python或子进程模块中的一些已知错误(使用python 3.6.1,但如果它可以帮助我解决这个问题,则不附加到特定版本)?

                  Can anyone figure this out and tell me what i'm doing wrong? Or is it some known bug in python or the subprocess module (using python 3.6.1, but not attached to the specific version if it will help me solve this problem)?

                  提前致谢!

                  PS 这个问题是对这个问题的后续,如果相关的话:如何在 windows 中使用 ffmpeg 抓取笔记本电脑网络摄像头视频

                  P.S. This question is a follow up to this one, if that's relevant: How to grab laptop webcam video with ffmpeg in windows

                  推荐答案

                  问题是,在命令行中,video="Lenovo EasyCamera" 使用引号来确保空格没有让它成为另一个论点.

                  The problem is that, in the commandline, video="Lenovo EasyCamera" uses the quotes to make sure the space doesn't make it another argument.

                  您可以通过测试 python 文件看到这一点:

                  You can see this with a test python file:

                  import sys
                  print(sys.argv[1:])
                  

                  > python print_argv.py video="Lenovo EasyCamera"
                  ['video=Lenovo EasyCamera']
                  > python print_argv.py "video=Lenovo EasyCamera"
                  ['video=Lenovo EasyCamera']
                  > python
                  >>> from subprocess import Popen
                  >>> cmd = ['python', 'print_argv.py', 'video="Lenovo EasyCamera"']
                  >>> p = Popen(cmd)
                  ['video="Lenovo EasyCamera"']
                  

                  ffmpeg 认为您正在寻找一个名为 "Lenovo EasyCamera" 而不是 Lenovo EasyCamera

                  ffmpeg thinks you're looking for a device called "Lenovo EasyCamera" instead of Lenovo EasyCamera

                  因此,您需要更改命令,使其不在引号中,因为 Popen 不会将其拆分为空格.

                  So, you need to change your command so that it is not in quotes, as Popen will not split it on spaces.

                  from subprocess import Popen
                  cmd = [..., '-i', 'video=Lenovo EasyCamera', ...]
                  p = Popen(cmd)
                  

                  这篇关于通过python子进程的ffmpeg无法找到相机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Python字符串作为子进程的文件参数 下一篇:如何从 subprocess.communicate() 在 python 中捕获流输出

                  相关文章

                    <bdo id='5vqin'></bdo><ul id='5vqin'></ul>
                  <tfoot id='5vqin'></tfoot>

                  1. <legend id='5vqin'><style id='5vqin'><dir id='5vqin'><q id='5vqin'></q></dir></style></legend>
                    1. <small id='5vqin'></small><noframes id='5vqin'>

                      <i id='5vqin'><tr id='5vqin'><dt id='5vqin'><q id='5vqin'><span id='5vqin'><b id='5vqin'><form id='5vqin'><ins id='5vqin'></ins><ul id='5vqin'></ul><sub id='5vqin'></sub></form><legend id='5vqin'></legend><bdo id='5vqin'><pre id='5vqin'><center id='5vqin'></center></pre></bdo></b><th id='5vqin'></th></span></q></dt></tr></i><div id='5vqin'><tfoot id='5vqin'></tfoot><dl id='5vqin'><fieldset id='5vqin'></fieldset></dl></div>