tuoheng_algN/vodsdk/test/test_push_stream.py

42 lines
1.9 KiB
Python

from util.Cv2Utils import video_conjuncing, write_or_video, write_ai_video, push_video_stream, close_all_p,pull_read_video_stream
import inspect
import psutil
def check_cpu(current_line_number):
cpu_use = psutil.cpu_percent()
cpu_mem = psutil.virtual_memory().percent
cpu_swap = psutil.swap_memory().percent
mem = psutil.virtual_memory()
# 已经使用的内存量(包括缓存和缓冲区)
used_mem = mem.used/(1024**2)
#current_line_number = inspect.currentframe().f_lineno
print( '---line:{} ,CPU 使用率:{}, 内存使用:{},{:4.0f}M, SWAP内存使用率:{}'.format(current_line_number,cpu_use, cpu_mem,used_mem,cpu_swap) )
if __name__=='__main__':
width=1920;height=1620;width_height_3=3110400;all_frames=3687; w_2=960;h_2=540
request_id='11111111111111'
pull_p=None
#pull_url='https://vod.play.t-aaron.com/customerTrans/edc96ea2115a0723a003730956208134/4b773ace-18f56a8ed7d-0004-f90c-f2c-7ec68.mp4'
pull_url='https://vod.play.t-aaron.com/customerTrans/edc96ea2115a0723a003730956208134/55547af9-184f0827dae-0004-f90c-f2c-7ec68.mp4'
push_p=None
#push_url='rtmp://live.push.t-aaron.com/live/prod33'
push_url='rtmp://live.push.t-aaron.com/live/innertest32'
check_cpu(inspect.currentframe().f_lineno)
#测试拉流OK
while True:
check_cpu(inspect.currentframe().f_lineno)
frame, pull_p, width, height = pull_read_video_stream(pull_p, pull_url, width, height,
width_height_3, w_2, h_2, request_id)
if frame is None:
break
check_cpu(inspect.currentframe().f_lineno)
#测试推流
push_p=push_video_stream(frame, push_p, push_url, [1,1], '2222222222222222222')
check_cpu(inspect.currentframe().f_lineno)
print('noth')