Read Frames from RTSP Stream in Python

前端 未结 6 463
旧巷少年郎
旧巷少年郎 2020-12-13 16:12

I have recently set up a Raspberry Pi camera and am streaming the frames over RTSP. While it may not be completely necessary, here is the command I am using the broadcast th

6条回答
  •  不思量自难忘°
    2020-12-13 16:20

    Bit of a hacky solution, but you can use the VLC python bindings (you can install it with pip install python-vlc) and play the stream:

    import vlc
    player=vlc.MediaPlayer('rtsp://:8554/output.h264')
    player.play()
    

    Then take a snapshot every second or so:

    while 1:
        time.sleep(1)
        player.video_take_snapshot(0, '.snapshot.tmp.png', 0, 0)
    

    And then you can use SimpleCV or something for processing (just load the image file '.snapshot.tmp.png' into your processing library).

提交回复
热议问题