mr_w

  • *
  • 207
    • LibrePilot
Re: New video gadget
« Reply #30 on: November 03, 2017, 12:56:27 pm »
Here is a picture and a short video of the latency.

Is it 0.2 or 0.13 seconds something?

Yes, 0.2 and even 0.13s is quite bit of latency. For high altitude, slow flying this will be really okay. It is similar latency to what GoPro offers on its video-out. Better HD cameras made for FPV have 0.05 - 0.06s latency, and simple analog ones are in 30ms range.


karla

  • *****
  • 629
Re: New video gadget
« Reply #31 on: November 03, 2017, 01:09:58 pm »
Ah, yes this camera is several years old and cheep to start with.
There might be other factors impacting latency other than the camera right?
Camera is the most important?
Anyway compared to the previous post video from filnet, my set up has the same type radio receiver and Win 10.
« Last Edit: November 03, 2017, 01:16:19 pm by karla »

filnet

  • *****
  • 113
Re: New video gadget
« Reply #32 on: November 04, 2017, 03:52:04 pm »
I have one of those : http://laserbgc.com/index.php?route=product/product&product_id=82

With that one I measured a latency of 487 - 359 = 128 ms in PFD.
Or by using the next two frames : 359 - 247 = 112 ms.



To display the time, I added a timeoverlay element to the pipeline.

New pipeline looks like this:
ksvideosrc device-index=0 ! decodebin ! timeoverlay halignment=left valignment=bottom shaded-background=true font-desc="Sans, 36" ! videoconvert ! video/x-raw,format=RGB ! appsink name=sink emit-signals=true

PS : I think, but need to verify, that PFD will add some extra latency compared to plain video gadget.
This is due to additional processing steps to get the video to the PFD.
« Last Edit: November 04, 2017, 04:09:15 pm by filnet »

karla

  • *****
  • 629
Re: New video gadget
« Reply #33 on: November 05, 2017, 01:09:11 am »
That really looks like a useful receiver both pc and mac and 3 radio frequencies.
So your ~120ms is roughly in the same ballpark as my results (my pc is pretty slow).
The elements you add to the video pipeline seems very useful, are those documented somewhere?
Thanks
K

filnet

  • *****
  • 113
Re: New video gadget
« Reply #34 on: November 05, 2017, 11:36:34 am »
There are hundreds of GStreamer plugins and elements : https://gstreamer.freedesktop.org/documentation/plugins.html

f5soh

  • *****
  • 4572
    • LibrePilot
Re: New video gadget
« Reply #35 on: November 05, 2017, 12:33:05 pm »
Found 120ms for Video and 160ms for PFD, using a 10$ Easycap usb stick connected to the Fatshark/Nextwave receiver.




Re: New video gadget
« Reply #36 on: November 05, 2017, 05:16:25 pm »
I bet there is an effective sleep(x) somewhere in the message pump or loop to keep the PFD from eating 100% CPU.  That could probably be tweaked or made a setting if desired.

f5soh

  • *****
  • 4572
    • LibrePilot
Re: New video gadget
« Reply #37 on: November 05, 2017, 05:51:16 pm »
Maybe sleep(40) somewhere  ::)

Quote
PS : I think, but need to verify, that PFD will add some extra latency compared to plain video gadget.
This is due to additional processing steps to get the video to the PFD.
« Last Edit: November 05, 2017, 05:54:49 pm by f5soh »

karla

  • *****
  • 629
Re: New video gadget
« Reply #38 on: November 08, 2017, 01:27:58 pm »
@filnet,
Now I got the OSD in the PFD video to work, thats great.
How do I go about if I want to save the flight on to a video file on the PC?

filnet

  • *****
  • 113
Re: New video gadget
« Reply #39 on: November 09, 2017, 09:18:00 pm »
@Cliff you are probably right.
Video to PFD needs an extra GStreamer conversion to a RGB format to satisfy OSG (that could be removed)
And then there is QML that imposes its own refresh rate.

Video gadget is much more direct. Qt makes the underlying window available to GStreamer and GStreamer renders to it directly.


filnet

  • *****
  • 113
Re: New video gadget
« Reply #40 on: November 09, 2017, 09:28:28 pm »
@Karl about recording the video: again we will start from video gadget (and then, once it works, move to PFD).

Recording can get tricky as you need to choose a container (mpeg, mp4, wmv, ...) and a codec (h264, ...). Codecs offer a lot of options that will influence quality, size of file, CPU usage and what not...

We can start with this pipeline:

Code: [Select]
ksvideosrc device-index=0 ! decodebin ! tee name=t
    t. ! queue ! autovideosink
    t. ! queue ! x264enc tune=zerolatency bitrate=498 ! mpegpsmux ! filesink location=capture.mpg

This pipeline will tee the video into two streams. One will be displayed and the other will be recorded to a mpeg file.
The file (capture.mpeg) should be created in the LibrePilot directory.

Note that some of the videos where not playable with Windows Media Player but worked fine with VLC.

Re: New video gadget
« Reply #41 on: November 10, 2017, 06:14:53 am »
Just as a point of reference, I found that Mpeg1 codec set to high bit rate and high quality produced good quality video with minimal latency.  It gave me the best quality and latency when I wanted to view and record the video same time on an old single core WinXP laptop.  The down side was large file size which I could handle with post processing if desired.  This was using the video editor software that came with an EasyCap video to USB device.  That software did a good job of capture too.

karla

  • *****
  • 629
Re: New video gadget
« Reply #42 on: November 11, 2017, 07:29:00 am »
Thank you filnet.
I put your pipeline text string in to the gadget Options, like this:



Then I opened the gadget and clicked the little play button to the down left, waited a while and then clicked the stopp button.
After that I expected to find a file somewhere on the PC called capture.mpg - but its not there.



Any thoughts?
p.s Should say the video did display okay on the screen.
« Last Edit: November 11, 2017, 07:33:46 am by karla »

filnet

  • *****
  • 113
Re: New video gadget
« Reply #43 on: November 11, 2017, 01:21:45 pm »
After that I expected to find a file somewhere on the PC called capture.mpg - but its not there.

Any thoughts?

Are you sure the directory D:\msys64\home\ABC exists ? If not, then create it.
But I would suggest to keep the file name simple for now (just capture.mpg) and it should be created in the LibrePilot directory.

karla

  • *****
  • 629
Re: New video gadget
« Reply #44 on: November 12, 2017, 01:04:29 am »
Yes it exists. I also first tried with just capture.mpg, its a bit embarrassing but I am not sure where the Librepilot directory is located, so I searched both c and d drive for the file, but no match. Done this several times after restarting etc etc.
Can there be any other cause, like my win 10 machine is missing the sw that creates the .mpg file?