Commit 078428e9 authored by 조이현's avatar 조이현

betav0.1

parent e9aef720
# rtsp_server # rtsp_server
### Dependancy
$ sudo apt install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-ugly
### Exec
$ python test.py
#!/usr/bin/env python
import cv2
import numpy as np
from time import sleep
fps = 15
width = 640
height = 480
#cap = cv2.VideoCapture(0)
cap = cv2.VideoCapture(0)
if not cap.isOpened():
raise Exception("can't open camera")
out = cv2.VideoWriter('appsrc ! videoconvert' + \
' ! x264enc speed-preset=ultrafast tune=zerolatency bitrate=600' + \
' ! rtspclientsink location=rtsp://192.168.5.10:8554/cam',
cv2.CAP_GSTREAMER, 0, fps, (width, height), True)
if not out.isOpened():
raise Exception("can't open video writer")
cap.set(cv2.CAP_PROP_FRAME_WIDTH, width)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, height)
while cap.isOpened():
ret, frame = cap.read()
#print(ret, frame.shape)
if not ret:
continue
out.write(frame)
print("frame written to the server")
cv2.imshow("v", frame)
sleep(1/fps)
cv2.waitKey(1)
cap.release()
out.release()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment