简体   繁体   English

opencv无法阻止流:设备的ioctl不合适

[英]opencv Unable to stop the stream: Inappropriate ioctl for device

I just want to convert video to frame images. 我只是想将视频转换为帧图像。

Using this simple code 使用这个简单的代码

import cv2
vidcap = cv2.VideoCapture('gog.mp4')
success,image = vidcap.read()
count = 0
success = True
while success:
  success,image = vidcap.read()
  print 'Read a new frame: ', success
  cv2.imwrite("frame%d.jpg" % count, image)
  count += 1

output is 输出是

Unable to stop the stream: Inappropriate ioctl for device 无法停止流:设备的ioctl不合适

I am using python 2.7.6 on ubuntu server. 我在ubuntu服务器上使用python 2.7.6。

I have solved this issue on Ubuntu 16.04.3. 我在Ubuntu 16.04.3上解决了这个问题。

  1. sudo apt-get install ffmpeg
  2. sudo apt-get install libavcodec-dev libavformat-dev libavdevice-dev
  3. Rebuild OpenCV 3.3.0 with the following commands: 使用以下命令重建OpenCV 3.3.0:

    • cd build
    • cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_FFMPEG=ON -D WITH_TBB=ON -D WITH_GTK=ON -D WITH_V4L=ON -D WITH_OPENGL=ON -D WITH_CUBLAS=ON -DWITH_QT=OFF -DCUDA_NVCC_FLAGS="-D_FORCE_INLINES" ..
    • make -j7
    • sudo make install

Hi i also taked this error and solved with this commands. 嗨我也接受了这个错误并用这个命令解决了。

sudo apt-get install libv4l-dev
cmake -DWITH_LIBV4L=ON .. (this is important)
make && sudo make install

if error occurs with cmake command second one pls install cmake gui.Do first command: sudo apt-get install libv4l-dev Through cmakegui program u can set parameters with CmakeVars.txt file. 如果使用cmake命令发生错误第二个请安装cmake gui.Do第一个命令: sudo apt-get install libv4l-dev通过cmakegui程序你可以用CmakeVars.txt文件设置参数。 Edit CmakeVars.txt file exchange WITH_LIBV4L=OFF to WITH_LIBV4L=ON and run make && sudo make install command. 编辑CmakeVars.txt文件交换WITH_LIBV4L = OFF到WITH_LIBV4L = ON并运行make && sudo make install命令。 For more information about this error visit: https://github.com/opencv/opencv/issues/6157 有关此错误的更多信息,请访问: https//github.com/opencv/opencv/issues/6157

I had the exact same issue using Manjaro 17.0.2 and OpenCV 3.2.0 with Java. 我使用Manjaro 17.0.2和OpenCV 3.2.0与Java有完全相同的问题。 I removed the old implementation of OpenCV, went and reinstalled it from scratch. 我删除了旧的OpenCV实现,从头开始重新安装。 Ran cmake with these parameters cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_LIBV4L=ON .. (thanks @emre) 使用这些参数进行cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_LIBV4L=ON .. (感谢@emre)

Then in the output of the Cmake installation I noticed Can't find ffmpeg - 'pkg-config' utility is missing . 然后在Cmake安装的输出中我注意到Can't find ffmpeg - 'pkg-config' utility is missing Installed the pkg-config and re ran cmake, make and now everything works. 安装了pkg-config并重新运行cmake,make,现在一切正常。

The problem was due to missing ffmpeg and ffmpeg-devel. 问题是由于缺少ffmpeg和ffmpeg-devel。 You can verify this in cmake output. 您可以在cmake输出中验证这一点。

CMAKE输出

If FFMPEG is not available, those YES will become NO. 如果FFMPEG不可用,那些YES将变为NO。 And if you compile and install the opencv without FFMPEG, you will get error "Unable to stop the stream: Inappropriate ioctl for device" for video related samples. 如果您编译并安装没有FFMPEG的opencv,您将收到错误“无法停止流:不合适的设备ioctl”视频相关样本。

To solve your problem, install ffmpeg and ffmpeg-devel, then "make" and "make install" again. 要解决您的问题,请安装ffmpeg和ffmpeg-devel,然后再次“make”和“make install”。

Hope this helps. 希望这可以帮助。

I use Linux Mint, and programming in C++. 我使用Linux Mint,用C ++编程。 I apply the same procedure of https://stackoverflow.com/a/45893821/11247666 . 我应用https://stackoverflow.com/a/45893821/11247666的相同程序。 This is: 这是:

sudo apt-get install ffmpeg
sudo apt-get install libavcodec-dev libavformat-dev libavdevice-dev
cd opencv-3.3.0
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local  -D WITH_FFMPEG=ON -D WITH_TBB=ON -D WITH_GTK=ON -D WITH_V4L=ON -D WITH_OPENGL=ON -D WITH_CUBLAS=ON -DWITH_QT=OFF -DCUDA_NVCC_FLAGS="-D_FORCE_INLINES" ..
make -j7
sudo make install

But after this. 但在此之后。 The problem was cannot be solved. 问题是无法解决的。 I have this error: 我有这个错误:

Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvNamedWindow. 未指定错误(该功能未实现。使用Windows,GTK + 2.x或Carbon支持重建库。如果您使用的是Ubuntu或Debian,请安装libgtk2.0-dev和pkg-config,然后重新运行cmake或configure脚本)在cvNamedWindow中。

I apply the following 我申请以下内容

sudo apt-get install libgtk2.0-dev
sudo apt-get install pkg-config

After this, I applied this same procedure: 在此之后,我应用了同样的程序:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local  -D WITH_FFMPEG=ON -D WITH_TBB=ON -D WITH_GTK=ON -D WITH_V4L=ON -D WITH_OPENGL=ON -D WITH_CUBLAS=ON -DWITH_QT=OFF -DCUDA_NVCC_FLAGS="-D_FORCE_INLINES" ..
make -j7
sudo make install

The above worked for me. 以上对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 OpenCV3错误:“无法停止流:设备的不适当的ioctl” - OpenCV3 error: “Unable to stop the stream: Inappropriate ioctl for device” Pexpect和PyCharm - 适用于设备的ioctl - Pexpect and PyCharm - Inappropriate ioctl for device 崇高的tset:标准错误:设备的ioctl不适当 - Sublime tset: standard error: Inappropriate ioctl for device IOError:[Errno 25] 设备的 ioctl 不合适 - IOError: [Errno 25] Inappropriate ioctl for device 在Python中运行ioctl会返回ENOTTY-设备不适合的ioctl - Running ioctl in Python returns ENOTTY - inappropriate ioctl for device 如何抑制“stty:'标准输入':设备的 ioctl 不合适”错误 - How to supress the “stty: 'standard input': Inappropriate ioctl for device” error 当在具有PowerCLI的VM上运行时,pexpect的interact()报告“不适当的设备ioctl” - pexpect's interact() reported “Inappropriate ioctl for device” when running on a VM with PowerCLI 詹金斯的pipenv shell返回问题termios.error:(25,'不合适的设备ioctl') - pipenv shell in Jenkins return the issue termios.error: (25, 'Inappropriate ioctl for device') “GetPassWarning:无法控制终端上的回声”是什么意思? “设备的 ioctl 不合适”? - What does "GetPassWarning: Can not control echo on the terminal" mean? "Inappropriate ioctl for device"? 使用Ubuntu和pty不合适的ioctl - Inappropriate ioctl using Ubuntu and pty
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM