liuxuan30 / TelloSwift

DJI Tello Swift Framework powered by SwiftNIO
Apache License 2.0
18 stars 7 forks source link

Video stream Data #6

Closed rubenvde closed 4 years ago

rubenvde commented 4 years ago

Hi @liuxuan30, I'm trying out your library which works great but I'm having trouble getting the video stream to work.

I set the videoDelegate and I'm receiving frames but can you clarify a bit more what to do with it? I'm getting a Data object back but I would like to get a NSImage or UIImage object from it. Can you describe how to do that?

liuxuan30 commented 4 years ago

Hi @rubenvde , the Data you get is directly from the stream of tello, that's the raw H264 content data. I have been working on providing a default video decoder, but I'm occupied recently so it slows me down.

The idea is you have to decode the H264 content either by videotoolbox first, or other similar Kits provided by apple, to create a CMSampleBuffer/CVImageBuffer or something like that, so you can get an image from one frame.

That's a little complicated to explain here, if you are not familiar with H264 decoding/encoding. There is a WWDC session about this, but it has gone for unknown reasons...

If you are not familiar and just want to comsume the video data, you will have to wait I commit the decoder so you can start your work from there. The code is ready and I tested a little, just need time to refactor and push.

Me myself also found this is very annoying as I also just wanted to consume the data rather than writing a video decoder from scratch first.

liuxuan30 commented 4 years ago

I will push a new project for video docoder soon, as it's far complex than I thought and really not related to Tello itself.

liuxuan30 commented 4 years ago

FYI @rubenvde #7 is being merged.