-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathvideo2stdout.py
37 lines (29 loc) · 1.01 KB
/
video2stdout.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/python
"""
Minimal example how to stream video to ffplay
usage:
./video2stdout.py | ffplay -
"""
import sys
import os
import inspect
# http://stackoverflow.com/questions/10020325/make-python-stop-emitting-a-carriage-return-when-writing-newlines-to-sys-stdout
if sys.platform == "win32":
import msvcrt
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
BEBOP_ROOT = os.path.realpath(os.path.abspath(os.path.join(os.path.split(inspect.getfile( inspect.currentframe() ))[0],"..")))
if BEBOP_ROOT not in sys.path:
sys.path.insert(0, BEBOP_ROOT) # access to drone source without installation
from bebop import Bebop
def videoCallback( frame, robot=None, debug=False ):
sys.stdout.write( frame[-1] ) # ignore frameNumber and frameFlag
sys.stdout.flush()
def video2stdout():
drone = Bebop( metalog=None, onlyIFrames=False )
drone.videoCbk = videoCallback
drone.videoEnable()
while True:
drone.update()
if __name__ == "__main__":
video2stdout()
# vim: expandtab sw=4 ts=4