Hello Tello Pilot!
Join our DJI Tello community & remove this banner.
Sign up

Translating an h264 code to an image in python

vasilis1926

New member
Joined
Feb 7, 2020
Messages
4
Reaction score
0
I am working on a project and I am trying to save the video from a drone in my computer and also show it live. I thought about converting the video in Images about 30 per second and updating my frontend with these pictures so that it looks like a video. Since It is the first time I am working with video and image strings I need some help. As far as I can figure out with my knowledge I am receiving a byte string. I can not use the libh264 decoder because i am unable to intergrate it in python 3.7 its only working with python 2

I would appreciate it if you could help me understand where every picture starts and where it ends. I assume that there has to be some kind of parity bits. How is it possible to make a picture out of it. Here is my code and what I've tried so far:
def videoLogging(self):
logging.info("-----------[Tello] Video Thread: started------------------")
INTERVAL = 0.2
index = 0
while True:
try:
packet_data = None
index += 1
res_string, ip = self.video_socket.recvfrom(2048)
packet_data = res_string
print(packet_data)
self.createImg(packet_data)
time.sleep(5)
# videoResponse = self.video_socket.recv(2048)
# mv = memoryview(videoResponse).cast('H')
# if mv is not None:
# self.createImg(mv)
# print("image created")
# print('VIDEO %s' % videoResponse)
# time.sleep(3)
except Exception as ex:
logging.error("Error in listening to tello\t\t %s" % ex)

def createImg(self, data):
with open('image.jpg', 'wb') as f:
f.write(data)
Unfortunately, the image can't be opened. Thank you in regards.


Here the first bytestring that i read:
b'\x00\x00\x00\x01A\xe2\x82_\xc1^\xa9y\xae\xa3\xf2G\x1a \x89z\' \x8c\xa6\xe7I}\xf3F\x07t\xf4*b\xd8\xc7\xff\x82\xb32\xb7\x07\x9b\xf5r0\xa0\x1e\x10\x8e\x80\x07\xc1\xdd\xb8g\xba)\x02\xee\x9f\x16][\xe4\xc6\x16\xc8\x17y\x02\xdb\x974\x13Mfn\xcc6TB\xadC\xb3Y\xadB~"\xd5\xdb\xdbg\xbaQ:{\xbftV\xc4s\xb8\xa3\x1cC\xe9?\xca\xf6\xef\x84]?\xbd`\x94\xf6+\xa8\xb4]\xc3\xe9\xa8-I\xd1\x180\xed\xc9\xee\xf4\x93\xd2\r\x00p1\xb3\x1d\xa2~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7*\x93Kv)~[\xf1%\xeb(o\xef;\xc0\xb4,\xa1\xc2V\x8a\xff\xe1\x86\x17\xe7\xf17\xe81l&\x14<j\xb0AS\xf92\xb1C;\x81\x8a\x06D\xab\x11j\xcd\xb1q\x9e\xefm\x0ei7\x15\x8d\x03\xdd6B\xd9qg*X\x0f\xe6F\xdc\xb6\x93N\xbe\x12\xc9#I\xe3\xd4\x80j\xe8z\xd5t\x05,Y\xd7\xec\xd1\x9a\x97\xae\x16\xb0\xdfi\xb2\xb8\xb5J-\xde9&\x1ai\x19\xb7\x81\xa3\'\xccf]\xeeK#\x8bk3\x11\x97\\T\x88\xfb\xee\xd3El:\x16\x13\xafi\xc0\xf9\xef\xefe7\xe4w\x14\xdf76g^\xd02J\x96Z\xedl\x19\x8eG\xb7\xc6\xebHj\x86\x84/:R{+co\xa0\xaa\xeb.\xbb\x0e\xc9\xf3\xa8\x1e\xd4\x1a\x010\x87;\xef\xbe\xaf.\x87\x9a5\xfdG\x82\xd5\xb2\x01\x1e\xf2\xd3l\xef\tb\xe7=1\x03\x8f\xae\x83\x84:0\x9bE;x\x03UB\x87\xbco\xb2\x80xZ\x96\x1a\x0e?i\xe51^\x9b\x1d\xb4\\|\xccH\xdf3G\x83\xbd/\rhS0;\x9a\xdb\xf6NG\x16 ?\xf3\x13<\xcf!p\xd5\n\xb1\xf2\x0e\xcc\xdc\x0b\xe6\xe8\[email protected]\x85\[email protected]\x87\xb4\xf8f\xc7\x9fi\xcc\xe4b\xca\xc0\x1eh\xc1u\xad\x98\x92\x12\x00\xb5`\xfa!~{\xac\xc0\x14:\xce\xfc\xa4\x90\x12\xc4K\xa5\xb9\x83\xd1\x03\x1a\xd8z\xf6A\xe9\xfbb\x07\x99\xf80\x9b,\x17\x8d /ZXb]\xb2P\\\'\xcb\n\xae\x82\x99X\xf5\t\xd1\xc9p\x11\x8d\xcaD\xf2\x8b\x8bc%\x17] \x89b\xa9kF\x93\xc0\xe1{INUg\xec\xb4\x1b`{\xd1:\x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b6cR\xb1\x18\x83\xe7\n\xde\xfeUM\x90\xf9\xbf\xf6\xd8J\xc7\x1a:z\x0bGL\x00l\xf6\xa5\x1f$\x86O6\xfa\x13\x04G\x0e\xfe\xca\xbe\xaf\xe1\xb6\xfa\x91\x9b\xb5\x9f]\x12N\x9c\xcf4b}E\x07\xa6B\xd2\x10\xe0Xjxi\x93\x92w\x1d \xd5\xd1\x87,5\xa0\xd3\x18\x8e\xe0\xad9o\x92\x8d\xb1\x95o\x0c"\xb4\xadW\xf9\xc9\xa0\xe5i\xdb\x17\xea\xd6o$Y\xfb\xb5\x9c\x93\x16\xf7\xc0\x1cz\x00\xfc$\x08\x9ay38Y\xe1_8\xb2\xe2\xd1\t\xcdfmcpSEt\x86\xa6'
 

f41ardu

Well-known member
Joined
Jan 3, 2019
Messages
57
Reaction score
20
Location
Back in Stuttgart ;->
Find an updated h264 decoder (for Python3 and Linux/Raspbian as platform) in my repository:

f41ardu/Tello-Python

Some libraries are required, including boost for python and cmake. If you are familar with your system building the decoder could be straight forward.
I have no idea to built for the windows platform.

f41ardu
 

New Threads

Members online

Forum statistics

Threads
4,074
Messages
30,984
Members
10,418
Latest member
Pparmly