OpenCV Heroku - video encode/decode

asked 2018-08-03 06:26:10 -0600

I'm wondering if it is possible to encode/decode videos in production on Heroku using opencv-python (along with the Django framework, or with the Flask framework if it needs to be that instead). Basically, the goal is to be able to run functions like the following

import cv2
video = cv2.VideoCapture('url/to/video')

Then from there, be able to run something like: fps = video.get(cv2.CAP_PROP_FPS)

Currently when I right the fps assignment line, I get back 0 for anything. If you were to run video.read() you would get back false. There seems to be no way to actually read video files in production. Is this an Opencv-python bug? Or is this something that is not possible?

I've asked this question in a number of places and people seem to think that the only line I'm trying to run is import cv2 and claim that what I'm trying to do is "totally possible". I'm not having trouble importing the library. It's getting any video functions to work. These functions all work locally. But they do not work on a Heroku app in production. Is this something that is not possible with this library?

Tools Im using locally: Python 3.6.4, Django 2.0, Anaconda 4.5.4, Opencv-python 3.4.1

edit retag flag offensive close merge delete

Comments

step1: try a print(cv2.getBuildInformation()) and see, if it has any video capabilities (Video IO section)

berak gravatar imageberak ( 2018-08-03 06:56:45 -0600 )edit

also, how exactly did you install cv2 there ?

berak gravatar imageberak ( 2018-08-03 06:57:51 -0600 )edit

When I ran that command, Video I/O section reported NO, but the FFMPEG reported YES

durneveir gravatar imagedurneveir ( 2018-08-03 06:59:17 -0600 )edit

Installing opencv on my heroku app was just a matter of deploying the app. I haven't done anything special just yet. Trying to see if this is possible. I did try attaching custom buildpacks though. Didn't work out.

durneveir gravatar imagedurneveir ( 2018-08-03 07:00:37 -0600 )edit

but the FFMPEG reported YES

same here (installed via PIP / requirements.txt)

so it might be possible !

berak gravatar imageberak ( 2018-08-03 07:09:04 -0600 )edit

Is it working for you?

durneveir gravatar imagedurneveir ( 2018-08-03 07:29:18 -0600 )edit

do you have an url ? (can't find anything useful, weird)

berak gravatar imageberak ( 2018-08-03 07:40:43 -0600 )edit