0

I am streaming a session using rtmp server(NGINX). I got the stream url as rtmp://ip:port/live/stream_name. How can I read the live stream in my python code(or any other) to do live transcription?

  • Does this answer your question? [Live Speech to Text Transcription in Python](https://stackoverflow.com/questions/65987662/live-speech-to-text-transcription-in-python) – DialFrost Aug 12 '22 at 07:42
  • Thank you for the reply. But, I would like to do transcription from the rtmp stream directly – Telugu Tracker Aug 23 '22 at 05:25

1 Answers1

1

You have to use one of libraries that allow such process, one of the most commonly used is OpenCV.

Install through pip:

python3 -m pip install opencv-python

Code sample

import cv2  # Import OpenCV lib

cap = cv2.VideoCapture('<your RTMP url>') # Open video source as object
while cap.isOpened():  # Untill end of file/error occured
    ret, frame = cap.read()  # Read frame as object - numpy.ndarray, ret is a confirmation of a successfull retrieval of the frame
    if ret: 
        <your code here>
    else:
        break
cap.release()
skylighty
  • 21
  • 3