您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

80 行
3.1KB

  1. import subprocess as sp
  2. import time
  3. import cv2
  4. import ffmpeg
  5. # 推流
  6. import numpy as np
  7. if __name__== "__main__":
  8. # with open(str(cv2.__file__),"r") as f:
  9. # print (f.read())
  10. # aa = {'loglevel': 'error'}
  11. # process = (
  12. # ffmpeg
  13. # .input("http://cmgw-vpc.lechange.com:8888/LCO/8D0B355PAN8B3B3/0/0/20221019T130437/eabfe43d95971e0ae03de28dad4fd4ce.m3u8", **aa)
  14. # .output('pipe:', format='rawvideo', pix_fmt='bgr24', loglevel='error')# , bufsize='1000000k'
  15. # .overwrite_output()
  16. # .global_args('-an')
  17. # .run_async(pipe_stdout=True)
  18. # )
  19. # self.pull_p = sp.Popen(command, stdout=sp.PIPE, stderr=sp.PIPE)
  20. cap = cv2.VideoCapture("https://vod.play.t-aaron.com/customerTrans/edc96ea2115a0723a003730956208134/55547af9-184f0827dae-0004-f90c-f2c-7ec68.mp4")
  21. fps = int(cap.get(cv2.CAP_PROP_FPS))
  22. print(fps)
  23. width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
  24. print(width)
  25. height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
  26. print(height)
  27. fourcc = int(cap.get(cv2.CAP_PROP_FOURCC))
  28. print(fourcc)
  29. print(cap.get(7))
  30. # print(cv2.getBuildInformation())
  31. # cap.setExceptionMode(True)
  32. # print(cap.getExceptionMode())
  33. # cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1920)
  34. # cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 1080)
  35. # cap.set(cv2.CAP_PROP_FPS, 25)
  36. # command = ['ffmpeg',
  37. # '-y', # 不经过确认,输出时直接覆盖同名文件。
  38. # '-f', 'rawvideo',
  39. # '-vcodec','rawvideo',
  40. # '-pix_fmt', 'bgr24',
  41. # # '-r', str(13),
  42. # '-s', "{}x{}".format(width, height),
  43. # # '-s', "{}x{}".format(1280, 720),
  44. # '-i', '-', # 指定输入文件
  45. # '-c:v', 'libx264', # 指定视频编码器
  46. # '-pix_fmt', 'yuv420p',
  47. # "-an",
  48. # # '-b:v', '3000k',
  49. # '-preset', 'ultrafast', # 指定输出的视频质量,会影响文件的生成速度,有以下几个可用的值 ultrafast,
  50. # # superfast, veryfast, faster, fast, medium, slow, slower, veryslow。
  51. # '-f', 'flv',
  52. # "rtmp://live.push.t-aaron.com/live/THSAq"]
  53. #
  54. # # # 管道配置
  55. # p = sp.Popen(command, stdin=sp.PIPE)
  56. # # while(cap.isOpened()):
  57. # while True:
  58. # start =time.time()
  59. # # in_bytes = process.stdout.read(1920 * 1080 * 3)
  60. # # result = (np.frombuffer(in_bytes, np.uint8).reshape([1080, 1920, 3]))
  61. # # time.sleep(0.04)
  62. # ret, frame = cap.read()
  63. # # print(cap.grab())
  64. # # print("aaaaaaaaaaaaaa", time.time()-start)
  65. # # start =time.time()
  66. # # a,b = cap.retrieve()
  67. # # print("bbbbbbbbbbbbbb", time.time()-start)
  68. # # if not ret:
  69. # # print("Opening camera is failed")
  70. # # break
  71. # # cv2.namedWindow('picture',0)
  72. # # cv2.resizeWindow("picture", 1980, 1080)
  73. # # cv2.imshow('picture', result)
  74. # # cv2.waitKey(1) & 0xFF == ord('q')
  75. # p.stdin.write(frame.tostring())