|
- import subprocess as sp
- from PIL import Image
- import time
- import cv2
- import oss2
- import numpy as np
- # 推流
- if __name__== "__main__":
-
- cap = cv2.VideoCapture(r"https://vod.play.t-aaron.com/customerTrans/14d44756fa6d37db17008d98bdee3558/18ac4fa7-18369b0e703-0004-f90c-f2c-7ec68.mp4")
-
- # Get video information
- 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)
- # ffmpeg command
- # command = ['D:/百度下载/ffmpeg-20200831-4a11a6f-win64-static/bin/ffmpeg.exe',
- # '-y', # 不经过确认,输出时直接覆盖同名文件。
- # '-f', 'rawvideo',
- # '-vcodec','rawvideo',
- # '-pix_fmt', 'bgr24',
- # '-s', "{}x{}".format(width, height),
- # # '-s', "{}x{}".format(1280, 720),
- # '-i', '-', # 指定输入文件
- # '-c:v', 'libx264', # 指定视频编码器
- # '-pix_fmt', 'yuv420p',
- # '-r', '15',
- # '-g', '15',
- # "-an",
- # '-b:v', '3000k',
- # '-preset', 'ultrafast', # 指定输出的视频质量,会影响文件的生成速度,有以下几个可用的值 ultrafast,
- # # superfast, veryfast, faster, fast, medium, slow, slower, veryslow。
- # '-f', 'flv',
- # "rtmp://live.push.t-aaron.com/live/THSAk"]
-
- # # 管道配置
- # p = sp.Popen(command, stdin=sp.PIPE, shell=False)
- while(cap.isOpened()):
- start =time.time()
- # ret, frame = cap.read()
- cap.grab()
- print(time.time()-start)
- # if not ret:
- # print("Opening camera is failed")
- # break
- # p.stdin.write(frame.tostring())
|