Object Detection Demo

Welcome to the object detection inference walkthrough! This notebook will walk you step by step through the process of using a pre-trained model to detect objects in an image. Make sure to follow the installation instructions before you start.

Imports

In [11]:
import numpy as np
import os
import six.moves.urllib as urllib
import sys
import tarfile
import tensorflow as tf
import zipfile

from collections import defaultdict
from io import StringIO
from matplotlib import pyplot as plt
from PIL import Image

# This is needed since the notebook is stored in the object_detection folder.
sys.path.append("..")
from object_detection.utils import ops as utils_ops

if tf.__version__ < '1.4.0':
  raise ImportError('Please upgrade your tensorflow installation to v1.4.* or later!')
print(tf.__version__)
1.5.0

Env setup

Object detection imports

Here are the imports from the object detection module.

In [12]:
from utils import label_map_util

from utils import visualization_utils as vis_util

Model preparation

Variables

Any model exported using the export_inference_graph.py tool can be loaded here simply by changing PATH_TO_CKPT to point to a new .pb file.

By default we use an "SSD with Mobilenet" model here. See the detection model zoo for a list of other models that can be run out-of-the-box with varying speeds and accuracies.

In [13]:
# Path to frozen detection graph. This is the actual model that is used for the object detection.
PATH_TO_CKPT = '/home/priya/Documents/mask_rcnn/mask_rcnn_inception_v2_coco_2018_01_28' + '/frozen_inference_graph.pb'

# List of the strings that is used to add correct label for each box.
PATH_TO_LABELS = os.path.join('data', 'mscoco_label_map.pbtxt')

NUM_CLASSES = 90

Load a (frozen) Tensorflow model into memory.

In [14]:
detection_graph = tf.Graph()
with detection_graph.as_default():
  od_graph_def = tf.GraphDef()
  with tf.gfile.GFile(PATH_TO_CKPT, 'rb') as fid:
    serialized_graph = fid.read()
    od_graph_def.ParseFromString(serialized_graph)
    tf.import_graph_def(od_graph_def, name='')

Loading label map

Label maps map indices to category names, so that when our convolution network predicts 5, we know that this corresponds to airplane. Here we use internal utility functions, but anything that returns a dictionary mapping integers to appropriate string labels would be fine

In [15]:
label_map = label_map_util.load_labelmap(PATH_TO_LABELS)
categories = label_map_util.convert_label_map_to_categories(label_map, max_num_classes=NUM_CLASSES, use_display_name=True)
category_index = label_map_util.create_category_index(categories)

Helper code

In [16]:
def load_image_into_numpy_array(image):
  (im_width, im_height) = image.size
  return np.array(image.getdata()).reshape(
      (im_height, im_width, 3)).astype(np.uint8)

Detection

In [17]:
# Import everything needed to edit/save/watch video clips
from moviepy.editor import VideoFileClip
from IPython.display import HTML
In [18]:
def detect_videos(image_np, sess, detection_graph):
    
    with detection_graph.as_default():
        
        ops = tf.get_default_graph().get_operations()
        all_tensor_names = {output.name for op in ops for output in op.outputs}
        tensor_dict = {}
        for key in [
              'num_detections', 'detection_boxes', 'detection_scores',
              'detection_classes', 'detection_masks'
          ]:
            tensor_name = key + ':0'
            if tensor_name in all_tensor_names:
                tensor_dict[key] = tf.get_default_graph().get_tensor_by_name(tensor_name)
        if 'detection_masks' in tensor_dict:
            # The following processing is only for single image
            detection_boxes = tf.squeeze(tensor_dict['detection_boxes'], [0])
            detection_masks = tf.squeeze(tensor_dict['detection_masks'], [0])
            # Reframe is required to translate mask from box coordinates to image coordinates and fit the image size.
            real_num_detection = tf.cast(tensor_dict['num_detections'][0], tf.int32)
            detection_boxes = tf.slice(detection_boxes, [0, 0], [real_num_detection, -1])
            detection_masks = tf.slice(detection_masks, [0, 0, 0], [real_num_detection, -1, -1])
            detection_masks_reframed = utils_ops.reframe_box_masks_to_image_masks(
                detection_masks, detection_boxes, image_np.shape[0], image_np.shape[1])
            detection_masks_reframed = tf.cast(
                tf.greater(detection_masks_reframed, 0.5), tf.uint8)
            # Follow the convention by adding back the batch dimension
            tensor_dict['detection_masks'] = tf.expand_dims(
                detection_masks_reframed, 0)
        image_tensor = tf.get_default_graph().get_tensor_by_name('image_tensor:0')

      # Run inference
        output_dict = sess.run(tensor_dict,
                             feed_dict={image_tensor: np.expand_dims(image_np, 0)})

      # all outputs are float32 numpy arrays, so convert types as appropriate
        output_dict['num_detections'] = int(output_dict['num_detections'][0])
        output_dict['detection_classes'] = output_dict[
          'detection_classes'][0].astype(np.uint8)
        output_dict['detection_boxes'] = output_dict['detection_boxes'][0]
        output_dict['detection_scores'] = output_dict['detection_scores'][0]
        if 'detection_masks' in output_dict:
            output_dict['detection_masks'] = output_dict['detection_masks'][0]

        vis_util.visualize_boxes_and_labels_on_image_array(
          image_np,
          output_dict['detection_boxes'],
          output_dict['detection_classes'],
          output_dict['detection_scores'],
          category_index,
          instance_masks=output_dict.get('detection_masks'),
          use_normalized_coordinates=True,
          line_thickness=1)
                
    return image_np
In [19]:
def process_image(image):  
    
    global counter
    
    if counter%1 ==0:
   
        with detection_graph.as_default():
            with tf.Session(graph=detection_graph) as sess:
                image_np = detect_videos(image, sess, detection_graph) 

    counter +=1 
    
    return image
In [20]:
filename = 'videos_in/cars_ppl.mp4'
new_loc = 'videos_out/cars_ppl_out.mp4'

counter = 0

white_output = new_loc
clip1 = VideoFileClip(filename).subclip(60,68)
white_clip = clip1.fl_image(process_image) #NOTE: this function expects color images!!s
%time white_clip.write_videofile(white_output, audio=False)
[MoviePy] >>>> Building video videos_out/cars_ppl_out.mp4
[MoviePy] Writing video videos_out/cars_ppl_out.mp4
  0%|          | 0/192 [00:00<?, ?it/s]
  1%|          | 1/192 [00:05<18:52,  5.93s/it]
  1%|          | 2/192 [00:11<18:45,  5.93s/it]
  2%|▏         | 3/192 [00:17<18:37,  5.91s/it]
  2%|▏         | 4/192 [00:23<18:27,  5.89s/it]
  3%|▎         | 5/192 [00:29<18:12,  5.84s/it]
  3%|▎         | 6/192 [00:34<17:56,  5.79s/it]
  4%|▎         | 7/192 [00:40<17:44,  5.76s/it]
  4%|▍         | 8/192 [00:46<17:31,  5.72s/it]
  5%|▍         | 9/192 [00:51<17:19,  5.68s/it]
  5%|▌         | 10/192 [00:57<17:09,  5.66s/it]
  6%|▌         | 11/192 [01:03<17:00,  5.64s/it]
  6%|▋         | 12/192 [01:08<16:52,  5.62s/it]
  7%|▋         | 13/192 [01:14<16:45,  5.62s/it]
  7%|▋         | 14/192 [01:19<16:39,  5.62s/it]
  8%|▊         | 15/192 [01:25<16:32,  5.61s/it]
  8%|▊         | 16/192 [01:31<16:31,  5.64s/it]
  9%|▉         | 17/192 [01:37<16:41,  5.72s/it]
  9%|▉         | 18/192 [01:42<16:28,  5.68s/it]
 10%|▉         | 19/192 [01:48<16:19,  5.66s/it]
 10%|█         | 20/192 [01:53<16:12,  5.66s/it]
 11%|█         | 21/192 [01:59<16:04,  5.64s/it]
 11%|█▏        | 22/192 [02:05<15:56,  5.63s/it]
 12%|█▏        | 23/192 [02:10<15:49,  5.62s/it]
 12%|█▎        | 24/192 [02:16<15:45,  5.63s/it]
 13%|█▎        | 25/192 [02:22<15:40,  5.63s/it]
 14%|█▎        | 26/192 [02:27<15:35,  5.63s/it]
 14%|█▍        | 27/192 [02:33<15:30,  5.64s/it]
 15%|█▍        | 28/192 [02:38<15:24,  5.64s/it]
 15%|█▌        | 29/192 [02:44<15:17,  5.63s/it]
 16%|█▌        | 30/192 [02:50<15:11,  5.62s/it]
 16%|█▌        | 31/192 [02:55<15:05,  5.62s/it]
 17%|█▋        | 32/192 [03:01<14:57,  5.61s/it]
 17%|█▋        | 33/192 [03:06<14:50,  5.60s/it]
 18%|█▊        | 34/192 [03:12<14:44,  5.60s/it]
 18%|█▊        | 35/192 [03:18<14:39,  5.60s/it]
 19%|█▉        | 36/192 [03:23<14:34,  5.60s/it]
 19%|█▉        | 37/192 [03:29<14:27,  5.60s/it]
 20%|█▉        | 38/192 [03:34<14:22,  5.60s/it]
 20%|██        | 39/192 [03:40<14:15,  5.59s/it]
 21%|██        | 40/192 [03:46<14:24,  5.69s/it]
 21%|██▏       | 41/192 [03:52<14:14,  5.66s/it]
 22%|██▏       | 42/192 [03:57<14:07,  5.65s/it]
 22%|██▏       | 43/192 [04:03<13:59,  5.63s/it]
 23%|██▎       | 44/192 [04:08<13:53,  5.63s/it]
 23%|██▎       | 45/192 [04:14<13:45,  5.62s/it]
 24%|██▍       | 46/192 [04:20<13:38,  5.61s/it]
 24%|██▍       | 47/192 [04:25<13:35,  5.63s/it]
 25%|██▌       | 48/192 [04:31<13:30,  5.63s/it]
 26%|██▌       | 49/192 [04:37<13:26,  5.64s/it]
 26%|██▌       | 50/192 [04:42<13:19,  5.63s/it]
 27%|██▋       | 51/192 [04:48<13:13,  5.63s/it]
 27%|██▋       | 52/192 [04:53<13:07,  5.62s/it]
 28%|██▊       | 53/192 [04:59<13:11,  5.69s/it]
 28%|██▊       | 54/192 [05:05<13:04,  5.69s/it]
 29%|██▊       | 55/192 [05:11<12:57,  5.67s/it]
 29%|██▉       | 56/192 [05:16<12:50,  5.66s/it]
 30%|██▉       | 57/192 [05:22<12:44,  5.66s/it]
 30%|███       | 58/192 [05:27<12:37,  5.65s/it]
 31%|███       | 59/192 [05:33<12:33,  5.66s/it]
 31%|███▏      | 60/192 [05:39<12:29,  5.68s/it]
 32%|███▏      | 61/192 [05:44<12:22,  5.67s/it]
 32%|███▏      | 62/192 [05:50<12:19,  5.69s/it]
 33%|███▎      | 63/192 [05:56<12:11,  5.67s/it]
 33%|███▎      | 64/192 [06:02<12:15,  5.75s/it]
 34%|███▍      | 65/192 [06:07<12:05,  5.71s/it]
 34%|███▍      | 66/192 [06:13<11:59,  5.71s/it]
 35%|███▍      | 67/192 [06:19<11:51,  5.69s/it]
 35%|███▌      | 68/192 [06:24<11:43,  5.68s/it]
 36%|███▌      | 69/192 [06:30<11:38,  5.68s/it]
 36%|███▋      | 70/192 [06:36<11:32,  5.68s/it]
 37%|███▋      | 71/192 [06:41<11:26,  5.67s/it]
 38%|███▊      | 72/192 [06:47<11:19,  5.66s/it]
 38%|███▊      | 73/192 [06:53<11:14,  5.67s/it]
 39%|███▊      | 74/192 [06:59<11:17,  5.74s/it]
 39%|███▉      | 75/192 [07:04<11:09,  5.72s/it]
 40%|███▉      | 76/192 [07:10<11:03,  5.72s/it]
 40%|████      | 77/192 [07:16<10:56,  5.70s/it]
 41%|████      | 78/192 [07:21<10:49,  5.70s/it]
 41%|████      | 79/192 [07:27<10:44,  5.70s/it]
 42%|████▏     | 80/192 [07:33<10:38,  5.70s/it]
 42%|████▏     | 81/192 [07:39<10:33,  5.71s/it]
 43%|████▎     | 82/192 [07:44<10:26,  5.70s/it]
 43%|████▎     | 83/192 [07:50<10:21,  5.70s/it]
 44%|████▍     | 84/192 [07:56<10:22,  5.77s/it]
 44%|████▍     | 85/192 [08:02<10:26,  5.85s/it]
 45%|████▍     | 86/192 [08:08<10:15,  5.81s/it]
 45%|████▌     | 87/192 [08:13<10:07,  5.78s/it]
 46%|████▌     | 88/192 [08:19<09:59,  5.77s/it]
 46%|████▋     | 89/192 [08:25<09:52,  5.75s/it]
 47%|████▋     | 90/192 [08:30<09:45,  5.74s/it]
 47%|████▋     | 91/192 [08:36<09:40,  5.74s/it]
 48%|████▊     | 92/192 [08:42<09:35,  5.75s/it]
 48%|████▊     | 93/192 [08:48<09:29,  5.75s/it]
 49%|████▉     | 94/192 [08:54<09:24,  5.76s/it]
 49%|████▉     | 95/192 [08:59<09:21,  5.78s/it]
 50%|█████     | 96/192 [09:05<09:17,  5.80s/it]
 51%|█████     | 97/192 [09:11<09:08,  5.77s/it]
 51%|█████     | 98/192 [09:17<09:01,  5.76s/it]
 52%|█████▏    | 99/192 [09:22<08:55,  5.76s/it]
 52%|█████▏    | 100/192 [09:28<08:51,  5.78s/it]
 53%|█████▎    | 101/192 [09:34<08:44,  5.76s/it]
 53%|█████▎    | 102/192 [09:40<08:36,  5.74s/it]
 54%|█████▎    | 103/192 [09:45<08:30,  5.73s/it]
 54%|█████▍    | 104/192 [09:51<08:23,  5.73s/it]
 55%|█████▍    | 105/192 [09:57<08:18,  5.73s/it]
 55%|█████▌    | 106/192 [10:03<08:13,  5.74s/it]
 56%|█████▌    | 107/192 [10:08<08:07,  5.74s/it]
 56%|█████▋    | 108/192 [10:14<08:02,  5.75s/it]
 57%|█████▋    | 109/192 [10:20<08:05,  5.85s/it]
 57%|█████▋    | 110/192 [10:26<07:56,  5.82s/it]
 58%|█████▊    | 111/192 [10:32<07:50,  5.81s/it]
 58%|█████▊    | 112/192 [10:37<07:44,  5.80s/it]
 59%|█████▉    | 113/192 [10:43<07:38,  5.81s/it]
 59%|█████▉    | 114/192 [10:49<07:31,  5.79s/it]
 60%|█████▉    | 115/192 [10:55<07:24,  5.77s/it]
 60%|██████    | 116/192 [11:00<07:16,  5.75s/it]
 61%|██████    | 117/192 [11:06<07:10,  5.74s/it]
 61%|██████▏   | 118/192 [11:12<07:03,  5.73s/it]
 62%|██████▏   | 119/192 [11:18<06:58,  5.73s/it]
 62%|██████▎   | 120/192 [11:23<06:53,  5.74s/it]
 63%|██████▎   | 121/192 [11:29<06:48,  5.75s/it]
 64%|██████▎   | 122/192 [11:35<06:42,  5.76s/it]
 64%|██████▍   | 123/192 [11:41<06:37,  5.76s/it]
 65%|██████▍   | 124/192 [11:46<06:31,  5.76s/it]
 65%|██████▌   | 125/192 [11:52<06:26,  5.77s/it]
 66%|██████▌   | 126/192 [11:58<06:21,  5.77s/it]
 66%|██████▌   | 127/192 [12:04<06:14,  5.76s/it]
 67%|██████▋   | 128/192 [12:10<06:09,  5.78s/it]
 67%|██████▋   | 129/192 [12:16<06:07,  5.84s/it]
 68%|██████▊   | 130/192 [12:21<06:00,  5.82s/it]
 68%|██████▊   | 131/192 [12:27<05:59,  5.90s/it]
 69%|██████▉   | 132/192 [12:33<05:53,  5.89s/it]
 69%|██████▉   | 133/192 [12:39<05:47,  5.89s/it]
 70%|██████▉   | 134/192 [12:45<05:39,  5.85s/it]
 70%|███████   | 135/192 [12:51<05:32,  5.82s/it]
 71%|███████   | 136/192 [12:57<05:25,  5.82s/it]
 71%|███████▏  | 137/192 [13:02<05:20,  5.82s/it]
 72%|███████▏  | 138/192 [13:08<05:13,  5.80s/it]
 72%|███████▏  | 139/192 [13:14<05:07,  5.80s/it]
 73%|███████▎  | 140/192 [13:20<05:01,  5.79s/it]
 73%|███████▎  | 141/192 [13:25<04:55,  5.79s/it]
 74%|███████▍  | 142/192 [13:31<04:49,  5.79s/it]
 74%|███████▍  | 143/192 [13:37<04:44,  5.80s/it]
 75%|███████▌  | 144/192 [13:43<04:38,  5.80s/it]
 76%|███████▌  | 145/192 [13:49<04:32,  5.79s/it]
 76%|███████▌  | 146/192 [13:54<04:26,  5.80s/it]
 77%|███████▋  | 147/192 [14:00<04:21,  5.81s/it]
 77%|███████▋  | 148/192 [14:06<04:17,  5.85s/it]
 78%|███████▊  | 149/192 [14:12<04:10,  5.83s/it]
 78%|███████▊  | 150/192 [14:18<04:04,  5.82s/it]
 79%|███████▊  | 151/192 [14:24<04:01,  5.90s/it]
 79%|███████▉  | 152/192 [14:30<03:59,  5.99s/it]
 80%|███████▉  | 153/192 [14:36<03:51,  5.94s/it]
 80%|████████  | 154/192 [14:42<03:45,  5.94s/it]
 81%|████████  | 155/192 [14:48<03:39,  5.93s/it]
 81%|████████▏ | 156/192 [14:54<03:32,  5.90s/it]
 82%|████████▏ | 157/192 [14:59<03:26,  5.89s/it]
 82%|████████▏ | 158/192 [15:05<03:20,  5.89s/it]
 83%|████████▎ | 159/192 [15:11<03:13,  5.87s/it]
 83%|████████▎ | 160/192 [15:17<03:07,  5.87s/it]
 84%|████████▍ | 161/192 [15:23<03:01,  5.87s/it]
 84%|████████▍ | 162/192 [15:29<02:55,  5.87s/it]
 85%|████████▍ | 163/192 [15:35<02:49,  5.86s/it]
 85%|████████▌ | 164/192 [15:40<02:43,  5.85s/it]
 86%|████████▌ | 165/192 [15:46<02:38,  5.88s/it]
 86%|████████▋ | 166/192 [15:52<02:32,  5.87s/it]
 87%|████████▋ | 167/192 [15:58<02:26,  5.87s/it]
 88%|████████▊ | 168/192 [16:04<02:21,  5.88s/it]
 88%|████████▊ | 169/192 [16:10<02:15,  5.88s/it]
 89%|████████▊ | 170/192 [16:16<02:09,  5.89s/it]
 89%|████████▉ | 171/192 [16:22<02:04,  5.91s/it]
 90%|████████▉ | 172/192 [16:28<01:57,  5.90s/it]
 90%|█████████ | 173/192 [16:34<01:54,  6.02s/it]
 91%|█████████ | 174/192 [16:40<01:47,  5.99s/it]
 91%|█████████ | 175/192 [16:46<01:41,  5.96s/it]
 92%|█████████▏| 176/192 [16:52<01:35,  5.95s/it]
 92%|█████████▏| 177/192 [16:58<01:30,  6.01s/it]
 93%|█████████▎| 178/192 [17:04<01:23,  5.99s/it]
 93%|█████████▎| 179/192 [17:10<01:17,  5.99s/it]
 94%|█████████▍| 180/192 [17:16<01:11,  5.98s/it]
 94%|█████████▍| 181/192 [17:22<01:05,  5.95s/it]
 95%|█████████▍| 182/192 [17:28<00:59,  5.94s/it]
 95%|█████████▌| 183/192 [17:33<00:53,  5.94s/it]
 96%|█████████▌| 184/192 [17:39<00:47,  5.93s/it]
 96%|█████████▋| 185/192 [17:45<00:41,  5.92s/it]
 97%|█████████▋| 186/192 [17:51<00:35,  5.93s/it]
 97%|█████████▋| 187/192 [17:57<00:29,  5.94s/it]
 98%|█████████▊| 188/192 [18:03<00:23,  5.94s/it]
 98%|█████████▊| 189/192 [18:09<00:17,  5.93s/it]
 99%|█████████▉| 190/192 [18:15<00:11,  5.92s/it]
 99%|█████████▉| 191/192 [18:21<00:05,  5.92s/it]
100%|██████████| 192/192 [18:27<00:00,  5.92s/it]
[MoviePy] Done.
[MoviePy] >>>> Video ready: videos_out/cars_ppl_out.mp4 

CPU times: user 1h 22min 33s, sys: 1min 45s, total: 1h 24min 19s
Wall time: 18min 27s

In [21]:
filename = 'videos_in/cars_ppl2.mp4'
new_loc = 'videos_out/cars_ppl2_out.mp4'

counter = 0

white_output = new_loc
clip1 = VideoFileClip(filename).subclip(64,72)
white_clip = clip1.fl_image(process_image) #NOTE: this function expects color images!!s
%time white_clip.write_videofile(white_output, audio=False)
[MoviePy] >>>> Building video videos_out/cars_ppl2_out.mp4
[MoviePy] Writing video videos_out/cars_ppl2_out.mp4
  0%|          | 0/240 [00:00<?, ?it/s]
  0%|          | 1/240 [00:05<23:45,  5.97s/it]
  1%|          | 2/240 [00:12<24:10,  6.09s/it]
  1%|▏         | 3/240 [00:18<23:52,  6.04s/it]
  2%|▏         | 4/240 [00:24<23:37,  6.01s/it]
  2%|▏         | 5/240 [00:30<23:24,  5.98s/it]
  2%|▎         | 6/240 [00:36<23:16,  5.97s/it]
  3%|▎         | 7/240 [00:41<23:08,  5.96s/it]
  3%|▎         | 8/240 [00:47<22:58,  5.94s/it]
  4%|▍         | 9/240 [00:53<22:59,  5.97s/it]
  4%|▍         | 10/240 [00:59<22:49,  5.95s/it]
  5%|▍         | 11/240 [01:05<22:43,  5.95s/it]
  5%|▌         | 12/240 [01:11<22:38,  5.96s/it]
  5%|▌         | 13/240 [01:17<22:32,  5.96s/it]
  6%|▌         | 14/240 [01:23<22:30,  5.98s/it]
  6%|▋         | 15/240 [01:29<22:28,  5.99s/it]
  7%|▋         | 16/240 [01:35<22:22,  5.99s/it]
  7%|▋         | 17/240 [01:41<22:13,  5.98s/it]
  8%|▊         | 18/240 [01:47<22:06,  5.97s/it]
  8%|▊         | 19/240 [01:53<21:59,  5.97s/it]
  8%|▊         | 20/240 [01:59<21:57,  5.99s/it]
  9%|▉         | 21/240 [02:05<21:52,  5.99s/it]
  9%|▉         | 22/240 [02:11<21:45,  5.99s/it]
 10%|▉         | 23/240 [02:18<22:08,  6.12s/it]
 10%|█         | 24/240 [02:24<21:59,  6.11s/it]
 10%|█         | 25/240 [02:30<21:46,  6.08s/it]
 11%|█         | 26/240 [02:36<21:36,  6.06s/it]
 11%|█▏        | 27/240 [02:42<21:27,  6.05s/it]
 12%|█▏        | 28/240 [02:48<21:19,  6.04s/it]
 12%|█▏        | 29/240 [02:54<21:13,  6.03s/it]
 12%|█▎        | 30/240 [03:00<21:04,  6.02s/it]
 13%|█▎        | 31/240 [03:06<20:56,  6.01s/it]
 13%|█▎        | 32/240 [03:12<21:06,  6.09s/it]
 14%|█▍        | 33/240 [03:18<20:54,  6.06s/it]
 14%|█▍        | 34/240 [03:24<20:48,  6.06s/it]
 15%|█▍        | 35/240 [03:30<20:38,  6.04s/it]
 15%|█▌        | 36/240 [03:36<20:29,  6.03s/it]
 15%|█▌        | 37/240 [03:42<20:21,  6.02s/it]
 16%|█▌        | 38/240 [03:48<20:13,  6.01s/it]
 16%|█▋        | 39/240 [03:54<20:10,  6.02s/it]
 17%|█▋        | 40/240 [04:00<20:07,  6.04s/it]
 17%|█▋        | 41/240 [04:06<20:03,  6.05s/it]
 18%|█▊        | 42/240 [04:12<19:56,  6.04s/it]
 18%|█▊        | 43/240 [04:18<19:49,  6.04s/it]
 18%|█▊        | 44/240 [04:24<19:44,  6.04s/it]
 19%|█▉        | 45/240 [04:31<20:02,  6.16s/it]
 19%|█▉        | 46/240 [04:37<19:48,  6.13s/it]
 20%|█▉        | 47/240 [04:43<19:39,  6.11s/it]
 20%|██        | 48/240 [04:49<19:29,  6.09s/it]
 20%|██        | 49/240 [04:55<19:22,  6.09s/it]
 21%|██        | 50/240 [05:01<19:18,  6.10s/it]
 21%|██▏       | 51/240 [05:07<19:13,  6.10s/it]
 22%|██▏       | 52/240 [05:13<19:06,  6.10s/it]
 22%|██▏       | 53/240 [05:19<18:57,  6.08s/it]
 22%|██▎       | 54/240 [05:26<19:00,  6.13s/it]
 23%|██▎       | 55/240 [05:32<18:49,  6.10s/it]
 23%|██▎       | 56/240 [05:38<18:42,  6.10s/it]
 24%|██▍       | 57/240 [05:44<18:37,  6.11s/it]
 24%|██▍       | 58/240 [05:50<18:30,  6.10s/it]
 25%|██▍       | 59/240 [05:56<18:26,  6.12s/it]
 25%|██▌       | 60/240 [06:02<18:21,  6.12s/it]
 25%|██▌       | 61/240 [06:08<18:17,  6.13s/it]
 26%|██▌       | 62/240 [06:15<18:09,  6.12s/it]
 26%|██▋       | 63/240 [06:21<18:00,  6.11s/it]
 27%|██▋       | 64/240 [06:27<17:53,  6.10s/it]
 27%|██▋       | 65/240 [06:33<17:47,  6.10s/it]
 28%|██▊       | 66/240 [06:39<18:04,  6.23s/it]
 28%|██▊       | 67/240 [06:45<17:53,  6.20s/it]
 28%|██▊       | 68/240 [06:52<17:41,  6.17s/it]
 29%|██▉       | 69/240 [06:58<17:32,  6.15s/it]
 29%|██▉       | 70/240 [07:04<17:20,  6.12s/it]
 30%|██▉       | 71/240 [07:10<17:15,  6.13s/it]
 30%|███       | 72/240 [07:16<17:06,  6.11s/it]
 30%|███       | 73/240 [07:22<16:58,  6.10s/it]
 31%|███       | 74/240 [07:28<16:51,  6.10s/it]
 31%|███▏      | 75/240 [07:34<16:45,  6.09s/it]
 32%|███▏      | 76/240 [07:40<16:40,  6.10s/it]
 32%|███▏      | 77/240 [07:46<16:34,  6.10s/it]
 32%|███▎      | 78/240 [07:52<16:28,  6.10s/it]
 33%|███▎      | 79/240 [07:59<16:25,  6.12s/it]
 33%|███▎      | 80/240 [08:05<16:22,  6.14s/it]
 34%|███▍      | 81/240 [08:11<16:16,  6.14s/it]
 34%|███▍      | 82/240 [08:17<16:10,  6.14s/it]
 35%|███▍      | 83/240 [08:23<16:04,  6.15s/it]
 35%|███▌      | 84/240 [08:29<15:57,  6.14s/it]
 35%|███▌      | 85/240 [08:36<15:50,  6.13s/it]
 36%|███▌      | 86/240 [08:42<15:44,  6.13s/it]
 36%|███▋      | 87/240 [08:48<15:38,  6.13s/it]
 37%|███▋      | 88/240 [08:54<15:52,  6.27s/it]
 37%|███▋      | 89/240 [09:00<15:40,  6.23s/it]
 38%|███▊      | 90/240 [09:07<15:30,  6.21s/it]
 38%|███▊      | 91/240 [09:13<15:22,  6.19s/it]
 38%|███▊      | 92/240 [09:19<15:14,  6.18s/it]
 39%|███▉      | 93/240 [09:25<15:07,  6.17s/it]
 39%|███▉      | 94/240 [09:31<15:00,  6.17s/it]
 40%|███▉      | 95/240 [09:37<14:53,  6.16s/it]
 40%|████      | 96/240 [09:44<14:47,  6.16s/it]
 40%|████      | 97/240 [09:50<14:41,  6.16s/it]
 41%|████      | 98/240 [09:56<14:37,  6.18s/it]
 41%|████▏     | 99/240 [10:02<14:33,  6.20s/it]
 42%|████▏     | 100/240 [10:08<14:27,  6.19s/it]
 42%|████▏     | 101/240 [10:15<14:19,  6.18s/it]
 42%|████▎     | 102/240 [10:21<14:12,  6.18s/it]
 43%|████▎     | 103/240 [10:27<14:07,  6.19s/it]
 43%|████▎     | 104/240 [10:33<14:01,  6.18s/it]
 44%|████▍     | 105/240 [10:39<13:54,  6.18s/it]
 44%|████▍     | 106/240 [10:45<13:48,  6.19s/it]
 45%|████▍     | 107/240 [10:52<13:42,  6.18s/it]
 45%|████▌     | 108/240 [10:58<13:36,  6.19s/it]
 45%|████▌     | 109/240 [11:04<13:30,  6.19s/it]
 46%|████▌     | 110/240 [11:11<13:44,  6.34s/it]
 46%|████▋     | 111/240 [11:17<13:33,  6.31s/it]
 47%|████▋     | 112/240 [11:23<13:23,  6.28s/it]
 47%|████▋     | 113/240 [11:29<13:14,  6.26s/it]
 48%|████▊     | 114/240 [11:36<13:07,  6.25s/it]
 48%|████▊     | 115/240 [11:42<13:01,  6.25s/it]
 48%|████▊     | 116/240 [11:48<12:54,  6.25s/it]
 49%|████▉     | 117/240 [11:54<12:48,  6.25s/it]
 49%|████▉     | 118/240 [12:01<12:43,  6.25s/it]
 50%|████▉     | 119/240 [12:07<12:37,  6.26s/it]
 50%|█████     | 120/240 [12:13<12:31,  6.27s/it]
 50%|█████     | 121/240 [12:19<12:23,  6.25s/it]
 51%|█████     | 122/240 [12:26<12:16,  6.24s/it]
 51%|█████▏    | 123/240 [12:32<12:09,  6.23s/it]
 52%|█████▏    | 124/240 [12:38<12:02,  6.23s/it]
 52%|█████▏    | 125/240 [12:44<11:56,  6.23s/it]
 52%|█████▎    | 126/240 [12:51<11:51,  6.24s/it]
 53%|█████▎    | 127/240 [12:57<11:43,  6.23s/it]
 53%|█████▎    | 128/240 [13:03<11:38,  6.23s/it]
 54%|█████▍    | 129/240 [13:09<11:33,  6.24s/it]
 54%|█████▍    | 130/240 [13:16<11:42,  6.39s/it]
 55%|█████▍    | 131/240 [13:22<11:32,  6.36s/it]
 55%|█████▌    | 132/240 [13:29<11:23,  6.33s/it]
 55%|█████▌    | 133/240 [13:35<11:15,  6.31s/it]
 56%|█████▌    | 134/240 [13:41<11:07,  6.30s/it]
 56%|█████▋    | 135/240 [13:47<11:00,  6.29s/it]
 57%|█████▋    | 136/240 [13:54<10:53,  6.28s/it]
 57%|█████▋    | 137/240 [14:00<10:48,  6.30s/it]
 57%|█████▊    | 138/240 [14:06<10:43,  6.31s/it]
 58%|█████▊    | 139/240 [14:13<10:35,  6.30s/it]
 58%|█████▊    | 140/240 [14:19<10:30,  6.30s/it]
 59%|█████▉    | 141/240 [14:25<10:23,  6.30s/it]
 59%|█████▉    | 142/240 [14:31<10:17,  6.30s/it]
 60%|█████▉    | 143/240 [14:38<10:10,  6.30s/it]
 60%|██████    | 144/240 [14:44<10:04,  6.29s/it]
 60%|██████    | 145/240 [14:50<09:58,  6.30s/it]
 61%|██████    | 146/240 [14:57<09:51,  6.29s/it]
 61%|██████▏   | 147/240 [15:03<09:45,  6.29s/it]
 62%|██████▏   | 148/240 [15:09<09:38,  6.29s/it]
 62%|██████▏   | 149/240 [15:15<09:32,  6.29s/it]
 62%|██████▎   | 150/240 [15:22<09:27,  6.31s/it]
 63%|██████▎   | 151/240 [15:29<09:33,  6.44s/it]
 63%|██████▎   | 152/240 [15:35<09:23,  6.40s/it]
 64%|██████▍   | 153/240 [15:41<09:14,  6.37s/it]
 64%|██████▍   | 154/240 [15:48<09:07,  6.37s/it]
 65%|██████▍   | 155/240 [15:54<09:01,  6.37s/it]
 65%|██████▌   | 156/240 [16:00<08:54,  6.36s/it]
 65%|██████▌   | 157/240 [16:07<08:48,  6.36s/it]
 66%|██████▌   | 158/240 [16:13<08:40,  6.35s/it]
 66%|██████▋   | 159/240 [16:19<08:33,  6.34s/it]
 67%|██████▋   | 160/240 [16:26<08:26,  6.33s/it]
 67%|██████▋   | 161/240 [16:32<08:21,  6.34s/it]
 68%|██████▊   | 162/240 [16:38<08:14,  6.34s/it]
 68%|██████▊   | 163/240 [16:45<08:08,  6.35s/it]
 68%|██████▊   | 164/240 [16:51<08:02,  6.35s/it]
 69%|██████▉   | 165/240 [16:57<07:56,  6.35s/it]
 69%|██████▉   | 166/240 [17:04<07:50,  6.35s/it]
 70%|██████▉   | 167/240 [17:10<07:44,  6.36s/it]
 70%|███████   | 168/240 [17:16<07:38,  6.37s/it]
 70%|███████   | 169/240 [17:23<07:31,  6.36s/it]
 71%|███████   | 170/240 [17:29<07:24,  6.35s/it]
 71%|███████▏  | 171/240 [17:36<07:28,  6.50s/it]
 72%|███████▏  | 172/240 [17:42<07:19,  6.47s/it]
 72%|███████▏  | 173/240 [17:49<07:11,  6.44s/it]
 72%|███████▎  | 174/240 [17:55<07:04,  6.43s/it]
 73%|███████▎  | 175/240 [18:02<06:58,  6.43s/it]
 73%|███████▎  | 176/240 [18:08<06:50,  6.42s/it]
 74%|███████▍  | 177/240 [18:14<06:43,  6.40s/it]
 74%|███████▍  | 178/240 [18:21<06:36,  6.40s/it]
 75%|███████▍  | 179/240 [18:27<06:34,  6.46s/it]
 75%|███████▌  | 180/240 [18:34<06:26,  6.44s/it]
 75%|███████▌  | 181/240 [18:40<06:19,  6.42s/it]
 76%|███████▌  | 182/240 [18:47<06:11,  6.41s/it]
 76%|███████▋  | 183/240 [18:53<06:04,  6.40s/it]
 77%|███████▋  | 184/240 [18:59<05:58,  6.40s/it]
 77%|███████▋  | 185/240 [19:06<05:51,  6.40s/it]
 78%|███████▊  | 186/240 [19:12<05:45,  6.40s/it]
 78%|███████▊  | 187/240 [19:19<05:39,  6.40s/it]
 78%|███████▊  | 188/240 [19:25<05:33,  6.40s/it]
 79%|███████▉  | 189/240 [19:31<05:26,  6.41s/it]
 79%|███████▉  | 190/240 [19:38<05:20,  6.41s/it]
 80%|███████▉  | 191/240 [19:44<05:14,  6.42s/it]
 80%|████████  | 192/240 [19:51<05:15,  6.57s/it]
 80%|████████  | 193/240 [19:58<05:07,  6.53s/it]
 81%|████████  | 194/240 [20:04<05:00,  6.53s/it]
 81%|████████▏ | 195/240 [20:11<04:52,  6.51s/it]
 82%|████████▏ | 196/240 [20:17<04:45,  6.48s/it]
 82%|████████▏ | 197/240 [20:23<04:37,  6.46s/it]
 82%|████████▎ | 198/240 [20:30<04:30,  6.45s/it]
 83%|████████▎ | 199/240 [20:36<04:24,  6.46s/it]
 83%|████████▎ | 200/240 [20:43<04:18,  6.46s/it]
 84%|████████▍ | 201/240 [20:49<04:11,  6.46s/it]
 84%|████████▍ | 202/240 [20:56<04:05,  6.46s/it]
 85%|████████▍ | 203/240 [21:02<03:59,  6.47s/it]
 85%|████████▌ | 204/240 [21:09<03:52,  6.46s/it]
 85%|████████▌ | 205/240 [21:15<03:45,  6.46s/it]
 86%|████████▌ | 206/240 [21:21<03:39,  6.46s/it]
 86%|████████▋ | 207/240 [21:28<03:33,  6.48s/it]
 87%|████████▋ | 208/240 [21:34<03:26,  6.47s/it]
 87%|████████▋ | 209/240 [21:41<03:20,  6.47s/it]
 88%|████████▊ | 210/240 [21:47<03:14,  6.50s/it]
 88%|████████▊ | 211/240 [21:54<03:08,  6.50s/it]
 88%|████████▊ | 212/240 [22:01<03:06,  6.67s/it]
 89%|████████▉ | 213/240 [22:08<02:58,  6.62s/it]
 89%|████████▉ | 214/240 [22:14<02:51,  6.58s/it]
 90%|████████▉ | 215/240 [22:21<02:43,  6.54s/it]
 90%|█████████ | 216/240 [22:27<02:36,  6.53s/it]
 90%|█████████ | 217/240 [22:33<02:29,  6.51s/it]
 91%|█████████ | 218/240 [22:40<02:23,  6.50s/it]
 91%|█████████▏| 219/240 [22:46<02:16,  6.50s/it]
 92%|█████████▏| 220/240 [22:53<02:09,  6.49s/it]
 92%|█████████▏| 221/240 [22:59<02:03,  6.49s/it]
 92%|█████████▎| 222/240 [23:06<01:56,  6.50s/it]
 93%|█████████▎| 223/240 [23:13<01:51,  6.53s/it]
 93%|█████████▎| 224/240 [23:19<01:44,  6.54s/it]
 94%|█████████▍| 225/240 [23:26<01:37,  6.53s/it]
 94%|█████████▍| 226/240 [23:32<01:31,  6.52s/it]
 95%|█████████▍| 227/240 [23:39<01:24,  6.52s/it]
 95%|█████████▌| 228/240 [23:45<01:18,  6.51s/it]
 95%|█████████▌| 229/240 [23:52<01:11,  6.51s/it]
 96%|█████████▌| 230/240 [23:58<01:05,  6.53s/it]
 96%|█████████▋| 231/240 [24:05<00:59,  6.57s/it]
 97%|█████████▋| 232/240 [24:12<00:53,  6.71s/it]
 97%|█████████▋| 233/240 [24:18<00:46,  6.65s/it]
 98%|█████████▊| 234/240 [24:25<00:39,  6.61s/it]
 98%|█████████▊| 235/240 [24:31<00:33,  6.60s/it]
 98%|█████████▊| 236/240 [24:38<00:26,  6.59s/it]
 99%|█████████▉| 237/240 [24:45<00:19,  6.60s/it]
 99%|█████████▉| 238/240 [24:51<00:13,  6.59s/it]
100%|█████████▉| 239/240 [24:58<00:06,  6.59s/it]
100%|██████████| 240/240 [25:04<00:00,  6.58s/it]
[MoviePy] Done.
[MoviePy] >>>> Video ready: videos_out/cars_ppl2_out.mp4 

CPU times: user 1h 45min 15s, sys: 2min 17s, total: 1h 47min 32s
Wall time: 25min 5s

In [22]:
filename = 'videos_in/kid_soccer.mp4'
new_loc = 'videos_out/kid_soccer_out.mp4'

counter = 0

white_output = new_loc
clip1 = VideoFileClip(filename).subclip(18,23)
white_clip = clip1.fl_image(process_image) #NOTE: this function expects color images!!s
%time white_clip.write_videofile(white_output, audio=False)
[MoviePy] >>>> Building video videos_out/kid_soccer_out.mp4
[MoviePy] Writing video videos_out/kid_soccer_out.mp4
  0%|          | 0/150 [00:00<?, ?it/s]
  1%|          | 1/150 [00:06<16:18,  6.57s/it]
  1%|▏         | 2/150 [00:13<16:11,  6.56s/it]
  2%|▏         | 3/150 [00:19<16:03,  6.55s/it]
  3%|▎         | 4/150 [00:26<15:56,  6.55s/it]
  3%|▎         | 5/150 [00:32<15:49,  6.55s/it]
  4%|▍         | 6/150 [00:39<15:42,  6.55s/it]
  5%|▍         | 7/150 [00:45<15:38,  6.56s/it]
  5%|▌         | 8/150 [00:52<15:32,  6.56s/it]
  6%|▌         | 9/150 [00:58<15:25,  6.56s/it]
  7%|▋         | 10/150 [01:05<15:19,  6.57s/it]
  7%|▋         | 11/150 [01:12<15:12,  6.57s/it]
  8%|▊         | 12/150 [01:19<15:30,  6.74s/it]
  9%|▊         | 13/150 [01:25<15:17,  6.70s/it]
  9%|▉         | 14/150 [01:32<15:07,  6.67s/it]
 10%|█         | 15/150 [01:39<14:57,  6.65s/it]
 11%|█         | 16/150 [01:45<14:48,  6.63s/it]
 11%|█▏        | 17/150 [01:52<14:40,  6.62s/it]
 12%|█▏        | 18/150 [01:58<14:34,  6.63s/it]
 13%|█▎        | 19/150 [02:05<14:26,  6.62s/it]
 13%|█▎        | 20/150 [02:12<14:17,  6.60s/it]
 14%|█▍        | 21/150 [02:18<14:09,  6.58s/it]
 15%|█▍        | 22/150 [02:25<14:02,  6.58s/it]
 15%|█▌        | 23/150 [02:31<13:54,  6.57s/it]
 16%|█▌        | 24/150 [02:38<13:48,  6.58s/it]
 17%|█▋        | 25/150 [02:44<13:43,  6.59s/it]
 17%|█▋        | 26/150 [02:51<13:38,  6.60s/it]
 18%|█▊        | 27/150 [02:58<13:32,  6.60s/it]
 19%|█▊        | 28/150 [03:04<13:25,  6.60s/it]
 19%|█▉        | 29/150 [03:11<13:19,  6.61s/it]
 20%|██        | 30/150 [03:18<13:13,  6.61s/it]
 21%|██        | 31/150 [03:24<13:13,  6.67s/it]
 21%|██▏       | 32/150 [03:31<13:05,  6.66s/it]
 22%|██▏       | 33/150 [03:38<13:16,  6.81s/it]
 23%|██▎       | 34/150 [03:45<13:03,  6.75s/it]
 23%|██▎       | 35/150 [03:51<12:51,  6.71s/it]
 24%|██▍       | 36/150 [03:58<12:42,  6.69s/it]
 25%|██▍       | 37/150 [04:05<12:33,  6.67s/it]
 25%|██▌       | 38/150 [04:11<12:24,  6.65s/it]
 26%|██▌       | 39/150 [04:18<12:16,  6.63s/it]
 27%|██▋       | 40/150 [04:25<12:11,  6.65s/it]
 27%|██▋       | 41/150 [04:31<12:05,  6.65s/it]
 28%|██▊       | 42/150 [04:38<11:57,  6.64s/it]
 29%|██▊       | 43/150 [04:44<11:50,  6.64s/it]
 29%|██▉       | 44/150 [04:51<11:44,  6.65s/it]
 30%|███       | 45/150 [04:58<11:37,  6.64s/it]
 31%|███       | 46/150 [05:04<11:31,  6.65s/it]
 31%|███▏      | 47/150 [05:11<11:24,  6.65s/it]
 32%|███▏      | 48/150 [05:18<11:18,  6.65s/it]
 33%|███▎      | 49/150 [05:24<11:11,  6.65s/it]
 33%|███▎      | 50/150 [05:31<11:04,  6.64s/it]
 34%|███▍      | 51/150 [05:38<10:58,  6.65s/it]
 35%|███▍      | 52/150 [05:44<10:52,  6.66s/it]
 35%|███▌      | 53/150 [05:52<11:02,  6.83s/it]
 36%|███▌      | 54/150 [05:58<10:49,  6.76s/it]
 37%|███▋      | 55/150 [06:05<10:39,  6.73s/it]
 37%|███▋      | 56/150 [06:11<10:28,  6.69s/it]
 38%|███▊      | 57/150 [06:18<10:21,  6.68s/it]
 39%|███▊      | 58/150 [06:25<10:13,  6.67s/it]
 39%|███▉      | 59/150 [06:31<10:06,  6.66s/it]
 40%|████      | 60/150 [06:38<09:58,  6.65s/it]
 41%|████      | 61/150 [06:45<09:52,  6.65s/it]
 41%|████▏     | 62/150 [06:51<09:45,  6.65s/it]
 42%|████▏     | 63/150 [06:58<09:39,  6.66s/it]
 43%|████▎     | 64/150 [07:05<09:34,  6.68s/it]
 43%|████▎     | 65/150 [07:11<09:26,  6.67s/it]
 44%|████▍     | 66/150 [07:18<09:21,  6.68s/it]
 45%|████▍     | 67/150 [07:25<09:13,  6.67s/it]
 45%|████▌     | 68/150 [07:31<09:06,  6.67s/it]
 46%|████▌     | 69/150 [07:38<09:00,  6.68s/it]
 47%|████▋     | 70/150 [07:45<08:53,  6.67s/it]
 47%|████▋     | 71/150 [07:51<08:47,  6.67s/it]
 48%|████▊     | 72/150 [07:58<08:40,  6.67s/it]
 49%|████▊     | 73/150 [08:05<08:32,  6.66s/it]
 49%|████▉     | 74/150 [08:12<08:39,  6.84s/it]
 50%|█████     | 75/150 [08:19<08:27,  6.77s/it]
 51%|█████     | 76/150 [08:25<08:18,  6.74s/it]
 51%|█████▏    | 77/150 [08:32<08:10,  6.72s/it]
 52%|█████▏    | 78/150 [08:39<08:03,  6.72s/it]
 53%|█████▎    | 79/150 [08:45<07:56,  6.71s/it]
 53%|█████▎    | 80/150 [08:52<07:51,  6.73s/it]
 54%|█████▍    | 81/150 [08:59<07:44,  6.73s/it]
 55%|█████▍    | 82/150 [09:06<07:37,  6.73s/it]
 55%|█████▌    | 83/150 [09:12<07:30,  6.73s/it]
 56%|█████▌    | 84/150 [09:19<07:22,  6.71s/it]
 57%|█████▋    | 85/150 [09:26<07:15,  6.70s/it]
 57%|█████▋    | 86/150 [09:32<07:09,  6.71s/it]
 58%|█████▊    | 87/150 [09:39<07:01,  6.70s/it]
 59%|█████▊    | 88/150 [09:46<06:56,  6.71s/it]
 59%|█████▉    | 89/150 [09:52<06:48,  6.70s/it]
 60%|██████    | 90/150 [09:59<06:41,  6.70s/it]
 61%|██████    | 91/150 [10:06<06:35,  6.70s/it]
 61%|██████▏   | 92/150 [10:13<06:28,  6.70s/it]
 62%|██████▏   | 93/150 [10:19<06:22,  6.72s/it]
 63%|██████▎   | 94/150 [10:27<06:25,  6.89s/it]
 63%|██████▎   | 95/150 [10:33<06:15,  6.83s/it]
 64%|██████▍   | 96/150 [10:40<06:06,  6.79s/it]
 65%|██████▍   | 97/150 [10:47<05:59,  6.78s/it]
 65%|██████▌   | 98/150 [10:53<05:52,  6.78s/it]
 66%|██████▌   | 99/150 [11:00<05:44,  6.76s/it]
 67%|██████▋   | 100/150 [11:07<05:37,  6.75s/it]
 67%|██████▋   | 101/150 [11:14<05:30,  6.75s/it]
 68%|██████▊   | 102/150 [11:20<05:23,  6.75s/it]
 69%|██████▊   | 103/150 [11:27<05:17,  6.75s/it]
 69%|██████▉   | 104/150 [11:34<05:10,  6.75s/it]
 70%|███████   | 105/150 [11:41<05:03,  6.75s/it]
 71%|███████   | 106/150 [11:47<04:57,  6.76s/it]
 71%|███████▏  | 107/150 [11:54<04:50,  6.75s/it]
 72%|███████▏  | 108/150 [12:01<04:43,  6.76s/it]
 73%|███████▎  | 109/150 [12:08<04:37,  6.76s/it]
 73%|███████▎  | 110/150 [12:14<04:30,  6.76s/it]
 74%|███████▍  | 111/150 [12:21<04:23,  6.76s/it]
 75%|███████▍  | 112/150 [12:28<04:16,  6.76s/it]
 75%|███████▌  | 113/150 [12:35<04:10,  6.76s/it]
 76%|███████▌  | 114/150 [12:42<04:03,  6.76s/it]
 77%|███████▋  | 115/150 [12:49<04:03,  6.95s/it]
 77%|███████▋  | 116/150 [12:56<03:54,  6.91s/it]
 78%|███████▊  | 117/150 [13:02<03:46,  6.86s/it]
 79%|███████▊  | 118/150 [13:09<03:38,  6.83s/it]
 79%|███████▉  | 119/150 [13:16<03:31,  6.82s/it]
 80%|████████  | 120/150 [13:23<03:24,  6.80s/it]
 81%|████████  | 121/150 [13:30<03:17,  6.80s/it]
 81%|████████▏ | 122/150 [13:36<03:10,  6.79s/it]
 82%|████████▏ | 123/150 [13:43<03:03,  6.79s/it]
 83%|████████▎ | 124/150 [13:50<02:56,  6.79s/it]
 83%|████████▎ | 125/150 [13:57<02:49,  6.79s/it]
 84%|████████▍ | 126/150 [14:04<02:43,  6.79s/it]
 85%|████████▍ | 127/150 [14:10<02:36,  6.79s/it]
 85%|████████▌ | 128/150 [14:17<02:29,  6.79s/it]
 86%|████████▌ | 129/150 [14:24<02:22,  6.80s/it]
 87%|████████▋ | 130/150 [14:31<02:16,  6.80s/it]
 87%|████████▋ | 131/150 [14:38<02:09,  6.80s/it]
 88%|████████▊ | 132/150 [14:44<02:02,  6.81s/it]
 89%|████████▊ | 133/150 [14:51<01:56,  6.84s/it]
 89%|████████▉ | 134/150 [14:59<01:52,  7.02s/it]
 90%|█████████ | 135/150 [15:05<01:44,  6.95s/it]
 91%|█████████ | 136/150 [15:12<01:36,  6.91s/it]
 91%|█████████▏| 137/150 [15:19<01:29,  6.88s/it]
 92%|█████████▏| 138/150 [15:26<01:22,  6.87s/it]
 93%|█████████▎| 139/150 [15:33<01:15,  6.87s/it]
 93%|█████████▎| 140/150 [15:40<01:08,  6.86s/it]
 94%|█████████▍| 141/150 [15:47<01:01,  6.85s/it]
 95%|█████████▍| 142/150 [15:53<00:54,  6.85s/it]
 95%|█████████▌| 143/150 [16:00<00:47,  6.85s/it]
 96%|█████████▌| 144/150 [16:07<00:41,  6.85s/it]
 97%|█████████▋| 145/150 [16:14<00:34,  6.84s/it]
 97%|█████████▋| 146/150 [16:21<00:27,  6.84s/it]
 98%|█████████▊| 147/150 [16:28<00:20,  6.84s/it]
 99%|█████████▊| 148/150 [16:34<00:13,  6.85s/it]
 99%|█████████▉| 149/150 [16:41<00:06,  6.90s/it]
100%|██████████| 150/150 [16:48<00:00,  6.88s/it]
[MoviePy] Done.
[MoviePy] >>>> Video ready: videos_out/kid_soccer_out.mp4 

CPU times: user 1h 6min 56s, sys: 1min 24s, total: 1h 8min 21s
Wall time: 16min 48s

In [23]:
filename = 'videos_in/cat_dog.mp4'
new_loc = 'videos_out/cat_dog_out.mp4'

counter = 0

white_output = new_loc
clip1 = VideoFileClip(filename).subclip(120,125)
white_clip = clip1.fl_image(process_image) #NOTE: this function expects color images!!s
%time white_clip.write_videofile(white_output, audio=False)
[MoviePy] >>>> Building video videos_out/cat_dog_out.mp4
[MoviePy] Writing video videos_out/cat_dog_out.mp4
  0%|          | 0/151 [00:00<?, ?it/s]
  1%|          | 1/151 [00:07<17:38,  7.05s/it]
  1%|▏         | 2/151 [00:14<17:27,  7.03s/it]
  2%|▏         | 3/151 [00:21<17:38,  7.15s/it]
  3%|▎         | 4/151 [00:29<18:31,  7.56s/it]
  3%|▎         | 5/151 [00:37<18:32,  7.62s/it]
  4%|▍         | 6/151 [00:45<18:28,  7.65s/it]
  5%|▍         | 7/151 [00:52<18:04,  7.53s/it]
  5%|▌         | 8/151 [00:59<17:33,  7.37s/it]
  6%|▌         | 9/151 [01:06<17:13,  7.28s/it]
  7%|▋         | 10/151 [01:14<17:13,  7.33s/it]
  7%|▋         | 11/151 [01:22<17:33,  7.53s/it]
  8%|▊         | 12/151 [01:30<17:38,  7.61s/it]
  9%|▊         | 13/151 [01:37<17:31,  7.62s/it]
  9%|▉         | 14/151 [01:45<17:20,  7.59s/it]
 10%|▉         | 15/151 [01:52<17:02,  7.52s/it]
 11%|█         | 16/151 [01:59<16:44,  7.44s/it]
 11%|█▏        | 17/151 [02:07<16:32,  7.41s/it]
 12%|█▏        | 18/151 [02:14<16:16,  7.34s/it]
 13%|█▎        | 19/151 [02:21<16:00,  7.28s/it]
 13%|█▎        | 20/151 [02:28<15:42,  7.19s/it]
 14%|█▍        | 21/151 [02:35<15:28,  7.14s/it]
 15%|█▍        | 22/151 [02:42<15:21,  7.14s/it]
 15%|█▌        | 23/151 [02:49<15:16,  7.16s/it]
 16%|█▌        | 24/151 [02:57<15:37,  7.38s/it]
 17%|█▋        | 25/151 [03:05<15:27,  7.36s/it]
 17%|█▋        | 26/151 [03:12<15:14,  7.32s/it]
 18%|█▊        | 27/151 [03:19<15:12,  7.36s/it]
 19%|█▊        | 28/151 [03:27<15:24,  7.52s/it]
 19%|█▉        | 29/151 [03:35<15:38,  7.69s/it]
 20%|█▉        | 30/151 [03:43<15:40,  7.78s/it]
 21%|██        | 31/151 [03:51<15:29,  7.75s/it]
 21%|██        | 32/151 [03:59<15:35,  7.86s/it]
 22%|██▏       | 33/151 [04:07<15:26,  7.85s/it]
 23%|██▎       | 34/151 [04:14<15:13,  7.80s/it]
 23%|██▎       | 35/151 [04:22<15:02,  7.78s/it]
 24%|██▍       | 36/151 [04:30<14:53,  7.77s/it]
 25%|██▍       | 37/151 [04:38<14:45,  7.77s/it]
 25%|██▌       | 38/151 [04:46<14:40,  7.79s/it]
 26%|██▌       | 39/151 [04:53<14:31,  7.78s/it]
 26%|██▋       | 40/151 [05:01<14:22,  7.77s/it]
 27%|██▋       | 41/151 [05:09<14:17,  7.80s/it]
 28%|██▊       | 42/151 [05:17<14:10,  7.81s/it]
 28%|██▊       | 43/151 [05:25<14:01,  7.80s/it]
 29%|██▉       | 44/151 [05:33<14:16,  8.01s/it]
 30%|██▉       | 45/151 [05:41<14:01,  7.94s/it]
 30%|███       | 46/151 [05:48<13:33,  7.75s/it]
 31%|███       | 47/151 [05:55<13:11,  7.61s/it]
 32%|███▏      | 48/151 [06:03<12:54,  7.52s/it]
 32%|███▏      | 49/151 [06:10<12:40,  7.45s/it]
 33%|███▎      | 50/151 [06:17<12:28,  7.41s/it]
 34%|███▍      | 51/151 [06:25<12:17,  7.38s/it]
 34%|███▍      | 52/151 [06:32<12:11,  7.39s/it]
 35%|███▌      | 53/151 [06:40<12:21,  7.56s/it]
 36%|███▌      | 54/151 [06:48<12:29,  7.73s/it]
 36%|███▋      | 55/151 [06:56<12:22,  7.73s/it]
 37%|███▋      | 56/151 [07:04<12:12,  7.71s/it]
 38%|███▊      | 57/151 [07:11<11:55,  7.62s/it]
 38%|███▊      | 58/151 [07:18<11:39,  7.52s/it]
 39%|███▉      | 59/151 [07:26<11:40,  7.61s/it]
 40%|███▉      | 60/151 [07:34<11:37,  7.66s/it]
 40%|████      | 61/151 [07:42<11:36,  7.74s/it]
 41%|████      | 62/151 [07:50<11:32,  7.78s/it]
 42%|████▏     | 63/151 [07:57<11:21,  7.75s/it]
 42%|████▏     | 64/151 [08:06<11:45,  8.11s/it]
 43%|████▎     | 65/151 [08:14<11:27,  7.99s/it]
 44%|████▎     | 66/151 [08:21<11:04,  7.82s/it]
 44%|████▍     | 67/151 [08:29<10:58,  7.84s/it]
 45%|████▌     | 68/151 [08:37<10:39,  7.71s/it]
 46%|████▌     | 69/151 [08:44<10:23,  7.61s/it]
 46%|████▋     | 70/151 [08:52<10:24,  7.71s/it]
 47%|████▋     | 71/151 [09:00<10:18,  7.74s/it]
 48%|████▊     | 72/151 [09:07<10:02,  7.63s/it]
 48%|████▊     | 73/151 [09:15<10:02,  7.72s/it]
 49%|████▉     | 74/151 [09:23<10:03,  7.83s/it]
 50%|████▉     | 75/151 [09:31<09:45,  7.71s/it]
 50%|█████     | 76/151 [09:38<09:28,  7.58s/it]
 51%|█████     | 77/151 [09:46<09:22,  7.61s/it]
 52%|█████▏    | 78/151 [09:54<09:24,  7.74s/it]
 52%|█████▏    | 79/151 [10:02<09:20,  7.78s/it]
 53%|█████▎    | 80/151 [10:10<09:18,  7.86s/it]
 54%|█████▎    | 81/151 [10:17<09:12,  7.89s/it]
 54%|█████▍    | 82/151 [10:25<09:03,  7.88s/it]
 55%|█████▍    | 83/151 [10:33<08:53,  7.84s/it]
 56%|█████▌    | 84/151 [10:42<09:00,  8.07s/it]
 56%|█████▋    | 85/151 [10:50<08:48,  8.00s/it]
 57%|█████▋    | 86/151 [10:57<08:36,  7.95s/it]
 58%|█████▊    | 87/151 [11:05<08:17,  7.77s/it]
 58%|█████▊    | 88/151 [11:12<07:59,  7.61s/it]
 59%|█████▉    | 89/151 [11:19<07:44,  7.49s/it]
 60%|█████▉    | 90/151 [11:27<07:34,  7.46s/it]
 60%|██████    | 91/151 [11:34<07:25,  7.43s/it]
 61%|██████    | 92/151 [11:41<07:17,  7.42s/it]
 62%|██████▏   | 93/151 [11:49<07:10,  7.42s/it]
 62%|██████▏   | 94/151 [11:56<07:03,  7.43s/it]
 63%|██████▎   | 95/151 [12:04<06:55,  7.41s/it]
 64%|██████▎   | 96/151 [12:11<06:45,  7.37s/it]
 64%|██████▍   | 97/151 [12:18<06:35,  7.32s/it]
 65%|██████▍   | 98/151 [12:25<06:26,  7.29s/it]
 66%|██████▌   | 99/151 [12:33<06:25,  7.41s/it]
 66%|██████▌   | 100/151 [12:41<06:19,  7.45s/it]
 67%|██████▋   | 101/151 [12:48<06:10,  7.40s/it]
 68%|██████▊   | 102/151 [12:55<06:01,  7.38s/it]
 68%|██████▊   | 103/151 [13:02<05:53,  7.36s/it]
 69%|██████▉   | 104/151 [13:10<05:54,  7.54s/it]
 70%|██████▉   | 105/151 [13:18<05:40,  7.41s/it]
 70%|███████   | 106/151 [13:25<05:29,  7.32s/it]
 71%|███████   | 107/151 [13:32<05:19,  7.27s/it]
 72%|███████▏  | 108/151 [13:39<05:11,  7.23s/it]
 72%|███████▏  | 109/151 [13:46<05:02,  7.21s/it]
 73%|███████▎  | 110/151 [13:53<04:55,  7.20s/it]
 74%|███████▎  | 111/151 [14:00<04:47,  7.18s/it]
 74%|███████▍  | 112/151 [14:07<04:39,  7.16s/it]
 75%|███████▍  | 113/151 [14:15<04:31,  7.15s/it]
 75%|███████▌  | 114/151 [14:22<04:25,  7.16s/it]
 76%|███████▌  | 115/151 [14:29<04:18,  7.18s/it]
 77%|███████▋  | 116/151 [14:36<04:11,  7.17s/it]
 77%|███████▋  | 117/151 [14:43<04:04,  7.18s/it]
 78%|███████▊  | 118/151 [14:51<03:56,  7.16s/it]
 79%|███████▉  | 119/151 [14:58<03:48,  7.15s/it]
 79%|███████▉  | 120/151 [15:05<03:41,  7.15s/it]
 80%|████████  | 121/151 [15:12<03:34,  7.16s/it]
 81%|████████  | 122/151 [15:19<03:27,  7.16s/it]
 81%|████████▏ | 123/151 [15:26<03:20,  7.16s/it]
 82%|████████▏ | 124/151 [15:34<03:19,  7.40s/it]
 83%|████████▎ | 125/151 [15:41<03:10,  7.32s/it]
 83%|████████▎ | 126/151 [15:49<03:01,  7.28s/it]
 84%|████████▍ | 127/151 [15:56<02:53,  7.25s/it]
 85%|████████▍ | 128/151 [16:03<02:46,  7.24s/it]
 85%|████████▌ | 129/151 [16:10<02:39,  7.23s/it]
 86%|████████▌ | 130/151 [16:17<02:31,  7.22s/it]
 87%|████████▋ | 131/151 [16:25<02:24,  7.20s/it]
 87%|████████▋ | 132/151 [16:32<02:16,  7.21s/it]
 88%|████████▊ | 133/151 [16:39<02:09,  7.19s/it]
 89%|████████▊ | 134/151 [16:46<02:02,  7.19s/it]
 89%|████████▉ | 135/151 [16:53<01:55,  7.19s/it]
 90%|█████████ | 136/151 [17:00<01:47,  7.18s/it]
 91%|█████████ | 137/151 [17:08<01:40,  7.18s/it]
 91%|█████████▏| 138/151 [17:15<01:33,  7.18s/it]
 92%|█████████▏| 139/151 [17:22<01:26,  7.18s/it]
 93%|█████████▎| 140/151 [17:29<01:18,  7.17s/it]
 93%|█████████▎| 141/151 [17:36<01:11,  7.18s/it]
 94%|█████████▍| 142/151 [17:44<01:04,  7.19s/it]
 95%|█████████▍| 143/151 [17:51<00:57,  7.20s/it]
 95%|█████████▌| 144/151 [17:59<00:51,  7.41s/it]
 96%|█████████▌| 145/151 [18:06<00:44,  7.34s/it]
 97%|█████████▋| 146/151 [18:13<00:36,  7.33s/it]
 97%|█████████▋| 147/151 [18:21<00:29,  7.35s/it]
 98%|█████████▊| 148/151 [18:28<00:21,  7.33s/it]
 99%|█████████▊| 149/151 [18:35<00:14,  7.31s/it]
 99%|█████████▉| 150/151 [18:42<00:07,  7.29s/it]
[MoviePy] Done.
[MoviePy] >>>> Video ready: videos_out/cat_dog_out.mp4 

CPU times: user 1h 7min 41s, sys: 1min 26s, total: 1h 9min 7s
Wall time: 18min 43s

In [24]:
filename = 'videos_in/fruits.mp4'
new_loc = 'videos_out/banana_out.mp4'

counter = 0

white_output = new_loc
clip1 = VideoFileClip(filename).subclip(79,85)
white_clip = clip1.fl_image(process_image) #NOTE: this function expects color images!!s
%time white_clip.write_videofile(white_output, audio=False)
[MoviePy] >>>> Building video videos_out/banana_out.mp4
[MoviePy] Writing video videos_out/banana_out.mp4
  0%|          | 0/144 [00:00<?, ?it/s]
  1%|          | 1/144 [00:07<17:42,  7.43s/it]
  1%|▏         | 2/144 [00:14<17:29,  7.39s/it]
  2%|▏         | 3/144 [00:22<17:17,  7.36s/it]
  3%|▎         | 4/144 [00:29<17:04,  7.32s/it]
  3%|▎         | 5/144 [00:36<16:54,  7.30s/it]
  4%|▍         | 6/144 [00:43<16:43,  7.27s/it]
  5%|▍         | 7/144 [00:50<16:36,  7.28s/it]
  6%|▌         | 8/144 [00:58<16:41,  7.36s/it]
  6%|▋         | 9/144 [01:06<16:45,  7.45s/it]
  7%|▋         | 10/144 [01:13<16:45,  7.50s/it]
  8%|▊         | 11/144 [01:21<16:38,  7.50s/it]
  8%|▊         | 12/144 [01:28<16:33,  7.53s/it]
  9%|▉         | 13/144 [01:37<16:58,  7.77s/it]
 10%|▉         | 14/144 [01:44<16:38,  7.68s/it]
 10%|█         | 15/144 [01:52<16:22,  7.61s/it]
 11%|█         | 16/144 [01:59<16:13,  7.61s/it]
 12%|█▏        | 17/144 [02:07<15:56,  7.53s/it]
 12%|█▎        | 18/144 [02:14<15:39,  7.46s/it]
 13%|█▎        | 19/144 [02:21<15:30,  7.44s/it]
 14%|█▍        | 20/144 [02:29<15:34,  7.54s/it]
 15%|█▍        | 21/144 [02:37<15:25,  7.52s/it]
 15%|█▌        | 22/144 [02:45<15:37,  7.69s/it]
 16%|█▌        | 23/144 [02:53<15:41,  7.78s/it]
 17%|█▋        | 24/144 [03:01<15:50,  7.92s/it]
 17%|█▋        | 25/144 [03:09<15:52,  8.00s/it]
 18%|█▊        | 26/144 [03:17<15:38,  7.95s/it]
 19%|█▉        | 27/144 [03:25<15:25,  7.91s/it]
 19%|█▉        | 28/144 [03:32<15:08,  7.83s/it]
 20%|██        | 29/144 [03:40<14:56,  7.80s/it]
 21%|██        | 30/144 [03:48<14:48,  7.80s/it]
 22%|██▏       | 31/144 [03:56<14:34,  7.74s/it]
 22%|██▏       | 32/144 [04:03<14:27,  7.74s/it]
 23%|██▎       | 33/144 [04:12<15:06,  8.17s/it]
 24%|██▎       | 34/144 [04:21<15:09,  8.27s/it]
 24%|██▍       | 35/144 [04:29<15:11,  8.36s/it]
 25%|██▌       | 36/144 [04:38<15:01,  8.35s/it]
 26%|██▌       | 37/144 [04:46<14:58,  8.40s/it]
 26%|██▋       | 38/144 [04:55<14:53,  8.43s/it]
 27%|██▋       | 39/144 [05:03<14:46,  8.44s/it]
 28%|██▊       | 40/144 [05:12<14:38,  8.45s/it]
 28%|██▊       | 41/144 [05:20<14:30,  8.45s/it]
 29%|██▉       | 42/144 [05:29<14:25,  8.48s/it]
 30%|██▉       | 43/144 [05:37<14:14,  8.46s/it]
 31%|███       | 44/144 [05:46<14:04,  8.44s/it]
 31%|███▏      | 45/144 [05:54<13:49,  8.38s/it]
 32%|███▏      | 46/144 [06:02<13:26,  8.23s/it]
 33%|███▎      | 47/144 [06:09<13:02,  8.06s/it]
 33%|███▎      | 48/144 [06:17<12:42,  7.94s/it]
 34%|███▍      | 49/144 [06:25<12:35,  7.95s/it]
 35%|███▍      | 50/144 [06:33<12:22,  7.90s/it]
 35%|███▌      | 51/144 [06:41<12:12,  7.87s/it]
 36%|███▌      | 52/144 [06:48<12:04,  7.88s/it]
 37%|███▋      | 53/144 [06:57<12:10,  8.03s/it]
 38%|███▊      | 54/144 [07:04<11:49,  7.89s/it]
 38%|███▊      | 55/144 [07:12<11:33,  7.79s/it]
 39%|███▉      | 56/144 [07:20<11:21,  7.74s/it]
 40%|███▉      | 57/144 [07:27<11:12,  7.73s/it]
 40%|████      | 58/144 [07:35<11:00,  7.68s/it]
 41%|████      | 59/144 [07:43<10:52,  7.68s/it]
 42%|████▏     | 60/144 [07:50<10:46,  7.69s/it]
 42%|████▏     | 61/144 [07:58<10:34,  7.65s/it]
 43%|████▎     | 62/144 [08:05<10:24,  7.62s/it]
 44%|████▍     | 63/144 [08:13<10:13,  7.58s/it]
 44%|████▍     | 64/144 [08:20<10:04,  7.56s/it]
 45%|████▌     | 65/144 [08:28<09:57,  7.56s/it]
 46%|████▌     | 66/144 [08:35<09:49,  7.56s/it]
 47%|████▋     | 67/144 [08:43<09:42,  7.57s/it]
 47%|████▋     | 68/144 [08:51<09:36,  7.58s/it]
 48%|████▊     | 69/144 [08:58<09:27,  7.56s/it]
 49%|████▊     | 70/144 [09:06<09:20,  7.57s/it]
 49%|████▉     | 71/144 [09:13<09:12,  7.57s/it]
 50%|█████     | 72/144 [09:21<09:05,  7.57s/it]
 51%|█████     | 73/144 [09:29<09:15,  7.83s/it]
 51%|█████▏    | 74/144 [09:37<09:04,  7.77s/it]
 52%|█████▏    | 75/144 [09:45<08:52,  7.72s/it]
 53%|█████▎    | 76/144 [09:52<08:41,  7.67s/it]
 53%|█████▎    | 77/144 [10:00<08:32,  7.64s/it]
 54%|█████▍    | 78/144 [10:07<08:22,  7.62s/it]
 55%|█████▍    | 79/144 [10:15<08:14,  7.60s/it]
 56%|█████▌    | 80/144 [10:22<08:06,  7.59s/it]
 56%|█████▋    | 81/144 [10:30<07:58,  7.60s/it]
 57%|█████▋    | 82/144 [10:38<07:50,  7.59s/it]
 58%|█████▊    | 83/144 [10:45<07:44,  7.61s/it]
 58%|█████▊    | 84/144 [10:53<07:37,  7.62s/it]
 59%|█████▉    | 85/144 [11:01<07:30,  7.64s/it]
 60%|█████▉    | 86/144 [11:08<07:22,  7.62s/it]
 60%|██████    | 87/144 [11:16<07:14,  7.62s/it]
 61%|██████    | 88/144 [11:23<07:06,  7.62s/it]
 62%|██████▏   | 89/144 [11:31<07:00,  7.65s/it]
 62%|██████▎   | 90/144 [11:39<06:53,  7.66s/it]
 63%|██████▎   | 91/144 [11:46<06:45,  7.66s/it]
 64%|██████▍   | 92/144 [11:54<06:37,  7.65s/it]
 65%|██████▍   | 93/144 [12:03<06:42,  7.90s/it]
 65%|██████▌   | 94/144 [12:10<06:31,  7.83s/it]
 66%|██████▌   | 95/144 [12:18<06:21,  7.78s/it]
 67%|██████▋   | 96/144 [12:26<06:11,  7.74s/it]
 67%|██████▋   | 97/144 [12:33<06:02,  7.71s/it]
 68%|██████▊   | 98/144 [12:41<05:53,  7.68s/it]
 69%|██████▉   | 99/144 [12:49<05:45,  7.68s/it]
 69%|██████▉   | 100/144 [12:56<05:38,  7.68s/it]
 70%|███████   | 101/144 [13:04<05:30,  7.69s/it]
 71%|███████   | 102/144 [13:12<05:22,  7.69s/it]
 72%|███████▏  | 103/144 [13:19<05:15,  7.69s/it]
 72%|███████▏  | 104/144 [13:27<05:08,  7.71s/it]
 73%|███████▎  | 105/144 [13:35<05:00,  7.71s/it]
 74%|███████▎  | 106/144 [13:43<04:53,  7.72s/it]
 74%|███████▍  | 107/144 [13:50<04:45,  7.72s/it]
 75%|███████▌  | 108/144 [13:58<04:37,  7.71s/it]
 76%|███████▌  | 109/144 [14:06<04:29,  7.70s/it]
 76%|███████▋  | 110/144 [14:13<04:22,  7.71s/it]
 77%|███████▋  | 111/144 [14:21<04:17,  7.81s/it]
 78%|███████▊  | 112/144 [14:29<04:12,  7.90s/it]
 78%|███████▊  | 113/144 [14:39<04:17,  8.29s/it]
 79%|███████▉  | 114/144 [14:47<04:07,  8.26s/it]
 80%|███████▉  | 115/144 [14:55<03:56,  8.15s/it]
 81%|████████  | 116/144 [15:02<03:44,  8.01s/it]
 81%|████████▏ | 117/144 [15:10<03:34,  7.94s/it]
 82%|████████▏ | 118/144 [15:18<03:24,  7.86s/it]
 83%|████████▎ | 119/144 [15:26<03:15,  7.83s/it]
 83%|████████▎ | 120/144 [15:33<03:06,  7.79s/it]
 84%|████████▍ | 121/144 [15:41<02:58,  7.77s/it]
 85%|████████▍ | 122/144 [15:49<02:50,  7.77s/it]
 85%|████████▌ | 123/144 [15:57<02:42,  7.75s/it]
 86%|████████▌ | 124/144 [16:04<02:35,  7.76s/it]
 87%|████████▋ | 125/144 [16:12<02:27,  7.76s/it]
 88%|████████▊ | 126/144 [16:20<02:19,  7.78s/it]
 88%|████████▊ | 127/144 [16:28<02:12,  7.79s/it]
 89%|████████▉ | 128/144 [16:35<02:04,  7.78s/it]
 90%|████████▉ | 129/144 [16:43<01:56,  7.78s/it]
 90%|█████████ | 130/144 [16:51<01:49,  7.79s/it]
 91%|█████████ | 131/144 [16:59<01:41,  7.79s/it]
 92%|█████████▏| 132/144 [17:07<01:33,  7.80s/it]
 92%|█████████▏| 133/144 [17:15<01:28,  8.04s/it]
 93%|█████████▎| 134/144 [17:23<01:19,  7.97s/it]
 94%|█████████▍| 135/144 [17:31<01:11,  7.94s/it]
 94%|█████████▍| 136/144 [17:39<01:03,  7.90s/it]
 95%|█████████▌| 137/144 [17:47<00:55,  7.88s/it]
 96%|█████████▌| 138/144 [17:54<00:47,  7.87s/it]
 97%|█████████▋| 139/144 [18:02<00:39,  7.87s/it]
 97%|█████████▋| 140/144 [18:10<00:31,  7.88s/it]
 98%|█████████▊| 141/144 [18:18<00:23,  7.86s/it]
 99%|█████████▊| 142/144 [18:26<00:15,  7.85s/it]
 99%|█████████▉| 143/144 [18:34<00:07,  7.84s/it]
100%|██████████| 144/144 [18:41<00:00,  7.81s/it]
[MoviePy] Done.

[MoviePy] >>>> Video ready: videos_out/banana_out.mp4 

CPU times: user 1h 6min 10s, sys: 1min 28s, total: 1h 7min 39s
Wall time: 18min 42s
In [25]:
filename = 'videos_in/apple_picking.mp4'
new_loc = 'videos_out/apple_picking_out.mp4'

counter = 0

white_output = new_loc
clip1 = VideoFileClip(filename).subclip(41,44)
white_clip = clip1.fl_image(process_image) #NOTE: this function expects color images!!s
%time white_clip.write_videofile(white_output, audio=False)
[MoviePy] >>>> Building video videos_out/apple_picking_out.mp4
[MoviePy] Writing video videos_out/apple_picking_out.mp4
  0%|          | 0/91 [00:00<?, ?it/s]
  1%|          | 1/91 [00:07<11:46,  7.85s/it]
  2%|▏         | 2/91 [00:15<11:34,  7.80s/it]
  3%|▎         | 3/91 [00:23<11:23,  7.77s/it]
  4%|▍         | 4/91 [00:30<11:13,  7.74s/it]
  5%|▌         | 5/91 [00:38<11:05,  7.74s/it]
  7%|▋         | 6/91 [00:46<10:58,  7.74s/it]
  8%|▊         | 7/91 [00:54<10:49,  7.73s/it]
  9%|▉         | 8/91 [01:02<11:02,  7.98s/it]
 10%|▉         | 9/91 [01:10<10:50,  7.93s/it]
 11%|█         | 10/91 [01:18<10:42,  7.93s/it]
 12%|█▏        | 11/91 [01:26<10:28,  7.86s/it]
 13%|█▎        | 12/91 [01:33<10:18,  7.82s/it]
 14%|█▍        | 13/91 [01:41<10:07,  7.79s/it]
 15%|█▌        | 14/91 [01:49<09:58,  7.77s/it]
 16%|█▋        | 15/91 [01:57<09:50,  7.77s/it]
 18%|█▊        | 16/91 [02:04<09:42,  7.77s/it]
 19%|█▊        | 17/91 [02:12<09:33,  7.75s/it]
 20%|█▉        | 18/91 [02:20<09:25,  7.74s/it]
 21%|██        | 19/91 [02:27<09:17,  7.74s/it]
 22%|██▏       | 20/91 [02:35<09:08,  7.73s/it]
 23%|██▎       | 21/91 [02:43<09:01,  7.73s/it]
 24%|██▍       | 22/91 [02:51<08:53,  7.74s/it]
 25%|██▌       | 23/91 [02:58<08:46,  7.74s/it]
 26%|██▋       | 24/91 [03:06<08:43,  7.81s/it]
 27%|██▋       | 25/91 [03:15<08:46,  7.98s/it]
 29%|██▊       | 26/91 [03:23<08:36,  7.95s/it]
 30%|██▉       | 27/91 [03:30<08:24,  7.89s/it]
 31%|███       | 28/91 [03:39<08:32,  8.14s/it]
 32%|███▏      | 29/91 [03:47<08:18,  8.04s/it]
 33%|███▎      | 30/91 [03:55<08:10,  8.04s/it]
 34%|███▍      | 31/91 [04:03<07:57,  7.95s/it]
 35%|███▌      | 32/91 [04:10<07:44,  7.87s/it]
 36%|███▋      | 33/91 [04:18<07:33,  7.82s/it]
 37%|███▋      | 34/91 [04:26<07:23,  7.78s/it]
 38%|███▊      | 35/91 [04:33<07:14,  7.76s/it]
 40%|███▉      | 36/91 [04:41<07:07,  7.78s/it]
 41%|████      | 37/91 [04:49<06:59,  7.76s/it]
 42%|████▏     | 38/91 [04:57<06:50,  7.74s/it]
 43%|████▎     | 39/91 [05:04<06:41,  7.73s/it]
 44%|████▍     | 40/91 [05:12<06:33,  7.72s/it]
 45%|████▌     | 41/91 [05:20<06:25,  7.71s/it]
 46%|████▌     | 42/91 [05:28<06:18,  7.72s/it]
 47%|████▋     | 43/91 [05:35<06:10,  7.72s/it]
 48%|████▊     | 44/91 [05:43<06:03,  7.73s/it]
 49%|████▉     | 45/91 [05:51<05:55,  7.73s/it]
 51%|█████     | 46/91 [05:59<05:48,  7.74s/it]
 52%|█████▏    | 47/91 [06:06<05:39,  7.73s/it]
 53%|█████▎    | 48/91 [06:15<05:42,  7.95s/it]
 54%|█████▍    | 49/91 [06:22<05:31,  7.88s/it]
 55%|█████▍    | 50/91 [06:30<05:21,  7.84s/it]
 56%|█████▌    | 51/91 [06:38<05:13,  7.83s/it]
 57%|█████▋    | 52/91 [06:46<05:05,  7.84s/it]
 58%|█████▊    | 53/91 [06:54<04:56,  7.80s/it]
 59%|█████▉    | 54/91 [07:01<04:47,  7.76s/it]
 60%|██████    | 55/91 [07:09<04:38,  7.73s/it]
 62%|██████▏   | 56/91 [07:17<04:30,  7.72s/it]
 63%|██████▎   | 57/91 [07:24<04:22,  7.72s/it]
 64%|██████▎   | 58/91 [07:32<04:14,  7.72s/it]
 65%|██████▍   | 59/91 [07:40<04:07,  7.72s/it]
 66%|██████▌   | 60/91 [07:47<03:59,  7.73s/it]
 67%|██████▋   | 61/91 [07:55<03:51,  7.73s/it]
 68%|██████▊   | 62/91 [08:03<03:43,  7.72s/it]
 69%|██████▉   | 63/91 [08:11<03:36,  7.71s/it]
 70%|███████   | 64/91 [08:18<03:28,  7.72s/it]
 71%|███████▏  | 65/91 [08:26<03:21,  7.75s/it]
 73%|███████▎  | 66/91 [08:34<03:14,  7.77s/it]
 74%|███████▎  | 67/91 [08:42<03:06,  7.79s/it]
 75%|███████▍  | 68/91 [08:51<03:05,  8.07s/it]
 76%|███████▌  | 69/91 [08:58<02:55,  7.98s/it]
 77%|███████▋  | 70/91 [09:06<02:46,  7.93s/it]
 78%|███████▊  | 71/91 [09:14<02:37,  7.89s/it]
 79%|███████▉  | 72/91 [09:22<02:29,  7.87s/it]
 80%|████████  | 73/91 [09:30<02:21,  7.84s/it]
 81%|████████▏ | 74/91 [09:37<02:12,  7.81s/it]
 82%|████████▏ | 75/91 [09:45<02:04,  7.80s/it]
 84%|████████▎ | 76/91 [09:53<01:57,  7.80s/it]
 85%|████████▍ | 77/91 [10:01<01:49,  7.80s/it]
 86%|████████▌ | 78/91 [10:08<01:41,  7.80s/it]
 87%|████████▋ | 79/91 [10:16<01:33,  7.81s/it]
 88%|████████▊ | 80/91 [10:24<01:26,  7.83s/it]
 89%|████████▉ | 81/91 [10:32<01:18,  7.82s/it]
 90%|█████████ | 82/91 [10:40<01:10,  7.82s/it]
 91%|█████████ | 83/91 [10:48<01:02,  7.82s/it]
 92%|█████████▏| 84/91 [10:55<00:54,  7.82s/it]
 93%|█████████▎| 85/91 [11:03<00:46,  7.81s/it]
 95%|█████████▍| 86/91 [11:11<00:39,  7.81s/it]
 96%|█████████▌| 87/91 [11:20<00:32,  8.08s/it]
 97%|█████████▋| 88/91 [11:28<00:24,  8.12s/it]
 98%|█████████▊| 89/91 [11:36<00:16,  8.06s/it]
 99%|█████████▉| 90/91 [11:44<00:07,  7.99s/it]
[MoviePy] Done.
[MoviePy] >>>> Video ready: videos_out/apple_picking_out.mp4 

CPU times: user 41min 42s, sys: 54 s, total: 42min 36s
Wall time: 11min 44s

In [26]:
filename = 'videos_in/horse.mp4'
new_loc = 'videos_out/horse_out.mp4'

counter = 0

white_output = new_loc
clip1 = VideoFileClip(filename).subclip(45,49)
white_clip = clip1.fl_image(process_image) #NOTE: this function expects color images!!s
%time white_clip.write_videofile(white_output, audio=False)
[MoviePy] >>>> Building video videos_out/horse_out.mp4
[MoviePy] Writing video videos_out/horse_out.mp4
  0%|          | 0/120 [00:00<?, ?it/s]
  1%|          | 1/120 [00:08<16:02,  8.09s/it]
  2%|▏         | 2/120 [00:15<15:47,  8.03s/it]
  2%|▎         | 3/120 [00:23<15:32,  7.97s/it]
  3%|▎         | 4/120 [00:31<15:20,  7.93s/it]
  4%|▍         | 5/120 [00:39<15:08,  7.90s/it]
  5%|▌         | 6/120 [00:47<15:01,  7.91s/it]
  6%|▌         | 7/120 [00:55<14:54,  7.92s/it]
  7%|▋         | 8/120 [01:03<14:43,  7.89s/it]
  8%|▊         | 9/120 [01:11<14:34,  7.88s/it]
  8%|▊         | 10/120 [01:18<14:24,  7.86s/it]
  9%|▉         | 11/120 [01:26<14:16,  7.85s/it]
 10%|█         | 12/120 [01:34<14:08,  7.86s/it]
 11%|█         | 13/120 [01:42<13:59,  7.84s/it]
 12%|█▏        | 14/120 [01:50<13:51,  7.84s/it]
 12%|█▎        | 15/120 [01:58<13:45,  7.86s/it]
 13%|█▎        | 16/120 [02:06<14:07,  8.15s/it]
 14%|█▍        | 17/120 [02:14<13:50,  8.06s/it]
 15%|█▌        | 18/120 [02:22<13:35,  8.00s/it]
 16%|█▌        | 19/120 [02:30<13:25,  7.97s/it]
 17%|█▋        | 20/120 [02:38<13:16,  7.97s/it]
 18%|█▊        | 21/120 [02:46<13:09,  7.97s/it]
 18%|█▊        | 22/120 [02:54<13:01,  7.98s/it]
 19%|█▉        | 23/120 [03:02<12:52,  7.96s/it]
 20%|██        | 24/120 [03:10<12:44,  7.96s/it]
 21%|██        | 25/120 [03:18<12:34,  7.95s/it]
 22%|██▏       | 26/120 [03:26<12:26,  7.94s/it]
 22%|██▎       | 27/120 [03:34<12:16,  7.92s/it]
 23%|██▎       | 28/120 [03:41<12:07,  7.91s/it]
 24%|██▍       | 29/120 [03:49<12:01,  7.93s/it]
 25%|██▌       | 30/120 [03:57<11:52,  7.92s/it]
 26%|██▌       | 31/120 [04:05<11:43,  7.90s/it]
 27%|██▋       | 32/120 [04:13<11:35,  7.90s/it]
 28%|██▊       | 33/120 [04:21<11:29,  7.92s/it]
 28%|██▊       | 34/120 [04:29<11:21,  7.92s/it]
 29%|██▉       | 35/120 [04:37<11:13,  7.92s/it]
 30%|███       | 36/120 [04:46<11:31,  8.23s/it]
 31%|███       | 37/120 [04:54<11:16,  8.15s/it]
 32%|███▏      | 38/120 [05:02<11:03,  8.09s/it]
 32%|███▎      | 39/120 [05:10<10:52,  8.05s/it]
 33%|███▎      | 40/120 [05:18<10:44,  8.05s/it]
 34%|███▍      | 41/120 [05:26<10:34,  8.03s/it]
 35%|███▌      | 42/120 [05:34<10:24,  8.01s/it]
 36%|███▌      | 43/120 [05:42<10:15,  8.00s/it]
 37%|███▋      | 44/120 [05:50<10:06,  7.98s/it]
 38%|███▊      | 45/120 [05:58<09:57,  7.96s/it]
 38%|███▊      | 46/120 [06:05<09:48,  7.95s/it]
 39%|███▉      | 47/120 [06:13<09:41,  7.96s/it]
 40%|████      | 48/120 [06:21<09:34,  7.98s/it]
 41%|████      | 49/120 [06:29<09:27,  7.99s/it]
 42%|████▏     | 50/120 [06:38<09:19,  8.00s/it]
 42%|████▎     | 51/120 [06:46<09:12,  8.00s/it]
 43%|████▎     | 52/120 [06:54<09:04,  8.01s/it]
 44%|████▍     | 53/120 [07:02<08:55,  8.00s/it]
 45%|████▌     | 54/120 [07:09<08:47,  7.99s/it]
 46%|████▌     | 55/120 [07:18<08:39,  8.00s/it]
 47%|████▋     | 56/120 [07:26<08:48,  8.26s/it]
 48%|████▊     | 57/120 [07:34<08:34,  8.17s/it]
 48%|████▊     | 58/120 [07:42<08:23,  8.12s/it]
 49%|████▉     | 59/120 [07:50<08:13,  8.10s/it]
 50%|█████     | 60/120 [07:58<08:03,  8.06s/it]
 51%|█████     | 61/120 [08:06<07:54,  8.05s/it]
 52%|█████▏    | 62/120 [08:14<07:46,  8.04s/it]
 52%|█████▎    | 63/120 [08:22<07:37,  8.03s/it]
 53%|█████▎    | 64/120 [08:30<07:28,  8.01s/it]
 54%|█████▍    | 65/120 [08:38<07:20,  8.00s/it]
 55%|█████▌    | 66/120 [08:46<07:12,  8.01s/it]
 56%|█████▌    | 67/120 [08:54<07:04,  8.01s/it]
 57%|█████▋    | 68/120 [09:02<06:56,  8.00s/it]
 57%|█████▊    | 69/120 [09:10<06:47,  8.00s/it]
 58%|█████▊    | 70/120 [09:18<06:40,  8.01s/it]
 59%|█████▉    | 71/120 [09:27<06:33,  8.03s/it]
 60%|██████    | 72/120 [09:34<06:24,  8.01s/it]
 61%|██████    | 73/120 [09:42<06:16,  8.00s/it]
 62%|██████▏   | 74/120 [09:50<06:08,  8.01s/it]
 62%|██████▎   | 75/120 [09:59<06:12,  8.29s/it]
 63%|██████▎   | 76/120 [10:07<06:01,  8.21s/it]
 64%|██████▍   | 77/120 [10:15<05:50,  8.14s/it]
 65%|██████▌   | 78/120 [10:23<05:40,  8.10s/it]
 66%|██████▌   | 79/120 [10:31<05:31,  8.08s/it]
 67%|██████▋   | 80/120 [10:40<05:22,  8.07s/it]
 68%|██████▊   | 81/120 [10:48<05:16,  8.11s/it]
 68%|██████▊   | 82/120 [10:56<05:07,  8.08s/it]
 69%|██████▉   | 83/120 [11:04<04:58,  8.06s/it]
 70%|███████   | 84/120 [11:12<04:49,  8.05s/it]
 71%|███████   | 85/120 [11:20<04:41,  8.05s/it]
 72%|███████▏  | 86/120 [11:28<04:33,  8.06s/it]
 72%|███████▎  | 87/120 [11:36<04:25,  8.06s/it]
 73%|███████▎  | 88/120 [11:44<04:17,  8.04s/it]
 74%|███████▍  | 89/120 [11:52<04:08,  8.03s/it]
 75%|███████▌  | 90/120 [12:00<04:01,  8.04s/it]
 76%|███████▌  | 91/120 [12:08<03:53,  8.04s/it]
 77%|███████▋  | 92/120 [12:16<03:45,  8.04s/it]
 78%|███████▊  | 93/120 [12:24<03:37,  8.05s/it]
 78%|███████▊  | 94/120 [12:32<03:29,  8.05s/it]
 79%|███████▉  | 95/120 [12:41<03:28,  8.34s/it]
 80%|████████  | 96/120 [12:49<03:18,  8.29s/it]
 81%|████████  | 97/120 [12:57<03:09,  8.23s/it]
 82%|████████▏ | 98/120 [13:06<03:00,  8.19s/it]
 82%|████████▎ | 99/120 [13:14<02:51,  8.15s/it]
 83%|████████▎ | 100/120 [13:22<02:42,  8.14s/it]
 84%|████████▍ | 101/120 [13:30<02:34,  8.14s/it]
 85%|████████▌ | 102/120 [13:38<02:26,  8.12s/it]
 86%|████████▌ | 103/120 [13:46<02:17,  8.11s/it]
 87%|████████▋ | 104/120 [13:54<02:09,  8.10s/it]
 88%|████████▊ | 105/120 [14:02<02:01,  8.11s/it]
 88%|████████▊ | 106/120 [14:10<01:53,  8.11s/it]
 89%|████████▉ | 107/120 [14:18<01:45,  8.10s/it]
 90%|█████████ | 108/120 [14:27<01:37,  8.09s/it]
 91%|█████████ | 109/120 [14:35<01:29,  8.09s/it]
 92%|█████████▏| 110/120 [14:43<01:21,  8.10s/it]
 92%|█████████▎| 111/120 [14:51<01:13,  8.14s/it]
 93%|█████████▎| 112/120 [14:59<01:05,  8.13s/it]
 94%|█████████▍| 113/120 [15:07<00:56,  8.12s/it]
 95%|█████████▌| 114/120 [15:15<00:48,  8.11s/it]
 96%|█████████▌| 115/120 [15:24<00:42,  8.41s/it]
 97%|█████████▋| 116/120 [15:33<00:33,  8.33s/it]
 98%|█████████▊| 117/120 [15:41<00:24,  8.28s/it]
 98%|█████████▊| 118/120 [15:49<00:16,  8.24s/it]
 99%|█████████▉| 119/120 [15:57<00:08,  8.22s/it]
100%|██████████| 120/120 [16:05<00:00,  8.20s/it]
[MoviePy] Done.
[MoviePy] >>>> Video ready: videos_out/horse_out.mp4 

CPU times: user 56min 12s, sys: 1min 10s, total: 57min 22s
Wall time: 16min 5s