mirror of
https://github.com/bluenviron/mediamtx.git
synced 2025-12-24 20:11:56 -08:00
update gstreamer recommended pipeline (#1682)
This commit is contained in:
parent
34757620b8
commit
e666e480cc
1 changed files with 23 additions and 7 deletions
30
README.md
30
README.md
|
|
@ -737,31 +737,47 @@ Videos can be published with `VideoWriter`:
|
|||
```python
|
||||
import cv2
|
||||
import numpy as np
|
||||
from time import sleep
|
||||
from time import sleep, time
|
||||
|
||||
fps = 20
|
||||
fps = 15
|
||||
width = 800
|
||||
height = 600
|
||||
colors = [
|
||||
(0, 0, 255),
|
||||
(255, 0, 0),
|
||||
(0, 255, 0),
|
||||
]
|
||||
|
||||
out = cv2.VideoWriter('appsrc ! videoconvert' + \
|
||||
' ! x264enc speed-preset=ultrafast bitrate=600 key-int-max=40' + \
|
||||
' ! x264enc speed-preset=ultrafast bitrate=600 key-int-max=' + str(fps * 2) + \
|
||||
' ! video/x-h264,profile=baseline' + \
|
||||
' ! rtspclientsink location=rtsp://localhost:8554/mystream',
|
||||
cv2.CAP_GSTREAMER, 0, fps, (width, height), True)
|
||||
if not out.isOpened():
|
||||
raise Exception("can't open video writer")
|
||||
|
||||
curcolor = 0
|
||||
start = time()
|
||||
|
||||
while True:
|
||||
frame = np.zeros((height, width, 3), np.uint8)
|
||||
|
||||
# create a red rectangle
|
||||
# create a rectangle
|
||||
color = colors[curcolor]
|
||||
curcolor += 1
|
||||
curcolor %= len(colors)
|
||||
for y in range(0, int(frame.shape[0] / 2)):
|
||||
for x in range(0, int(frame.shape[1] / 2)):
|
||||
frame[y][x] = (0, 0, 255)
|
||||
frame[y][x] = color
|
||||
|
||||
out.write(frame)
|
||||
print("frame written to the server")
|
||||
|
||||
sleep(1 / fps)
|
||||
now = time()
|
||||
diff = (1 / fps) - now - start
|
||||
if diff > 0:
|
||||
sleep(diff)
|
||||
start = now
|
||||
```
|
||||
|
||||
### From a UDP stream
|
||||
|
|
@ -770,7 +786,7 @@ The server supports ingesting UDP/MPEG-TS packets (i.e. MPEG-TS packets sent wit
|
|||
|
||||
```
|
||||
gst-launch-1.0 -v mpegtsmux name=mux alignment=1 ! udpsink host=238.0.0.1 port=1234 \
|
||||
videotestsrc ! video/x-raw,width=1280,height=720 ! x264enc speed-preset=ultrafast bitrate=6000 key-int-max=40 ! mux. \
|
||||
videotestsrc ! video/x-raw,width=1280,height=720 ! x264enc speed-preset=ultrafast bitrate=3000 key-int-max=60 ! video/x-h264,profile=high ! mux. \
|
||||
audiotestsrc ! audioconvert ! avenc_aac ! mux.
|
||||
```
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue