- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Play a video in reverse mode using Python OpenCv
The full form of OpenCv is Open Source Computer Vision, using this library we can perform different operations on images, videos.
Application areas of OpenCV
- Facial recognition system
- Motion tracking
- Artificial neural network
- Deep neural network
- Video streaming etc.
For installing on Windows we can use this command line
pip install opencv-python
For Linux −
sudo apt-get install python-opencv
To complete our task we have to follow some steps −
Step 1: We import OpenCv library named cv2. Step 2: Take a video as input data. Step 3: First we break the video into a number of frames and store all these frames in a list. Step 4: When we are getting all the frames then we shall apply iteration method. Step 5: Here we apply iteration for reversing the list. Step 6: Use the reverse() method for reversing the order of the frames in the list.
Example code
import cv2 # Grab the current frame. my_check , vid = cap.read() # use counter variable for # Counting frames counter = 0 check = True frame_list = [] while(check == True): cv2.imwrite("frame%d.jpg" %counter , vid) check , vid = cap.read() frame_list.append(vid) # increment the counter by 1 counter += 1 frame_list.pop() # looping in the List of frames. for frame in frame_list: # show the frame. cv2.imshow("Frame" , frame) if cv2.waitKey(25) and 0xFF == ord("q"): break cap.release() # close any open windows cv2.destroyAllWindows() frame_list.reverse() for frame in frame_list: cv2.imshow("Frame" , frame) if cv2.waitKey(25) and 0xFF == ord("q"): break cap.release() cv2.destroyAllWindows()
Output
- Related Articles
- How to rotate a video in OpenCV using C++?
- HTML DOM Video play( ) Method
- Play local (hard-drive) video file with HTML5 video tag?
- Play infinitely looping video on-load in HTML5
- How can we change the resolution of a video in OpenCV using C++?
- How to capture video from default camera in OpenCV using C++?
- How to capture video from other cameras in OpenCV using C++?
- How to load video from your computer in OpenCV using C++?
- How to store video on your computer in OpenCV using C++?
- How to play YouTube video in my Android Application?
- How to play audio and video file in iOS?
- How android YouTube app Play Video from Intent
- Template matching using OpenCV in Python
- Arithmetic operations using OpenCV in Python
- Python Program to Reverse a String Using Recursion

Advertisements