1

I am trying to write a script that will extract a single frame from a user uploaded video clip in order to create a thumbnail. It sounds like either OpenCV or ffmpeg will do what I need, but I am having trouble installing them.

I tried installing OpenCV using apt-get install libopencv-dev, and it looks like everything worked, but when running import cv2 in Python, it says there is no such module. Also tried installing using these instructions, but when I run the import, it hangs for a second or two and then says Failed to initialize libdc1394.

I then tried to install ffmpeg with pyffmpeg, but the most recent version of pyffmpeg I could find was released 3 years ago and built for Python2.6 on Ubuntu 10.10, while I am using 2.7 on Ubuntu 12.04.

Does anyone have experience installing either of these, or would recommend something else for this purpose?

Hat
  • 1,691
  • 6
  • 28
  • 44
  • possible duplicate of [Extract Video Frames In Python](http://stackoverflow.com/questions/10672578/extract-video-frames-in-python) – njzk2 Feb 03 '14 at 23:32
  • @njzk2 that link popped up in my searches before posting this. It doesn't address the installation/import problems I am having for either OpenCV or ffmpeg – Hat Feb 04 '14 at 00:05
  • You should install cv2 with 'pip install opencv-python' – Gaspard Merten Apr 16 '21 at 11:41

1 Answers1

0

If you are trying to install ffmpeg, you can do this more easily if you have homebrew and then use brew to install it. It's a lot more complicated otherwise.

If you just want to be able to complete this task, and it doesn't have to be the tool you're listing, you could try ffmpeg-python. After you have it installed, you can use the get_video_thumbnail example to get a single image. You could also probably tweak the read_frame_as_jpeg example to get a single image from a frame if you want.

spock
  • 1
  • 2
  • Doesn't ffmpeg-python requires ffmpeg to be installed and referenced in the user's path? – Gaspard Merten Apr 16 '21 at 11:40
  • Yes which is why I mention that you should use homebrew to install ffmpeg if possible. Installation process would be: 1. Install ffmpeg with homebrew 2. Install ffmpeg-python with pip – spock Apr 16 '21 at 17:35