# 直播測試
ssh連到172.16.1.88
要先開啟rtsp simple server
./rtsp-simple-server
使用ffmpeg 開啟直播
\[CH01\]\ 2022-04-11\ 14.30.00_Joined.mp4 為影片檔名
ffmpeg-5.0.1-amd64-static/ffmpeg -re -stream_loop -1 -i \[CH01\]\ 2022-04-11\ 14.30.00_Joined.mp4 -c copy -f rtsp rtsp://localhost:8554/mystream
windows ffmpeg開法
rtsp-simple-server.exe
ffmpeg.exe -re -stream_loop -1 -i \[CH01\]\ 2022-04-11\ 14.30.00_Joined.mp4 -c copy -f rtsp rtsp://localhost:8554/mystream1
ffmpeg.exe -re -stream_loop -1 -i "E:/DVR/0325/[CH01] 2023-03-25 15.30.01.mp4" -c copy -f rtsp rtsp://localhost:8554/mystream2
ffmpeg.exe -re -stream_loop -1 -i 1418-1423.mp4 -c copy -f rtsp rtsp://localhost:8554/mystream1
ffmpeg -1 -i 1418-1423.mp4 -c copy -f rtsp rtsp://localhost:8554/mystream1
ffmpeg.exe -re -i "E:/DVR/0816/[CH01] 2022-08-16 15.00.00.mp4" -c copy -f rtsp rtsp://localhost:8554/mystream1
使用U100或U150進行直播測試
開啟pycharm python U100.py
修改rtsp ip address
```
import subprocess
in_stream = 'rtsp://172.16.1.250:8554/mystream'
width = 1920
height = 1080
```
修改time_config
```
global web_out,web_in ,save_switch,frame_number
save_switch = True
tracker = EuclideanDistTracker()
time_config = 1000
# vid = cv2.VideoCapture(f"rtsp://172.16.1.250:8554/live")
object_detector = cv2.createBackgroundSubtractorKNN(10, 10000, True)
```
time_config 位置
```
elif temp_number_of_steels == number_of_steels and number_of_steels >= 1 and (time_msec - initial_time) >= 30 and (time_msec - initial_time) < time_config:
flag = True
elif temp_number_of_steels < number_of_steels and number_of_steels >= 1 and temp_number_of_steels >= 1 and (time_msec - initial_time) >= 30 and (time_msec - initial_time) < time_config:
flag = True
if (time_msec - initial_time) >= 0 and (time_msec - initial_time) < time_config:
curve_or_straight_accu.append(x_list[i])
time_to_alert = time_config-500
if switch_5 == 1:
time_to_alert = time_config-500
if (time_msec - initial_time) >= time_config+450 and initial_time > 0:
curve_or_straight_accu.clear()
curve_or_straight_accu_final = [1,1,1,1,1,1,1,1,1,1]
if (time_msec - initial_time) >= time_config+500 and initial_time > 0:
x_list_final.clear()
```
連線到測試的那台電腦 查看即時辨識 ip:5000 白色電腦172.16.1.245:5000 黑色電腦172.16.1.250:5000
您好!如果您想要使用ffmpeg自動重連,可以使用以下指令:ffmpeg -reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5 -i <URL>。其中,-reconnect 1表示啟用自動重連,-reconnect_streamed 1表示啟用對串流的自動重連,-reconnect_delay_max 5表示最大重連延遲為5秒。請注意,您需要將<URL>替換為您要連接的串流URL。1
您可以使用以下命令來抓取串流並顯示在螢幕上:ffmpeg -i <stream-url> -f mpegts -codec:v mpeg1video -s 640x480 -b:v 800k -r 30 http://localhost:8080/stream.mpg