In [1]:
import cv2
import numpy as np
 
input = 'C://Users//triti//Desktop//Input//0000000C.avi'
output = 'C://Users//triti//Desktop//Output//abc.avi'
# Create a VideoCapture object
cap = cv2.VideoCapture(input)
 
# Check if camera opened successfully
if (cap.isOpened() == False): 
  print("Unable to read camera feed")
 
# Default resolutions of the frame are obtained.The default resolutions are system dependent.
# We convert the resolutions from float to integer.
frame_width = int(cap.get(3))
frame_height = int(cap.get(4))
 
# Define the codec and create VideoWriter object.The output is stored in 'outpy.avi' file.
out = cv2.VideoWriter(output,cv2.VideoWriter_fourcc('M','J','P','G'), 15, (frame_width,frame_height))
 
while(True):
  ret, frame = cap.read()
 
  if ret == True: 
     
    # Write the frame into the file 'output.avi'
    out.write(frame)
 
    # Display the resulting frame    
    #cv2.imshow('frame',frame)
 
    # Press Q on keyboard to stop recording
    if cv2.waitKey(1) & 0xFF == ord('q'):
      break
 
  # Break the loop
  else:
    break 
 
# When everything done, release the video capture and video write objects
cap.release()
out.release()
 
# Closes all the frames
cv2.destroyAllWindows()

In [22]:
cap.read()


Out[22]:
(False, None)

In [23]:
cap = cv2.VideoCapture(input)

In [24]:
cap.read()


Out[24]:
(True, array([[[12, 12, 12],
         [ 9,  9,  9],
         [ 9,  9,  9],
         ...,
         [12, 12, 12],
         [12, 12, 12],
         [12, 12, 12]],
 
        [[ 9,  9,  9],
         [12, 12, 12],
         [12, 12, 12],
         ...,
         [12, 12, 12],
         [13, 13, 13],
         [14, 14, 14]],
 
        [[ 9,  9,  9],
         [ 9,  9,  9],
         [12, 12, 12],
         ...,
         [13, 13, 13],
         [14, 14, 14],
         [14, 14, 14]],
 
        ...,
 
        [[16, 16, 16],
         [19, 19, 19],
         [13, 13, 13],
         ...,
         [ 7,  7,  7],
         [ 6,  6,  6],
         [ 5,  5,  5]],
 
        [[13, 13, 13],
         [19, 19, 19],
         [16, 16, 16],
         ...,
         [ 6,  6,  6],
         [ 4,  4,  4],
         [ 4,  4,  4]],
 
        [[13, 13, 13],
         [19, 19, 19],
         [16, 16, 16],
         ...,
         [ 4,  4,  4],
         [ 4,  4,  4],
         [ 3,  3,  3]]], dtype=uint8))

In [25]:
ob = cap.read()

In [26]:
ob[1]


Out[26]:
array([[[13, 13, 13],
        [11, 11, 11],
        [ 8,  8,  8],
        ...,
        [11, 11, 11],
        [10, 10, 10],
        [11, 11, 11]],

       [[13, 13, 13],
        [11, 11, 11],
        [11, 11, 11],
        ...,
        [11, 11, 11],
        [12, 12, 12],
        [11, 11, 11]],

       [[13, 13, 13],
        [ 8,  8,  8],
        [ 8,  8,  8],
        ...,
        [12, 12, 12],
        [12, 12, 12],
        [12, 12, 12]],

       ...,

       [[16, 16, 16],
        [11, 11, 11],
        [16, 16, 16],
        ...,
        [ 6,  6,  6],
        [ 5,  5,  5],
        [ 4,  4,  4]],

       [[16, 16, 16],
        [16, 16, 16],
        [16, 16, 16],
        ...,
        [ 5,  5,  5],
        [ 4,  4,  4],
        [ 3,  3,  3]],

       [[14, 14, 14],
        [14, 14, 14],
        [16, 16, 16],
        ...,
        [ 4,  4,  4],
        [ 3,  3,  3],
        [ 3,  3,  3]]], dtype=uint8)

In [27]:
type(ob[1])


Out[27]:
numpy.ndarray

In [ ]: