11

I'm using the following code to open a video stream:

import cv2
video = cv2.VideoCapture()
video.open("some_m3u8_link")
success, image = video.read()

However, even if the code works as intended locally, on Heroku success is always false.

I'm using cedar-14 stack with the following buildpacks:

heroku/python

https://github.com/jonathanong/heroku-buildpack-ffmpeg-latest.git

(I tried several buildpack options for ffmpeg)

Running ffmpeg --version on heroku instance will return ffmpeg version 4.0-static https://johnvansickle.com/ffmpeg/

Is there any setting/configuration I missed in order to make it work on deployment? Thank you!

Later edit: I tried several links for "some_m3u8_link" including from twitch and other streaming services (including traffic streaming li An example for reproducing:

python -c "import cv2; video=cv2.VideoCapture(); video.open('https://hddn01.skylinewebcams.com/live.m3u8?a=5tm6kfqrhqbpblan9j5d4bmua4'); success, image = video.read(); print(success)"

Returns True on local machine and False on Heroku.

(the link is taken from here)

Community
  • 1
  • 1
Dacian Mujdar
  • 585
  • 2
  • 17

3 Answers3

0

You can try this:

import cv2
video = cv2.VideoCapture("some_m3u8_link")
success, image = video.read()
mpromonet
  • 11,326
  • 43
  • 62
  • 91
0
  • You can use pafy module with cv2

-try opencv3 if its not working with cv2

    import cv2, pafy
    url = "Some url to stream"
    video = pafy.new(url)
    best = video.getbest(preftype="webm")
    video=cv2.VideoCapture(best.url)
skysoft999
  • 540
  • 1
  • 6
  • 27
  • As I see from pafy project description it seems to be designed to work on youtube only ("Retrieve YouTube content and metadata") – Dacian Mujdar May 10 '18 at 06:59
0

Specifying the mode to open it might work.

video.open("some_m3u8_link", "r")

If that doesn't work then specifying the file extension might help. You might also need to make a variable equal to the function

Ex:

""" replace .mp4 with the applicable file type, 
I don't know if you need to specify file mode"""
import cv2
video = cv2.VideoCapture()
video = video.open("some_m3u8_link.mp4") 
success, image = video.read()

If this doesn't work then I am out of ideas.

mdfry
  • 1
  • 2