Transparency Apparently

BlitzMax Forums/BlitzMax Programming/Transparency Apparently

dw817(Posted 2016) [#1]
I don't think this is a beginner's question so I am posing it here.

What could be written in BlitzMAX to do two things ?

[1] Display a movie, an Mp4, at a fixed size and location on the screen.

[2] The ability to plot to that screen in BlitzMAX where color R=0, G=0, B=0, bleeds through the video, and any other colors appear as pixels on top.

I'd like to do this so I can build an animated watermark and slider marquee in front of the video.


xlsior(Posted 2016) [#2]
1) IIRC there's some code that uses the VLC playback libraries to draw video to the screen, which should be able to handle .mp4.
(What platform are you talking about here? Windows, Linux, Mac?)

2) Not sure what you mean here, but you can draw whatever you want on top of video, simply by not erasing the background but giving additional drawing statements before the flip.


dw817(Posted 2016) [#3]
I know you can display a video in BlitzMAX, Xlsior. what would be unique is to plot directly above that movie surface in BlitzMAX keeping in mind any non-plotted pixels are transparent and would show the video beneath.

BlitzMAX code of this design would be interesting and likely helpful for others to see and make use of.

For instance, you could play a video from Online and inject SRT directly into it - or inject your own special effects into an Offline video you record and then can re-record with the new effects generated from BlitzMAX, the main reason I would want it.


Hezkore(Posted 2016) [#4]
With Brucey's AVBin module I was able to get each frame of a video as a Pixmap, which I could manipulate any way I wanted.
But AVBin seems to be very outdated now.


Kryzon(Posted 2016) [#5]
When you install the VLC media player you can get the libvlc and libvlccore DLLs to use with this:
http://www.blitzbasic.com/codearcs/codearcs.php?code=3230

Using that code archive as example, you would supply a function pointer to the "unlock" callback of libvlc to do processing, such as converting the decoded pixels of the video frame to a BlitzMax TPixmap.
https://www.videolan.org/developers/vlc/doc/doxygen/html/group__libvlc__media__player.html#gadb157d29493dfc0f89d889603e76aeb9


xlsior(Posted 2016) [#6]
I know you can display a video in BlitzMAX, Xlsior. what would be unique is to plot directly above that movie surface in BlitzMAX keeping in mind any non-plotted pixels are transparent and would show the video beneath.


What do you mean "plot directly above that movie surface"?

Typically, you open a graphics screen or a canvas. you draw the movie frame. As long as you don't FLIP to make the updated screen visible yet, ANY other drawing operations (whether images, lines/pixels/whatever primitives etc.) you draw afterwards before the flip get drawn on top of the movie, and any place where you don't draw you still see the movie. That's it. the video framr would be drawn just like any other image that's part of a scene.

Unless you mean something entirely different, I don't really understand what the problem is here...


dw817(Posted 2016) [#7]
Hi Xlsior:

Here is an example of what I would like to do in BlitzMAX:

Display and animate a movie.

While the movie plays I can draw circles, lines, raster, and text directly on top of the movie screen.



Where "JORDAN DURAM" is plotted by Blitzmax's own DrawText() routine.

It will stay there displayed until you clear the pixels, say with Cls(), which will NOT clear the video frame, just what is plotted on top of it.


xlsior(Posted 2016) [#8]
It will stay there displayed until you clear the pixels, say with Cls(), which will NOT clear the video frame, just what is plotted on top of it.


No way around it -- You will need to redraw the video frame after each and every flip, then draw your own stuff on top of it again. Both the DirectX and openGL specs say that background buffer is undefined after you do a flip, so there is NO guarantee that the background remains...

And even on the computers where the videocard does retain the previous frame, it would have everything including the other stuff you already drew, which you apparently don't want. On some card it would be black, and on other cards it may rewind one, two, three, or even four frames depending on how many backbuffers the videocard drivers use and cycle through internally.

As far as (re)drawing the videoframe:
Here's a snippet from Grable that takes the frame as a pixmap or image with the VLC libraries, which would be trivial to redraw: http://www.blitzbasic.com/codearcs/codearcs.php?code=3230#comments


dw817(Posted 2016) [#9]
Ah that's too bad, Xlsior. That would've been a nice and easy way to introduce special effects and information into an already coded or streaming video.


Kryzon(Posted 2016) [#10]
You do zero research and then give up.
The next time you're wondering why you don't grow in your field, please remember this moment.


xlsior(Posted 2016) [#11]
That would've been a nice and easy way to introduce special effects and information into an already coded or streaming video


I fail to see how a single "draw the video frame!" call before drawing your own stuff on top of it is apparently such a problem.