Hello_Video + overlay

Anything and everything about programming graphics with Ultibo
Gavinmc42
Posts: 1422
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Hello_Video + overlay

Postby Gavinmc42 » Thu Aug 02, 2018 7:32 am

Been spending the last two days fixing/modifying a Raspbian/Netbeans/Java project from years ago.
Basically overlaying instrument data as text/OpenGLES over a video.
A dashboard cluster on a exercise bike.

Was checking the Videocore examples, wow, Hello_video just worked.
Used ffmpeg to convert the big old mp4 to h264, that just worked too :shock:
Time to test this < 1 hour, previous Netbeans Java project was weeks.

So how to overlay some OpenVG stuff onto the video?
Anyone got an idea?

I think it might take me a few more years before I learn everything about Ultibo 2.0 ;)
pik33
Posts: 795
Joined: Fri Sep 30, 2016 6:30 pm
Location: Poland
Contact:

Re: Hello_Video + overlay

Postby pik33 » Thu Aug 02, 2018 11:54 am

These are dispmanx objects. Create a dispmanx layer over your video layer and display any stuff on it.
User avatar
Ultibo
Site Admin
Posts: 2081
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Hello_Video + overlay

Postby Ultibo » Thu Aug 02, 2018 12:16 pm

Gavinmc42 wrote:So how to overlay some OpenVG stuff onto the video?
Anyone got an idea?

There are three items you need to deal with to get OpenVG output overlaid on a video.

1. Setup OpenVG to use transparent background, we covered that one here.

2. Make the video run in a separate thread so your main thread is free to do OpenVG drawing, this should be as simple as taking the hello_video example and using the techniques shown in the multi threading example to create a thread that calls hello_video instead. Since all of the Syscalls and C library interfaces are thread safe there shouldn't be any problem doing this.

3. Set the DispmanX layer number for OpenVG to be higher (?) than the MMAL layer so it will display on top of the video. There are a bunch of posts on the Pi forum that talk about setting the DispmanX layer numbers etc (can't find any one them right now!), from memory I think it is to do with vc_dispmanx_element_add or one of those functions.
Ultibo.org | Make something amazing
https://ultibo.org
Gavinmc42
Posts: 1422
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: Hello_Video + overlay

Postby Gavinmc42 » Fri Aug 03, 2018 1:40 am

Thanks guys, I will try those, still more to learn about these Pi's ;)

ffmpeg works :D
530MB mp4 file is a 260MB h264.
This size file takes 5 secs to boot, still much faster than Raspbain/Java ;)

Am I right in that the current SDcard driver is not optimized for speed yet?

9 hours to fix the old code, 1 hr to test if it will work on Ultibo.
That is a typical ratio for me Linux to Ultibo when learning.
When I actually know how to use Ultibo it gets down to minutes to fix stuff.
Gavinmc42
Posts: 1422
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: Hello_Video + overlay

Postby Gavinmc42 » Fri Aug 03, 2018 4:42 am

Got two long videos in a forever loop :D
If I did this with Linux/python etc I would have memory leaks and crashes.

Since this is on a pedal bike and is powered by the generator, not many people will pedal for days ;)
Once people stop pedaling power goes off and memory leaks disappear :lol:
pjde
Posts: 425
Joined: Tue Feb 09, 2016 6:21 am
Location: Sydney, Australia

Re: Hello_Video + overlay

Postby pjde » Fri Aug 03, 2018 5:41 am

There is an example on how to do this in Jan Newmarch's book Raspberry Pi GPU Audio Video Programming.

Regards

Paul
Gavinmc42
Posts: 1422
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: Hello_Video + overlay

Postby Gavinmc42 » Fri Aug 03, 2018 5:58 am

There is an example on how to do this in Jan Newmarch's book Raspberry Pi GPU Audio Video Programming.

And Andrew from Melbourne

Those VC4 hello examples are useless?
Time to go back to C and get my head around how this work.

I found the problems with playing with these bit of VC4 C code is it is very easy to break the code and hard to fix.
In fact I have zero idea on how to debug VC4 code when this C code gets converted to Pascal.
hmm does the start_db.elf help?

Need to check to see if HDMI audio works for sound, only using a DVI monitor at the moment.
Gavinmc42
Posts: 1422
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: Hello_Video + overlay

Postby Gavinmc42 » Fri Aug 03, 2018 7:25 am

Garry, the Videocore Hello_Pi examples have a lot of libxxx.a files.
I assume these are compiled C files?

If I want to modify them or use other C files, how do I make them?
viewtopic.php?f=16&t=449
Seems like a lot of work. ;)

Would it not be better to convert all the Hello_Pi examples to pure Pascal?
Probably even more work?
pik33
Posts: 795
Joined: Fri Sep 30, 2016 6:30 pm
Location: Poland
Contact:

Re: Hello_Video + overlay

Postby pik33 » Fri Aug 03, 2018 9:43 am

If I want to modify them or use other C files, how do I make them?


The simplest way: having a Raspbian on your RPi, compile your .c to .o using gcc, then make .a out of .o using ar. You have these tools ready in Raspbian.
I compiled my mp3 and module player library in this way. They were written for Raspbian so I had to edit them and remove all linux related stuff, for example writing debug to stderr and another useless and not implemented in Ultibo function calls.
Gavinmc42
Posts: 1422
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: Hello_Video + overlay

Postby Gavinmc42 » Fri Aug 03, 2018 10:47 am

The simplest way: having a Raspbian on your RPi

Thanks pik33, been so long since I used Raspbian I forgot the obvious :lol:

Return to “Graphics”

Who is online

Users browsing this forum: No registered users and 0 guests