# Streaming Video Over USB is Slower than Streaming to IDE

**URL:** <https://forums.openmv.io/t/streaming-video-over-usb-is-slower-than-streaming-to-ide/5641>\
**Category:** OpenMV Boards\
**Created:** [March 30, 2021, 7:07pm UTC](https://forums.openmv.io/t/streaming-video-over-usb-is-slower-than-streaming-to-ide/5641 "2021-03-30T19:07:15Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![iabdalkader](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/iabdalkader/32/1169_2.png) [@iabdalkader](https://forums.openmv.io/u/iabdalkader)\
**Post date:** [March 31, 2021, 12:09am UTC](https://forums.openmv.io/t/streaming-video-over-usb-is-slower-than-streaming-to-ide/5641/11 "2021-03-31T00:09:49Z")

</div>

So right now we can’t yield from snapshot so coros are useless. Anyway, until double buffering is implemented you can either:

1. use timers like the following example ( I get 20FPS for VGA and 10FPS for HD)

```python
import sensor, image, time, ustruct
from pyb import USB_VCP, Timer

usb = USB_VCP()
sensor.reset()                   
sensor.set_pixformat(sensor.RGB565) 
sensor.set_framesize(sensor.HD)

img = None
ready = False
size = 0

def timer_callback(timer):
    global img
    global ready
    global size
    # DO NOT allocate memory in this handler.
    if (ready == True):
        usb.send(size)
        usb.send(img)
        ready = False 

tim = Timer(2, freq=100)
tim.callback(timer_callback)

while(True):
    fb = sensor.snapshot()
    if (usb.recv(4, timeout=10) == b'snap'):
        while (ready):
            time.sleep_ms(1)
        img = fb.compressed(quality=50)
        size = ustruct.pack("<L", img.size())
        ready = True

```

1. take a look at the pyopenmv.py module and pyopenmv\_fb.py in the tools dir, these pretty much implement the same protocol used by the IDE:

> **[openmv/tools at master · openmv/openmv](https://github.com/openmv/openmv/tree/master/tools)**
>
> master/tools

---

_[View the full topic](https://forums.openmv.io/t/streaming-video-over-usb-is-slower-than-streaming-to-ide/5641)._
