|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- import subprocess as sp
- import time
- import cv2
- import ffmpeg
- # 推流
- import numpy as np
-
- if __name__== "__main__":
-
-
- # with open(str(cv2.__file__),"r") as f:
- # print (f.read())
- # aa = {'loglevel': 'error'}
- # process = (
- # ffmpeg
- # .input("http://cmgw-vpc.lechange.com:8888/LCO/8D0B355PAN8B3B3/0/0/20221019T130437/eabfe43d95971e0ae03de28dad4fd4ce.m3u8", **aa)
- # .output('pipe:', format='rawvideo', pix_fmt='bgr24', loglevel='error')# , bufsize='1000000k'
- # .overwrite_output()
- # .global_args('-an')
- # .run_async(pipe_stdout=True)
- # )
- # self.pull_p = sp.Popen(command, stdout=sp.PIPE, stderr=sp.PIPE)
- cap = cv2.VideoCapture("https://vod.play.t-aaron.com/customerTrans/edc96ea2115a0723a003730956208134/55547af9-184f0827dae-0004-f90c-f2c-7ec68.mp4")
- fps = int(cap.get(cv2.CAP_PROP_FPS))
- print(fps)
- width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
- print(width)
- height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
- print(height)
- fourcc = int(cap.get(cv2.CAP_PROP_FOURCC))
- print(fourcc)
- print(cap.get(7))
- # print(cv2.getBuildInformation())
- # cap.setExceptionMode(True)
- # print(cap.getExceptionMode())
- # cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1920)
- # cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 1080)
- # cap.set(cv2.CAP_PROP_FPS, 25)
- # command = ['ffmpeg',
- # '-y', # 不经过确认,输出时直接覆盖同名文件。
- # '-f', 'rawvideo',
- # '-vcodec','rawvideo',
- # '-pix_fmt', 'bgr24',
- # # '-r', str(13),
- # '-s', "{}x{}".format(width, height),
- # # '-s', "{}x{}".format(1280, 720),
- # '-i', '-', # 指定输入文件
- # '-c:v', 'libx264', # 指定视频编码器
- # '-pix_fmt', 'yuv420p',
- # "-an",
- # # '-b:v', '3000k',
- # '-preset', 'ultrafast', # 指定输出的视频质量,会影响文件的生成速度,有以下几个可用的值 ultrafast,
- # # superfast, veryfast, faster, fast, medium, slow, slower, veryslow。
- # '-f', 'flv',
- # "rtmp://live.push.t-aaron.com/live/THSAq"]
- #
- # # # 管道配置
- # p = sp.Popen(command, stdin=sp.PIPE)
- # # while(cap.isOpened()):
- # while True:
- # start =time.time()
- # # in_bytes = process.stdout.read(1920 * 1080 * 3)
- # # result = (np.frombuffer(in_bytes, np.uint8).reshape([1080, 1920, 3]))
- # # time.sleep(0.04)
- # ret, frame = cap.read()
- # # print(cap.grab())
- # # print("aaaaaaaaaaaaaa", time.time()-start)
- # # start =time.time()
- # # a,b = cap.retrieve()
- # # print("bbbbbbbbbbbbbb", time.time()-start)
- # # if not ret:
- # # print("Opening camera is failed")
- # # break
- # # cv2.namedWindow('picture',0)
- # # cv2.resizeWindow("picture", 1980, 1080)
- # # cv2.imshow('picture', result)
- # # cv2.waitKey(1) & 0xFF == ord('q')
- # p.stdin.write(frame.tostring())
-
|