At night, I was scanning station B. I watched the little mage’s legal video (actually I was watching the little mage). I suddenly wondered how to get a certain picture from the video. I was curious and started to explore this new one. Fertile soil, the magic begins slowly.
I used Python to crawl the cover of the B station video before. It is relatively simple.
You can refer to
this article on getting B station video information with python . In fact, you can get it directly by viewing the source code, but how to get any frame of the video. Becomes a problem.
- Dependent environment: cv2 library
- Installation method
You can directly open the command line and enter
pip install opencv-python
Because the access speed of foreign websites is very slow and the connection is often interrupted, you can use the domestic mirror source (take Tsinghua mirror as an example)
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python
It is install opencv-python when installing, and import cv2 when importing . After the installation is complete, you can happily program.
I checked some information on CSDN and found that I used the universal opencv library. I had to copy with Ctrl+C and then paste with Ctrl+V. Refer to a variety of writing methods, and finally achieved results, you can get a certain frame of any local video.
The source code is as follows: