【问题标题】:Read rtmp live streaming video using python使用python读取rtmp直播视频
【发布时间】:2022-10-20 18:53:31
【问题描述】:

我正在使用 rtmp 服务器(NGINX)流式传输会话。我得到的流网址为 rtmp://ip:port/live/stream_name。 如何在我的 python 代码(或任何其他代码)中读取实时流以进行实时转录?

【问题讨论】:

标签: python ffmpeg rtmp live-streaming audio-analysis


【解决方案1】:

您必须使用允许此类过程的库之一,最常用的库之一是 OpenCV。

通过 pip 安装:

python3 -m pip install opencv-python

代码示例

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()

【讨论】:

    猜你喜欢
    • 2014-05-19
    • 2015-04-17
    • 2021-10-23
    • 2015-11-27
    • 1970-01-01
    • 2016-10-15
    • 2019-12-19
    • 2013-10-22
    • 2023-03-13
    相关资源
    最近更新 更多