Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I've Python code that enables capture and size modification of a video content stored in a local file (there is source written by Flask):
   

import cv2
import time
    
    
from flask import render_template, Flask, send_from_directory, abort, json, \
       Response  
    
app = Flask(__name__)
   
@app.route("/")
def index():
   """Video streaming home page."""
   return render_template('index.html')
    
def gen():
   """Video streaming generator function."""
   while True:
      cap = cv2.VideoCapture('/var/media/something.ts')
    
      # Read until video is completed
      while (cap.isOpened()):
         # Capture frame-by-frame
         ret, img = cap.read()
         if ret == True:
            img = cv2.resize(img, (0,0), fx=1.5, fy=1.5)
            frame = cv2.imencode('.jpg', img)[1].tobytes()
            yield (b'--frame\r\n'b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')
            time.sleep(0.1)
         else:
            break
    
@app.route('/video_feed')
def video_feed():
  """Video streaming route. Put this in the src attribute of an img tag."""
  return Response(gen(),
                  mimetype='multipart/x-mixed-replace; boundary=frame')
    
if __name__ == '__main__':
  app.run(host = "0.0.0.0", port = '5000')


While program running, the video plays in browser on port 5000, well. I wonder if there is any alternate option to display content in the same way, but omitting any OpenCV-featured functions like `VideoCapture` or `resize`. Is it reachable to do that? What Python modules and functions may replace instructions like those with OpenCV?

What I have tried:

I was searching for any OpenCV-independent solutions whenever in Internet, but code stuff I found includes just that library to be removed.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900