LibrePilot Forum

Development => GCS General => Topic started by: filnet on July 15, 2017, 01:23:04 pm

Title: New video gadget
Post by: filnet on July 15, 2017, 01:23:04 pm
I submitted a PR that adds video to the PFD and a new video gadget to the GCS.

The PR can be found here https://bitbucket.org/librepilot/librepilot/pull-requests/454 (https://bitbucket.org/librepilot/librepilot/pull-requests/454)

There is a readme file in ./ground/gcs/src/libs/gstreamer/ that gives some pointers to building this branch.

A demo video can seen here:
https://vimeo.com/103945453 (https://vimeo.com/103945453)

GStreamer is used to view, process, record and eventually stream video from a variety of sources (usb or ip camera, file, network...).
For those who know GStreamer, the new video gadget is more or less a glorified gst-launch.

The GCS video gadget comes with a number of sample GStreamer pipelines. Most of them work on Windows only but can easily be adapted to Linux or Mac.

A few Windows' specific GStreamer elements are used but most pipelines will work if those elements are switched with the corresponding element for the specific platform.

Type  Windows  Linux  Mac
Video capture  ksvideosrc  v4l2src  avfvideosrc
Video display  d3dvideosink  ximagesink  osxvideosink
Screen capture  dx9screencapsrc  ximagesrc  avfvideosrc

You can get information about GStreamer elements with gst-launch-1.0 <element name>

The branch is known to compile and work on Windows, Linux and Mac.
It will work best with the latest GStreamer (1.12.2). Your results may vary if you use an older version of GStreamer (but it should work...).


Title: Re: New video gadget
Post by: filnet on July 15, 2017, 04:37:45 pm
[reserved]
Title: Re: New video gadget
Post by: f5soh on September 25, 2017, 11:49:53 pm
Video gadget is now merged to the development 'next' branch.

LibrePilot-16.09+r522-gd9cce5e_i686.exe  https://drive.google.com/open?id=0B5d_9OcqQj8BOGZmaFF5RnVUck0
Title: Re: New video gadget
Post by: Brunosanta on October 17, 2017, 06:28:50 pm
could anyone tell what would be the use of it, so I kind of follow?
thank you
Title: Re: New video gadget
Post by: filnet on October 17, 2017, 07:14:21 pm
could anyone tell what would be the use of it, so I kind of follow?

A simple use case is to display video from the UAV in the PFD. Sexier than the default background.

Another one is to record the video from the UAV to a file.

A more mundane use case is to record a video screen capture of your activity in GCS (for showing a bug, making a tutorial or demo-ing a new feature).

More advanced use cases include:
- receive video from UAV, overlay some information (OSD...) and transmit video to FPV goggles
- receive video from UAV, do some processing (detect faces) and send instructions back to UAV (say "hello")

GStreamer is a very powerful video/audio processing framework.

Your imagination is the limit...
Title: Re: New video gadget
Post by: Brunosanta on October 17, 2017, 07:58:26 pm
thanks for the answers, its clear now.
Title: Re: New video gadget
Post by: karla on October 18, 2017, 05:38:37 am
A simple use case is to display video from the UAV in the PFD. Sexier than the default background.
Hi, filnet, do you have a demo of this?
Its not in your first post right?
Thanks
Title: Re: New video gadget
Post by: f5soh on October 18, 2017, 07:25:57 am
Here is the video plugin and PFD working with a local USB camera.
The same can be achieved receiving a remote Wifi camera and composite video from FPV receiver using a EasyCap or similar.

https://www.youtube.com/watch?v=ttbe6b1H5d8
Title: Re: New video gadget
Post by: karla on October 23, 2017, 04:58:45 am
Ah, got to try that :) thanks.
Title: Re: New video gadget
Post by: karla on October 29, 2017, 07:22:43 am
Hi, not sure this is the right place for this post, but to try this new video capability out I setup the build environment and built the complete LibrePilot Next software on my PC MS windows 10 home edition and installed it. It worked amazingly well the whole process just following the instructions here :)
https://librepilot.atlassian.net/wiki/spaces/LPDOC/pages/14876735/Windows+Building+and+Packaging

Now, I also got a small 5.8 gHz usb receiver and plugged it in to the PC usb port and windows installed the drivers for a USB2.0 PC CAMERA and I got a clear image immediately from my quad transmitter camera when I started the Camera app that ships with windows. Amazing.
https://www.banggood.com/Eachine-ROTG01-UVC-OTG-5_8G-150CH-Full-Channel-FPV-Receiver-For-Android-Mobile-Phone-Smartphone-p-1147692.html?rmmds=search (https://www.banggood.com/Eachine-ROTG01-UVC-OTG-5_8G-150CH-Full-Channel-FPV-Receiver-For-Android-Mobile-Phone-Smartphone-p-1147692.html?rmmds=search)
So I know the transmitter and camera and the PC is capable of receiving the video live feed.

(https://forum.librepilot.org/index.php?action=dlattach;topic=3649.0;attach=6797;image)

But what else do I need to do in LibrePilot GCS to get the video to display in the Video gadget?
I have tried Video|default and Video|USB camera play settings in the Scopes page but just getting the scrambled screen.
Maybe there is a file to ready about this somewhere I missed?

Thanks!

Title: Re: New video gadget
Post by: filnet on October 29, 2017, 12:14:45 pm
Hi karla,

First thing is that it is not possible to display USB video in more than one PFD/gadget at once (at least not out of the box...).

So please close the PFD or make it display something other than video and make sure you have only one gadget using USB Video.
The gadget has better error reporting than PFD so I suggest to get that working first and then switch to PFD.

So once you got USB video in only one Video gadget please report what you get (screen shot included please).

PS : The USB video restriction (i.e. only one widget can access the usb video) is system wide.
It also applies to other applications accessing the usb video. So make sure you are not visualizing the video from some other app.
Title: Re: New video gadget
Post by: karla on October 29, 2017, 12:41:10 pm
Hi  :)
okay Now I only have one gadget active,
that is the Scope|Video.
sub command is either | default or | USB camera -Play, does not matter, same result,
no picture.

(https://forum.librepilot.org/index.php?action=dlattach;topic=3649.0;attach=6804;image)

(https://forum.librepilot.org/index.php?action=dlattach;topic=3649.0;attach=6805;image)

some other setting I need to attend to?
Title: Re: New video gadget
Post by: filnet on October 29, 2017, 12:57:09 pm
Can you show the content of the video "console" ?
Title: Re: New video gadget
Post by: filnet on October 29, 2017, 01:08:26 pm
And try this:

Open the "USB Camera - Play" gadget configuration by going to Tools/Options/Video.

There, change the video "pipeline" to "ksvideosrc device-index=0 ! videoconvert ! autovideosink" (without the double quotes).

It will add an extra videoconvert element to the pipeline.
Title: Re: New video gadget
Post by: karla on October 29, 2017, 01:37:03 pm
Not sure I understand what you need :-\
but here are some screen dumps...
and I changed what you suggested, but no change...

(https://forum.librepilot.org/index.php?action=dlattach;topic=3649.0;attach=6807;image)

(https://forum.librepilot.org/index.php?action=dlattach;topic=3649.0;attach=6809;image)
Title: Re: New video gadget
Post by: filnet on October 29, 2017, 01:44:26 pm
Seems like you understood how to edit the pipeline ;)

But the screenshot of the console shows that the gadget uses the old pipeline (without the videoconvert).
Did you forget to press Ok or something ?
Title: Re: New video gadget
Post by: filnet on October 30, 2017, 07:33:51 pm
And if you have more than one video source (built-in web cam for instance) you can change the device-id property in the pipeline. If device-id zero is not what you want, then try 1, 2, etc...
Title: Re: New video gadget
Post by: karla on October 31, 2017, 12:04:26 pm
Thank you filnet.

I was actually trying that before you mentioned it as a wild guess :)

ksvideosrc device-index= 0 ! videoconvert ! autovideosink
ksvideosrc device-index= 1 ! videoconvert ! autovideosink
even tried
device-index= 2
device-index= -1

But, with only the onboard webcam active, then ID = 0  gives the video feed to the video gadget.
When both the onboard webcam and the usb camera is connected then the ID = 0 gives Pipeline error msg, but ID = 1 gives the video feed again.

See the error picture here.

(https://forum.librepilot.org/index.php?action=dlattach;topic=3649.0;attach=6818;image)

Does it matter that I do not have any FC board connected?

Anyway we should be able to rule out that my USB camera has problem since the PC onboard app Camera can display the stream?

Thanks
Title: Re: New video gadget
Post by: filnet on October 31, 2017, 02:52:13 pm
Things to try:

1/ Add a decodebin in the pipeline:
     ksvideosrc device-index= 0 ! decodebin ! videoconvert ! autovideosink

2/ Use the PC application to view the video from the usb cam and see if any information about the video can be obtained (format, etc...)
Title: Re: New video gadget
Post by: karla on October 31, 2017, 02:55:07 pm
Yes, will do.
I will also try to find another webcam to try.
Thanks
Title: Re: New video gadget
Post by: karla on October 31, 2017, 03:20:35 pm
I tried your first command, and it worked. Got video :)

ksvideosrc device-index= 0 ! decodebin ! videoconvert ! autovideosink

(https://forum.librepilot.org/index.php?action=dlattach;topic=3649.0;attach=6820;image)

Any idea what the command should look like to get the video feed in to the PFD video screen?

Its getting more exciting...
Title: Re: New video gadget
Post by: TheOtherCliff on October 31, 2017, 04:39:29 pm
My next here PFD widget type has a "PFD (Video)" option.  ?
Title: Re: New video gadget
Post by: filnet on October 31, 2017, 05:48:07 pm
@Karl, for PFD Video, you need to edit the PFD Video configuration and add the same decodebin element in front of the videoconvert element (PFD already has a videoconvert element). Make sure to not run the gadget and PFD at the same time.

Pipeline should look like this:
  ksvideosrc device-index=0 ! decodebin ! videoconvert ! video/x-raw,format=RGB ! appsink name=sink emit-signals=true

Could you do a quick test for me: in the gadget configuration (not PFD) remove the videoconvert element. I would like to know if decodebin alone is enough.

Next thing we can do is to measure latency of the video :)
Title: Re: New video gadget
Post by: karla on November 01, 2017, 01:52:17 am
Sorry, it got a bit late last night.

Yes!
Got video in the PFD | PFD(Video) gadget using your setting:
ksvideosrc device-index=0 ! decodebin ! videoconvert ! video/x-raw,format=RGB ! appsink name=sink emit-signals=true

(https://forum.librepilot.org/index.php?action=dlattach;topic=3649.0;attach=6822;image)

This is big filnet!
Since I started with this flying, back in the Openpilot times, I always wanted the PFD as my OSD - Now its here!
I will use and explore this further in my Heli FPV/Photo project. I already have a fully functional MinOPOSD system installed on it, but it can turn on/off handy.

Yes,
without the videoconvert part it still work with video feed in the Video | USB Camera - play gadget. Like this:
ksvideosrc device-index= 0 ! decodebin ! autovideosink


So any other tests you like me to run?  :P
Title: Re: New video gadget
Post by: filnet on November 01, 2017, 10:56:48 am
Great news ! Thansks for testing Karl !

Next step, if you are ok, will be to measure latency. I'll get back to you on how to do that.
Title: Re: New video gadget
Post by: f5soh on November 01, 2017, 11:25:41 am
PFD is really sexy :D
Title: Re: New video gadget
Post by: karla on November 01, 2017, 01:32:18 pm
(https://forum.librepilot.org/index.php?action=dlattach;topic=3649.0;attach=6828;image)
Title: Re: New video gadget
Post by: filnet on November 02, 2017, 11:24:59 am
One simple way to measure end to end latency is to:
- run GCS and display the video in PFD
- display on your PC screen a digital clock with milliseconds (for example: https://codepen.io/jasonleewilson/pen/gPrxwX)
- make sure that both the PFD and the clock are visible on your screen
- point your camera to film your PC screen to obtain a kaleidoscopic effect in the PFD and take a screen shot.
- the time difference between two consecutive frames of the kaleidoscope is your latency.

This will give you the end to end latency (but won't tell where this latency comes from).

An alternative way to measure latency is shown at the end of this video : https://www.youtube.com/watch?v=4ZBePhvjMW0
It is similar but requires a second camera.

Something else that can be done with the video gadget is to view the video stream *and* record it on disc.
Note that it is not (yet) possible to record the PFD overlay but only the raw video.
Title: Re: New video gadget
Post by: TheOtherCliff on November 02, 2017, 11:56:03 am
A very simple way to measure delay that nonetheless gives a good "feel" for the delay is to wave your hand up and down in front of the camera while you watch the video.  Change the frequency of your hand motion till you get it exactly out of phase ... hand going up while video shows hand going down ...

If you want a number, you can count the number of hand wave cycles (e.g. each time your hand goes down, don't count the ups) in a second, multiply by 2 to get the number of half cycles, and take the reciprocal "1 / halfcycles" to get your delay.

Full analog video hardware is so fast that this test seems instantaneous.
Title: Re: New video gadget
Post by: karla on November 03, 2017, 12:39:56 pm
Here is a picture and a short video of the latency.

(https://forum.librepilot.org/index.php?action=dlattach;topic=3649.0;attach=6837;image)

Is it 0.2 or 0.13 seconds something?

https://www.youtube.com/watch?v=3bcAbri5_JM

Maybe a 'hand test' next time...
Title: Re: New video gadget
Post by: mr_w on November 03, 2017, 12:56:27 pm
Here is a picture and a short video of the latency.
(https://forum.librepilot.org/index.php?action=dlattach;topic=3649.0;attach=6837;image)
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.

Title: Re: New video gadget
Post by: karla 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.
Title: Re: New video gadget
Post by: filnet 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.

(https://forum.librepilot.org/index.php?action=dlattach;topic=3649.0;attach=6839;image)

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.
Title: Re: New video gadget
Post by: karla 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
Title: Re: New video gadget
Post by: filnet on November 05, 2017, 11:36:34 am
There are hundreds of GStreamer plugins and elements : https://gstreamer.freedesktop.org/documentation/plugins.html
Title: Re: New video gadget
Post by: f5soh 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.

(https://forum.librepilot.org/index.php?action=dlattach;topic=3649.0;attach=6844)

(https://forum.librepilot.org/index.php?action=dlattach;topic=3649.0;attach=6846)
Title: Re: New video gadget
Post by: TheOtherCliff 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.
Title: Re: New video gadget
Post by: f5soh 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.
Title: Re: New video gadget
Post by: karla 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?
Title: Re: New video gadget
Post by: filnet 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.

Title: Re: New video gadget
Post by: filnet 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.
Title: Re: New video gadget
Post by: TheOtherCliff 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.
Title: Re: New video gadget
Post by: karla on November 11, 2017, 07:29:00 am
Thank you filnet.
I put your pipeline text string in to the gadget Options, like this:

(https://forum.librepilot.org/index.php?action=dlattach;topic=3649.0;attach=6858;image)

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.

(https://forum.librepilot.org/index.php?action=dlattach;topic=3649.0;attach=6860;image)

Any thoughts?
p.s Should say the video did display okay on the screen.
Title: Re: New video gadget
Post by: filnet 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.
Title: Re: New video gadget
Post by: karla 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?
Title: Re: New video gadget
Post by: karla on November 12, 2017, 02:55:05 am
Ah, I just had to start the GCS, run as administrator, then it did write the file :)
Movie captured just fine.
So, ready for the PFD Video gadget capture to file?

Title: Re: New video gadget
Post by: filnet on November 12, 2017, 01:24:16 pm
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?

Are you building LP yourself (I assumed you did because of the D:\msys64 in your recording location) ?

If you start LP using a shortcut then you can right click on it to go to the location of the executable.

Strange that you need to be admin though...

Anyways on to recording + PFD.
Title: Re: New video gadget
Post by: filnet on November 12, 2017, 01:38:34 pm
To record video and display it on the PFD we will add a third branch to the previous pipeline.

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

The new branch uses an intervideosink element that makes it possible to connect multiple pipelines together (but only within the same process).

And we will adapt the PFD pipeline to consume from the intervideosink.

Code: [Select]
intervideosrc ! timeoverlay halignment=left valignment=bottom shaded-background=true font-desc="Sans, 36" ! videoconvert ! video/x-raw,format=RGB ! appsink name=sink emit-signals=true

Note that I added the timeoverlay element so you can measure latency again to check if the new pipelines don't have an adverse effect on latency.

PS : I am aware that all this is a bit crude and not user friendly :)
Ideally all this should be hidden behind a user friendly interface where you just have to select a file to save to...
But having the raw power of GStreamer in your hands lets you do a lot of stuff...
Title: Re: New video gadget
Post by: karla on November 13, 2017, 01:42:55 pm
Yes, I proudly build my own LibrePilot executable :)
Found the location of the runtime installed LP here: C:\Program Files\LibrePilot

Many things are strange filnet, like the hat of the pope :) I accept the looks of the hat and the fact I need to run LP GCS as Admin, no problems as long as it works.

So these are the settings in the Gadget video pipeline I put in:

(https://forum.librepilot.org/index.php?action=dlattach;topic=3649.0;attach=6868;image)

This is the great result!!!! It works.

(https://forum.librepilot.org/index.php?action=dlattach;topic=3649.0;attach=6870;image)

And this is the video capture.mpg

https://forum.librepilot.org/index.php?action=dlattach;topic=3649.0;attach=6872

I am not sure about the latency,
maybe you have an idea?
Title: Re: New video gadget
Post by: filnet on November 13, 2017, 02:19:16 pm
You got it a bit wrong. Or I did not explain it well enough. Or both ;)

Some vocabulary, so we speak the same language:
- Video gadget is the the "standalone" video gadget (not PFD).
- PFD or PFD gadget is, well, the PFD...
- There is no "PFD Video gadget"  (but PFD has a configuration where it can display video).

From my last post, you need to put the 1st pipeline (with 3 branches) in a Video gadget and the second one in the PFD gadget.

With that setup:
- the Video gadget pipeline will display, record and push video to the intervideosink.
- the PFD pipeline will consume from the intervideosrc and display the video.

The intervideosink / intervideosrc will talk to each other behind the scene.

From the screenshot the latency looks worse : 907 - 674 = 233ms.

Can you try again with the alternative setup described here ?
Title: Re: New video gadget
Post by: karla on November 14, 2017, 01:53:34 am
Lets see if I got it right this time
It feels a bit counter intuitive but seems to work.

This is the Video setting:

(https://forum.librepilot.org/index.php?action=dlattach;topic=3649.0;attach=6873;image)

This is the PFD setting:

(https://forum.librepilot.org/index.php?action=dlattach;topic=3649.0;attach=6882;image)

This is the resulting Video screen:

(https://forum.librepilot.org/index.php?action=dlattach;topic=3649.0;attach=6877;image)

This is the resulting PFD screen:

(https://forum.librepilot.org/index.php?action=dlattach;topic=3649.0;attach=6875;image)

and lastly this is the capture clip:

https://forum.librepilot.org/index.php?action=dlattach;topic=3649.0;attach=6881

This is better since you can control when to save to disk and when to stop saving with the control buttons in the Video gadget.
Title: Re: New video gadget
Post by: TheOtherCliff on November 14, 2017, 03:45:37 am
To play without using sudo / admin you probably just need to belong to the correct group.

After plugging your video device in, do (lower case L):
  ls -lrt /dev
and look in the last few lines.

Or if you know the device name just do:
   ls -l /dev/yourdevicename

and see what group it belongs to.  From my system...
$ ls -l /dev/video0
crw-rw----+  1 root video    81,   0 Nov 13 21:35 video0

'root video' see here that root is the owner and video is the group.

If I just become a member of the video group I might not need to sudo / admin.  Is it 'video' group for you too?

It's also possible that an executable (player / pipeline) you are using changes it's effective user or group (SUID / SGID) as it runs...
Title: Re: New video gadget
Post by: filnet on November 14, 2017, 09:25:46 am
It feels a bit counter intuitive but seems to work.

My inner geek likes it.

This is better since you can control when to save to disk and when to stop saving with the control buttons in the Video gadget.

Yes, and it also shows one way to overcome the limitation that only one source can access the web cam.
There is still only one active ksvideosrc but the pipeline that has it can dispatch the video further to other pipelines.

The latency is still bad : 602 - 369 = 233 ms
Title: Re: New video gadget
Post by: karla on November 14, 2017, 11:35:54 am
should just say its fantastic to have this working :)
... so saving to disk will increase latency.
How about capturing or relaying sound to GCS?
Title: Re: New video gadget
Post by: filnet on November 14, 2017, 12:05:58 pm
... so saving to disk will increase latency.

I don't know where the latency comes from. There are probably multiple causes.
Will need to look into it.

How about capturing or relaying sound to GCS?

Can your video capture hw relay sound ? Do you get sound using the application that came with it ?
Title: Re: New video gadget
Post by: karla on November 14, 2017, 12:53:09 pm
Haha I just assumed it could record sound but it can not - so its a bit much to ask that the gcs should get any sound :)
Anyway, if another camera can send sound, in that case, would the Gadget be able to pick it up?
Best
K
Title: Re: New video gadget
Post by: karla on November 14, 2017, 12:54:37 pm
@cliff
Thanks!
Will look in to it tomorrow
K
Title: Re: New video gadget
Post by: TheOtherCliff on November 14, 2017, 07:12:53 pm
Usually CCD cameras don't have microphones.  Some RunCam brand cameras (e.g. Owl 2 adds night vision) have microphones, but they are USD $44 shipped.
https://www.ebay.com/itm/RunCam-OWL2-Camera-Orange-Power-5-36V-FOV-150/362112037161

Some less expensive CMOS cameras have microphones because CMOS is a simple circuit and there is room on the circuit board?

Most video transmitters have a microphone input and if your camera is deaf mute, you just buy a cheap (USD $1.09 shipped) surveillance microphone like this (I have some of this model, but can't promise I have used this exact one):
https://www.ebay.com/itm/1Pcs-Mic-Microphone-Sound-Monitor-Voice-Audio-Cable-Tiny-For-Security-Camera-DVR/332137471873

Some video transmitters even have built in microphones (USD $14 shipped).
https://www.banggood.com/Eachine-TX801-5_8G-72CH-0_01MW5MW25MW50MW100MW200MW400MW600MW-Switched-AV-VTX-FPV-Transmitter-p-1147691.html
Title: Re: New video gadget
Post by: karla on November 15, 2017, 03:55:37 am
Thanks Cliff.
Well my camera and tx do transmit both video and sound, hover the USB video receiver on the ground station is not capable to receive sound. As far as I understand.
This one: https://www.banggood.com/Eachine-ROTG01-UVC-OTG-5_8G-150CH-Full-Channel-FPV-Receiver-For-Android-Mobile-Phone-Smartphone-p-1147692.html?rmmds=search

For example if I use the Camera app that ships with MS 10, to display the video, then it is silent, however when choosing the built in camera on the PC it has sound (used for skype etc).
Title: Re: New video gadget
Post by: karla on November 16, 2017, 12:07:35 am
If I just become a member of the video group I might not need to sudo / admin.  Is it 'video' group for you too?

No, not sure. cant find any name indicated its the video.
But no problem really, I just put it in the LibrePilot shortcut to run as admin.

[email protected] MSYS ~
$ ls -lrt /dev
total 4
crw-rw-rw- 1 ABC None  13, 254 Dec  1  2006 clipboard
drwxr-xr-x 1 ABC None        0 Oct 28 06:12 shm
drwxr-xr-x 1 ABC None        0 Oct 28 06:12 mqueue
lrwxrwxrwx 1 ABC None       15 Oct 28 06:12 stdin -> /proc/self/fd/0
lrwxrwxrwx 1 ABC None       15 Oct 28 06:12 stdout -> /proc/self/fd/1
lrwxrwxrwx 1 ABC None       15 Oct 28 06:12 stderr -> /proc/self/fd/2
lrwxrwxrwx 1 ABC None       13 Oct 28 06:12 fd -> /proc/self/fd
crw-rw-rw- 1 ABC None   1,   5 Nov 15 23:03 zero
crw-rw-rw- 1 ABC None  13, 255 Nov 15 23:03 windows
crw-rw-rw- 1 ABC None   1,   9 Nov 15 23:03 urandom
crw-rw-rw- 1 ABC None 117,   5 Nov 15 23:03 ttyS5
crw-rw-rw- 1 ABC None 117,  12 Nov 15 23:03 ttyS12
crw-rw-rw- 1 ABC None 117,  11 Nov 15 23:03 ttyS11
crw-rw-rw- 1 ABC None   5,   0 Nov 15 23:03 tty
crw-rw-rw- 1 ABC None   1,   8 Nov 15 23:03 random
crw--w---- 1 ABC None 136,   0 Nov 15 23:03 pty0
crw-rw-rw- 1 ABC None   5,   2 Nov 15 23:03 ptmx
crw-rw-rw- 1 ABC None   1,   3 Nov 15 23:03 null
crw-rw-rw- 1 ABC None   1,   7 Nov 15 23:03 full
crw-rw-rw- 1 ABC None  14,   3 Nov 15 23:03 dsp
crw-rw-rw- 1 ABC None   5,   1 Nov 15 23:03 console
crw-rw-rw- 1 ABC None   5, 254 Nov 15 23:03 conout
crw-rw-rw- 1 ABC None   5, 255 Nov 15 23:03 conin
crw------- 1 ABC None   1,  11 Nov 15 23:03 kmsg
brw-rw-rw- 2 ABC None  11,   0 Nov 15 23:03 scd0
brw-rw-rw- 2 ABC None  11,   0 Nov 15 23:03 sr0
brw-rw-rw- 1 ABC None   8,   0 Nov 15 23:03 sda
brw-rw-rw- 1 ABC None   8,   1 Nov 15 23:03 sda1
brw-rw-rw- 1 ABC None   8,   2 Nov 15 23:03 sda2
brw-rw-rw- 1 ABC None   8,   3 Nov 15 23:03 sda3
brw-rw-rw- 1 ABC None   8,   4 Nov 15 23:03 sda4
brw-rw-rw- 1 ABC None   8,   5 Nov 15 23:03 sda5
 
Title: Re: New video gadget
Post by: f5soh on November 16, 2017, 12:28:06 am
Previous post from Cliff talk about devices access under Linux and you are using Windows.  :P

Anyways your issue seems related to rights needed to write in some place, not rights to access video device.
You must add your username to users authorized to write where the capture file is saved ?
Title: Re: New video gadget
Post by: karla on November 16, 2017, 10:15:54 am
Thanks a lot to even bother to answer this, really!
It works and I am happy with that.
Please move on in life
 :)
Title: Re: New video gadget
Post by: Anonator on November 21, 2017, 07:28:20 am
Trying to get video gadget working on xenial.  Compiled ok but no video in options on GCS. Create video gadget possible but no second selector shows to select USB...   Have gstreamer 1.8.3 Please help
Title: Re: New video gadget
Post by: filnet on November 21, 2017, 09:26:53 pm
Hi Anonator,

Can you run gcs with the "-log gcs.log" option and share the log file.

Note that even if no configs are available for the Video gadget (which is strange) you can always create a new one.
Try to create a config with this simple test pipeline:

Code: [Select]
videotestsrc ! autovideosink
Cheers,
Philippe.
Title: Re: New video gadget
Post by: Anonator on November 24, 2017, 01:20:25 am
My log file where I just open and go to scopes tab with video widget.  Thanks
Title: Re: New video gadget
Post by: filnet on November 24, 2017, 08:32:06 am
My log file where I just open and go to scopes tab with video widget.  Thanks

There is nothing special in the log file.
Try to do reset GCS with the -reset command line option or try to do a full clean build.
Title: Re: New video gadget
Post by: Anonator on November 25, 2017, 12:01:34 am
Thanks muchly filnet :)  Reset GCS with the -reset command line option fixed my problem.  Looks fantastic!
Title: Re: New video gadget
Post by: filnet on November 25, 2017, 03:56:37 pm
Thanks muchly filnet :)  Reset GCS with the -reset command line option fixed my problem.  Looks fantastic!

Do you remember, by any chance, if GCS crashed or was killed the first time you used your build ?
Title: Re: New video gadget
Post by: Anonator on November 26, 2017, 12:55:17 am
Yes it did hang...
Title: Re: New video gadget
Post by: karla on December 10, 2017, 05:33:52 am
...
A more mundane use case is to record a video screen capture of your activity in GCS (for showing a bug, making a tutorial or demo-ing a new feature).

Hello filnet, I have a new question:
I have figured out how to do a capture of the whole screen of LP GCS in to a picture file on disk.
Can I capture/save a 5-10 min of the screen activity to a video file as well?
How go about that?
Thanks a lot!

K
Title: Re: New video gadget
Post by: filnet on December 10, 2017, 04:47:40 pm
Can I capture/save a 5-10 min of the screen activity to a video file as well?

Yes, and GCS comes with a few examples. Take a look at the Screen Capture configurations.
Title: Re: New video gadget
Post by: karla on December 13, 2017, 06:39:04 am
Yes! Thank you filnet
The problems I had were all about the MS Media player could not play the video.
It was captured just fine with your default Screen - Capture to file setting.

dx9screencapsrc monitor=0 cursor=true ! tee name=t
    t. ! queue ! timeoverlay ! autovideosink
    t. ! queue ! videoconvert ! x264enc tune=zerolatency tune=zerolatency bitrate=498 ! mpegpsmux ! filesink location=D:\capture.mpg

Then I opened it using VLC app just fine.

 
Title: Re: New video gadget
Post by: filnet on December 13, 2017, 09:55:15 am
Then I opened it using VLC app just fine.

Same here. VLC can play the video while Media Player can't.
Not sure why...
Title: Re: New video gadget
Post by: karla on December 14, 2017, 03:23:54 am
I can live with that.
B t w on my mac, Quick time player is also unable to open the video file.

Sorry to chase you around with questions filet,
but this video gadget is very useful.
My next question:

How to get the PFD information that is overlayed in the video stream to also be captured to the video file?
I understand that currently only the raw video without the overlay gets recorded.
PFD is overlayed and as such is not part of the video.
If possible, it would be a very nice way to document and share flights...
Title: Re: New video gadget
Post by: TheOtherCliff on December 14, 2017, 03:39:51 am
It may be that the PFD is not available in a standard video format.

On Linux, I use a desktop/window/area recorder called Kazam to record things like this.
Title: Re: New video gadget
Post by: karla on December 14, 2017, 08:38:14 am
well, that might very well be an option to use another screen capture software to get all the action in to a video file...
Title: Re: New video gadget
Post by: karla on December 30, 2017, 12:32:26 pm
Yes, it works fine to capture PFD and a Video feed as OSD in to one video with other software!

https://www.youtube.com/watch?v=MvDSUCLri_A

I found a Product test of different free screen recorders here:
http://www.techradar.com/news/the-best-free-screen-recorder

I choosed OBS Studio https://obsproject.com/
Its avaialble for MS, Mac and Linux,
but there are many more.

I put the camera on another vehicle, the heli doesnt have it ready yet, but will soon.
This software seems to handle the sound capture as well.

Title: Re: New video gadget
Post by: micheleamerica on February 18, 2018, 10:56:10 am
Hi
I've compiled my own LP next version on Windows 10 and I've got gstreamer 1.12.4 installed.
When trying to apply the suggestions in this thread I'm able to see the video stream in the Video Gadget but my PFD in video mode shows a gray background instead of the video.
In the PDF video pipeline I've this:
Code: [Select]
intervideosrc ! timeoverlay halignment=left valignment=bottom shaded-background=true font-desc="Sans, 36" ! videoconvert ! video/x-raw,format=RGB ! appsink name=sink emit-signals=true
And in the Video Gadget this:
Code: [Select]
ksvideosrc device-index=1 ! decodebin ! tee name=t
    t. ! queue ! intervideosink
    t. ! queue ! autovideosink
    t. ! queue ! x264enc tune=zerolatency bitrate=498 ! mpegpsmux ! filesink location=capture.mpg
Any help is more than welcome.
Regards
M A
Title: Re: New video gadget
Post by: f5soh on February 18, 2018, 03:30:52 pm
Did you try the pipelines mentioned here (https://forum.librepilot.org/index.php?topic=3649.msg26702#msg26702) ?
You should have 'ksvideosrc' first for PFD, same as Video gadget.
Title: Re: New video gadget
Post by: filnet on February 18, 2018, 07:04:24 pm
Hi michelamerica,

The pipelines you mention should work, and PFD should show video provided the Video Gadget pipeline is started.

Can you provide a log of GCS (by adding "-log log.txt" argument to the GCS command line).

PS: you don't need to install gstreamer as it is provided by msys2. I'd suggest to uninstall it if you don't need it elsewhere.
Title: Re: New video gadget
Post by: micheleamerica on February 18, 2018, 07:49:04 pm
Hi

Here is the gcs log file. I noticed there is an error concerning an empty pipeline:

CRT: VideoWidget::createPipelineFromDesc - "Failed to create pipeline: empty pipeline not allowed"

But when I check the configuration on the GCS both pipelines (Video Gadget and PFD video) are not empty...

Attached the full log file.

Regards

M A
Title: Re: New video gadget
Post by: karla on May 01, 2018, 06:50:56 am
Hello,
I just upgraded to LP Next r711 and have some unexpected Video in the GCS.
https://forum.librepilot.org/index.php?topic=4263.0 (https://forum.librepilot.org/index.php?topic=4263.0)

I now get an unwanted, additional video window, whereas I only had one before in the PFD.
If I close it the video in the PFD also disappears.

(https://forum.librepilot.org/index.php?action=dlattach;topic=3649.0;attach=7473;image)

I have the previous LP Next r589 also installed on the win pc and its unclear to me what GCS settings are actually used. Here is a screenshot of the settings.

(https://forum.librepilot.org/index.php?action=dlattach;topic=3649.0;attach=7475;image)

How to get rid of the extra video window (the smaller one)?
Title: Re: New video gadget
Post by: filnet on May 01, 2018, 07:06:40 pm
Looks like some kind of regression.

Changing the autovideosink to a d3dvideosink (in the USBCamera - Play gadget) should workaround the issue.
Title: Re: New video gadget
Post by: karla on May 02, 2018, 07:29:47 am
Thank you filnet.

Not sure if I did what you suggested, but
I changed the Options settings for gadget Video, USB Camera - Play

from this:

ksvideosrc device-index=0 ! decodebin ! tee name=t
    t. ! queue ! intervideosink
    t. ! queue ! autovideosink

 
to this:

ksvideosrc device-index=0 ! decodebin ! tee name=t
    t. ! queue ! intervideosink
    t. ! queue ! d3dvideosink


It only resulted in no Video dislplay at all, no extra window, but no video in the PFD either :(

FYI, this is the setting for the PDF Video gadget:

intervideosrc ! videoconvert ! video/x-raw,format=RGB ! appsink name=sink emit-signals=true

I checked and the old settings are the same when using r711 as r589 and r589 is still working fine with nice video in PFD. So maybe something changed in this r711 version?
Title: Re: New video gadget
Post by: filnet on May 02, 2018, 08:18:40 am
Hi karla,

Yes, there is a problem in the latest next.
It is due to changes to handle the latest GStreamer version (1.14.0) but unfortunately the packaged next that you are using was built with an older version of GStreamer (1.8.3) and is missing a few GStreamer plugins.

One workaround is to add the missing files manually.

Locate the .\lib\librepilot-gcs\gstreamer-1.0 directory in your r589 install and copy its full content to the corresponding directory in your r711 install.

PS: this is the change that broke video :
https://bitbucket.org/librepilot/librepilot/diff/ground/gcs/src/libs/gstreamer/copydata.pro?diff2=a4c0bcfb1a68&at=next&mode=edit&spa=0&fileviewer=file-view-default
Title: Re: New video gadget
Post by: karla on May 02, 2018, 09:24:20 am
Yes filnet!
It works now
Hero!
Title: New Video Gadget - Hauppauge USB Live 2
Post by: andyp on May 23, 2018, 11:10:11 am
I am trying the last next branch with Hauppauge USB Live 2 and I am not getting it working. USB Camera works fine.

Following console output:

setting pipeline ksvideosrc device-index= 1 ! decodebin ! videoconvert ! autovideosink
starting...
StateChange: element pipeline1 changed state from Null to Ready
StateChange: element pipeline1 changed state from Ready to Paused
NewClock : element pipeline1 has new clock GstSystemClock
Info: element pipeline1 sent info event: Unhandled message (stream-start)
PrepareWindowId: element autovideosink0-actual-sink-d3dvideo prepare window id
Error: element ksvideosrc1 sent error event: failed to start capture (0x0000048f) (../../../gst-plugins-bad-1.8.3/sys/winks/gstksvideosrc.c(963): gst_ks_video_src_create (): /GstPipeline:pipeline1/GstKsVideoSrc:ksvideosrc1:
failed to change pin state to KSSTATE_RUN)
Error: element ksvideosrc1 sent error event: Internal data flow error. (../../../../gstreamer-1.8.3/libs/gst/base/gstbasesrc.c(2948): gst_base_src_loop (): /GstPipeline:pipeline1/GstKsVideoSrc:ksvideosrc1:
streaming task paused, reason error (-5))
StateChange: element pipeline1 changed state from Paused to Ready

Can anyone help?
Title: Re: New Video Gadget - Hauppauge USB Live 2
Post by: filnet on May 23, 2018, 03:25:04 pm
Hi andyp,

Can anyone help?

Most probably some compatibility issue with your hardware.
Can you get video from your hardware using another application ?
Are there ways to configure your hardware and, if yes, what options do you have.

You might also want to google "failed to change pin state to KSSTATE_RUN".

Title: Re: New video gadget
Post by: andyp on May 23, 2018, 11:51:26 pm
No trouble with virtualdub or the application of Hauppauge.