diux-dev / rosettadrone

Android-based mavlink wrapper for DJI drones
BSD 3-Clause "New" or "Revised" License
113 stars 51 forks source link

[Question] Laggy Video? #29

Closed pierotofy closed 5 years ago

pierotofy commented 5 years ago

Hello :hand:

First of all, thanks for making this work available! I've compiled everything and connected my Phantom 3 Advanced to QGroundControl (which I run on a Desktop computer).

The mavlink commands are arriving, the video arrives also, but seems to lag quite a bit, with green bars appearing over the video feed. To rule out network problems I modified https://github.com/diux-dev/rosettadrone/blob/master/app/src/main/cpp/video_encoder.c#L155 to broadcast a videotestsrc video source instead of the UDP packets and video shows up OK.

I tried tweaking encoding speed and bit rate, to no avail.

I'm guessing perhaps this is specific to the Phantom 3 Advanced, but I was just wondering if people have experienced the same issue or if they had suggestions?

sdowhy commented 5 years ago

What phone are you using? Does it work if you feed it into gstreamer or vlc on your desktop?

It is entirely possible it's due to the P3 Advanced, I don't have one to test with.

pierotofy commented 5 years ago

Hey thanks for the reply. It's a Google Pixel 1 (stock). I've also tried with an older Samsung Galaxy S3 mini, the frame rate seemed slower on the galaxy but showing more or less the same artifacts (image from QGroundControl video feed attached).

image

VLC gives some hints, but doesn't even display the video stream.

vlc --network-caching 0 --demux h264 "udp://@0.0.0.0:5600"

VLC media player 3.0.4 Vetinari (revision 3.0.4-0-gf615db6332)
[0000565429265570] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
^C[00007fd86c0153f0] h26x demux error: this doesn't look like a h264 ES stream, continuing anyway
[00007fd86c002580] main stream error: unknown query 0x30e in demux_vaControlHelper
QObject::~QObject: Timers cannot be stopped from another thread

Removing the --demux h264 parameter yields no video, but no warning.

vlc --network-caching 0 "udp://@0.0.0.0:5600"

I will continue investigating, I just thought I'd open an issue to see if somebody encountered the same problem before (and if there are suggestions).

pierotofy commented 5 years ago

Well, embarrassing, but turns out I had uncommented some debugging statements to find my way around in the beginning, but forgot to turn them off later, which I think was causing the software to slow down and cause the lag :hammer:

Turning those statements off yields a smooth video.

image

I still can't figure out how to display the video stream in VLC, I think that would be handy to know in the future (or are there other tools).

On a related note, changing the IP address of the GCS causes the video feed to exhibit green artifacts again. I think something is not being deallocated/stopped properly, but this is for another issue.