-
Notifications
You must be signed in to change notification settings - Fork 0
/
flask_video.py
executable file
·36 lines (30 loc) · 1.01 KB
/
flask_video.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/python
from flask import Flask, Response
import cv2
import vlc
app = Flask(__name__)
print(vlc.__version__)
def stream_video_to_rtsp():
# Using VLC's sout function for setting up RTSP
vlc_instance = vlc.Instance()
media_player = vlc_instance.media_player_new()
media = vlc_instance.media_new('input.mp4')
# media = vlc_instance.media_new('meta.mp4')
# Configure RTP/RTSP Stream Output
#media.add_option("sout=#rtp{mux=ts,dst=localhost,port=8554,sdp=rtsp://localhost:8554/stream}")
media.add_option(":sout=#rtp{mux=ts,dst=localhost,port=8554,sdp=rtsp://localhost:8554/stream}")
media.add_option(":sout-all")
media.add_option(":sout-keep")
#media.add_option("sout-all")
#media.add_option("sout-keep")
media_player.set_media(media)
media_player.play()
# Keep the stream running
try:
while True:
pass
except KeyboardInterrupt:
media_player.stop()
print("Stream stopped")
if __name__ == '__main__':
stream_video_to_rtsp()