opencv Unable to stop the stream Inappropriate ioctl for device

0 votes

I 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

I am using python 2.7.6 on ubuntu server. How do I fix this issue?

Jul 20, 2019 in Python by ana1504.k
• 7,910 points
3,240 views

1 answer to this question.

0 votes

I have solved this issue on 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:

    • 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
answered Jul 20, 2019 by SDeb
• 13,300 points

Related Questions In Python

+1 vote
1 answer
0 votes
1 answer
+1 vote
1 answer

What is the correct order to learn concepts in Python for machine learning?

Machine Learning is a vast domain. It ...READ MORE

answered Jul 25, 2018 in Python by Abhi
• 3,720 points
1,062 views
0 votes
1 answer

What's the canonical way to check for type in Python?

To check if o is an instance ...READ MORE

answered Aug 24, 2018 in Python by Priyaj
• 58,020 points
949 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,443 views
0 votes
1 answer
0 votes
1 answer

How to install OpenCV for Python 2.7?

The official OpenCV installer does not install ...READ MORE

answered Nov 14, 2018 in Python by SDeb
• 13,300 points
2,331 views
0 votes
1 answer

Return a list inside a for loop while iterating over the elements of another list

The print() is getting called multiple times ...READ MORE

answered Sep 22, 2018 in Python by SDeb
• 13,300 points
5,039 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP