欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

python-視頻分幀&多幀合成視頻實(shí)例

 更新時(shí)間:2019年12月10日 09:23:09   作者:放下扳手&拿起鍵盤(pán)  
今天小編就為大家分享一篇python-視頻分幀&多幀合成視頻實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧

我就廢話(huà)不多說(shuō)了,直接上代碼吧!

1.視頻分幀:

import cv2
vidcap = cv2.VideoCapture('005.avi')
success,image = vidcap.read()
count = 0
success = True
while success:
 success,image = vidcap.read()
 cv2.imwrite("frame%d.jpg" % count, image)   # save frame as JPEG file
 if cv2.waitKey(10) == 27:           
   break
 count += 1

2.多幀合成視頻:

import cv2
 
def images_to_video():
  fps = 30 # 幀率
  num_frames = 500
  img_array = []
  img_width = 720
  img_height = 1280
  for i in range(num_frames+1):
    filename = "./frames/"+str(i)+".png"
    img = cv2.imread(filename)
 
    if img is None:
      print(filename + " is non-existent!")
      continue
    img_array.append(img)
 
  out = cv2.VideoWriter('demo.avi', cv2.VideoWriter_fourcc(*'DIVX'), fps,(img_width,img_height))
 
  for i in range(len(img_array)):
    out.write(img_array[i])
  out.release()
 
 
def main():
  
  images_to_video()
 
 
if __name__ == "__main__":
  main()

以上這篇python-視頻分幀&多幀合成視頻實(shí)例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論