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?
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.
Related
I am trying to install OpenCV following this link https://docs.opencv.org/master/d5/de5/tutorial_py_setup_in_windows.html
opencv-4.5.1 is the version I am building from source. I have no errors in my entire process( up to Step 16)
Step 17 which INSTALL also has no errors, but Step 18 'import cv2 as cv' will not import this module.
I have python 3.9.1. I followed all the steps with CMAKE and was able to generate with no errors.
Is there something that I am missing here?
I would recommend to use another IDE like Pycharm to create your projects. It is extremely easy to setup an OpenCV work environment :).
IDLE is great for smaller projects but I`ve seen a lot of people having issues with it.
I can't install opencv-contrib-python on PyCharm using the Setting options provided by PyCharm. I get these error everytime I tried first not using the --user option, such as in image 1:
Then I tried using the --user option, and I got what is showed in image 2
My knowledge of Python is very weak and I don't need to get it better right now. I have a script I need to run for a very close presentation (in the script there are many section with many examples of how to use SIFT, image homography, and other stuff used in image processing and artificial vision. I can't run the SIFT part, this is why I need opencv-contrib-python). I'm using opencv 3.4.3.18 and I need to make the script working for that distribution!
I haven't found anything of useful since now and I'm in quite a hurry and still without a solution.
Thank you for the help!
in the last couple of days I was developing an APP on python IDLE.
I tried to import the vlc module, when I run it I get this error:
OSError: dlopen(libvlccore.dylib, 6): image not found
I installed the module with this command: pip install python-vlc.
I hope you can help me getting it work!
Thanks in advance!
Zaid Zaim
python-vlc is just Python bindings for libVLC.
Without that library, it won't do you any good, because all it does is try to load that library (a .dylib, .so, or .dll, depending on your platform) and call functions out of it.
There should be installation instructions at the wiki page linked above, but on a Mac, the easiest way is to just install the VLC player. I know that if you install it with Homebrew, you get the library, in a location that python-vlc can find. But I think even the binary installer from the front page of the main VideoLAN website will work as well.
If you're using Homebrew, you'll want to read the docs for when to search brew vs. brew cask vs. other taps,1 or search somewhere like Mac App Store for the current status. But at present, the appropriate command appears to be:
brew cask install vlc
1. Generally, anything that you'd expect to find as a double-clickable app in /Applications, as opposed to a Unix command-line tool or a support library, is going to be a cask, and therefore in the tap cask, which has special shortcuts to access it. But that's a relatively new thing, and not every recipe has been converted yet.
brew install --cask vlc
Is the latest command, and it works for me!
I have found some other threads but they didn't help my problem.
The lines that I'm confused about are:
print("videopath",os.path.isfile(video_path),video_path)
self.cap = cv2.VideoCapture(video_path)
print("is open?",self.cap.isOpened())
It says my file exists (the first line returns true, and prints the direct path to my .mp4), and when I put cv2.VideoCapture in a try/catch, it succeeded without an issue. However it says the video is not open and I can't pull any frames from it. I'm on Ubuntu 16.04, using OpenCV 3.3 and Python 3.5.
Any suggestions would be much appreciated, thank you.
In the end it was because I had the wheel version of OpenCV installed on top of my manual installation. DON'T use pip install opencv-python as it is not official and errors like this will occur. This was an incredible guide that made it very easy: https://www.pyimagesearch.com/2016/10/24/ubuntu-16-04-how-to-install-opencv/
To be clear though, I had gone through this whole process once, and then tried pip just because, and it broke it, so once you install it manually, don't touch the wheel packages!
I have pip installed opencv-python on my Ubuntu guest OS hosted in a virtual box. Both my python and Ubuntu are 64-bit. But when I import cv2 I couldn't find all the functions to manipulate images. The following is an image of the ini file I get when I do ctrl+B.
I uninstalled the opencv and followed many tutorials to install opencv using apt-get including from the official opencv website and none of them worked for me. Can someone give me a hint what I can do to get opencv to work?
Following this tutorial, I was able to finally install opencv properly. I am posting my answer to help someone in a similar situation. Ubuntu version is the most important thing you have to check before you follow any of the tutorials. Just like my case, if you happen to follow one of the old tutorials but your Ubuntu version is 16, you need to remove the opencv altogether then follow the tutorial.
After the fix, my ini looks like this. It consists all the functions to manipulate image. The screenshot shows the partial shot in my ide.