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()
Articoli simili
- What are the best programming blogs?
- Quale negozio di video online è meglio per guardare un video - Amazon Video o Google Play?
- È consigliabile imparare Tkinter in Python per avanzare la propria carriera o per ottenere una migliore offerta di lavoro come sviluppatore Python?
- Come eseguire uno script Python senza installare Python