0

After reading this thread: streaming m3u8 file with opencv

I've implemented this code to stream a live camera:

import m3u8
import cv2
import subprocess as sp
import numpy as np

VIDEO_URL = r'https://5e0da72d486c5.streamlock.net:8443/ayalon/HaHalacha.stream/playlist.m3u8'
FFMPEG_BIN = r"C:\ffmpeg-n4.4-latest-win64-lgpl-4.4\bin\ffmpeg.exe"
# cv2.namedWindow("GoPro", cv2.CV_WINDOW_AUTOSIZE)

pipe = sp.Popen([FFMPEG_BIN, "-i", VIDEO_URL,
                 "-loglevel", "quiet",  # no text output
                 "-an",  # disable audio
                 "-f", "image2pipe",
                 "-pix_fmt", "bgr24",
                 "-vcodec", "rawvideo", "-"],
                stdin=sp.PIPE, stdout=sp.PIPE)
while True:
    raw_image = pipe.stdout.read(432 * 240 * 3)  # read 432*240*3 bytes (= 1 frame)
    image = np.frombuffer(raw_image)  # np.fromstring(raw_image, dtype='uint8').reshape((240, 432, 3))
    cv2.imshow("Stream", image)
    if cv2.waitKey(5) == 27:
        break
cv2.destroyAllWindows()

But the image i see is just white noise. What am i missing? Thx

Guy Barash
  • 470
  • 5
  • 17

1 Answers1

0

Just so you know, when you go on this website to download the lib :

https://github.com/BtbN/FFmpeg-Builds/releases

The ones who have shared in their names means they're already built

The ones without mean that you have to build them yourselves

try using prebuilt one

Kanoto
  • 11
  • 2