Advertisement
nbatothemax

Untitled

May 5th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. import ffmpeg
  2.  
  3.  
  4. WIDTH = 1280
  5. HEIGHT = 720
  6.  
  7. stream_decoder = (
  8.     ffmpeg
  9.     .input('pipe:', format='rawvideo', pix_fmt='rgb24', s='{}x{}'.format(WIDTH, HEIGHT))
  10.     .output('pipe:', format='rawvideo', pix_fmt='rgb24', s='{}x{}'.format(WIDTH, HEIGHT))
  11.     .run_async(pipe_stdout=True)
  12. )
  13.  
  14. while True:
  15.     # READ 1280*720*3 elements from socket
  16.    
  17.     stream_decoder.stdin.write(read_data)
  18.     frame = stream_decoder.stdout.read(width * height * 3)
  19.  
  20.     if not frame:
  21.         break
  22.     in_frame = (
  23.         np
  24.         .frombuffer(frame, np.uint8)
  25.         .reshape([height, width, 3])
  26.     )
  27.  
  28.     # accelerate
  29.  
  30.     # send array
  31.  
  32. process1.stdin.close()
  33. process1.wait()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement