How to play a video by Python programming
A2A.
You can play videos in any environment using python’s OpenCV library.
This is a great library for image processing.
For playing video in the web-browser you will need django or flask with openCV integration.
Check out these links if interested:
The Web framework for perfectionists with deadlines
Flask (A Python Microframework)
Welcome to Pyramid, a Python Web Framework(for smaller apps)
But if you just wanna play video from your local PC, that’s a 10-liner(provided openCV is installed, you can install it using pip : pip install opencv-python)
here is the sample code.
- import cv2
- import numpy as np
- cap = cv2.VideoCapture('Your_video.mp4')
- '''
- Make sure your_video is in the same dir, else mention the full path.
- '''
- while True:
- ret, frame = cap.read()
- gray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
- cv2.imshow('frame',frame)
- cv2.imshow('grayF',gray)
- if cv2.waitKey(1) & 0xFF == ord('q'):
- break
- cap.release()
- cv2.destroyAllWindows()
Artigos semelhantes
- What are the best programming blogs?
- Qual loja de vídeo online é melhor para assistir a um vídeo - Amazon Video ou Google Play?
- É aconselhável aprender Tkinter em Python para avançar na carreira ou para obter uma melhor oferta de emprego como desenvolvedor Python?
- Como executar um script Python sem instalar o Python