ADD file via upload
This commit is contained in:
parent
3eb92c350d
commit
b5ab22c8f1
|
@ -0,0 +1,54 @@
|
|||
from ffmpy3 import FFmpeg
|
||||
from cv2 import cv2
|
||||
import subprocess
|
||||
|
||||
rtmpUrl = "rtmp://175.24.114.42:1935/myapp/test"
|
||||
camera_path = "output.mp4"
|
||||
cap = cv2.VideoCapture(0)
|
||||
|
||||
reRate=0.6 #缩放比例
|
||||
|
||||
# Get video information
|
||||
fps = int(cap.get(cv2.CAP_PROP_FPS))
|
||||
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)*reRate)
|
||||
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)*reRate)
|
||||
|
||||
# ffmpeg command
|
||||
PicCommand = ['ffmpeg',
|
||||
'-y',
|
||||
'-f', 'rawvideo',
|
||||
'-vcodec','rawvideo',
|
||||
'-pix_fmt', 'bgr24',
|
||||
'-s', "{}x{}".format(width, height),
|
||||
'-r', str(fps),
|
||||
'-i', '-',
|
||||
'-c:v', 'libx264',
|
||||
'-pix_fmt', 'yuv420p',
|
||||
'-preset', 'ultrafast',
|
||||
'-f', 'flv',
|
||||
rtmpUrl]
|
||||
|
||||
|
||||
SouCmd = ['ffmpeg',
|
||||
'-re',
|
||||
'-i',
|
||||
'''C:\\1.mp3''',
|
||||
'-vn',
|
||||
'-acodec',
|
||||
'copy',
|
||||
'-f', 'flv',
|
||||
rtmpUrl]
|
||||
|
||||
# 管道配置
|
||||
p = subprocess.Popen(PicCommand, stdin=subprocess.PIPE,shell=False)
|
||||
|
||||
# read webcamera
|
||||
while(cap.isOpened()):
|
||||
ret, frame = cap.read()
|
||||
reFrame=cv2.resize(frame,(0,0),None,reRate,reRate)
|
||||
if not ret:
|
||||
print("Opening camera is failed")
|
||||
break
|
||||
|
||||
|
||||
p.stdin.write(reFrame.tostring())
|
Loading…
Reference in New Issue