Not been that busy lately this time

I had 2.5 days carried over for holidays so I took a long weekend off beginning half day on Friday. All to go for long rides with the missus on our motorbikes. And she was very happy because she has only been riding for almost a month now.

Anyway, documents have been written up towards this project and a very important document that I created regarding it from about six years ago needs altering. No database plan has been setup yet until the spreadsheets are finalised. Number crunching has been pretty good.

At the moment I have four sample videos created, although I need a lot more, to which a demonstration setup can be made. When all the sample videos have been produced, they will range through all categories of businesses.

My Intel tiny PC turned up and I am not disappointed. I may as well stick to 30 frames per second instead of 60 as the current videos play perfect. I’ve got it to boot up in Linux and auto run my software to play the videos on a loop. No screen tearing and running all over these last four days.

Over the next one to three weeks I should have the server infrastructure in place where I can live test my new system. As mentioned above, the documentation has been more of an important matter over this weekend off when I’ve had the time. The infrastructure will include storage, database solutions, communications, security protocols and a users interface to the server.

Throughout this entire project I’ve kept to a strict diet of royalty free and open source. In the future, the software I have used will get donations.

PS…

The initial test was a single ‘cpp’ program which links to ‘libvlc’ and ‘X11’ which opens a full screen window and attaches each instance being played to the full screen window. Now it gets complex. (not really)…

I have been busy actually

Saturday and Sunday I was faffing about with my Odroid U3 trying to get various API’s to play full screen videos on Linux but kept coming up against a brick wall because those API’s are for openGL and not openGL ES. Only Android would do that and I do not want to go down that route. So instead of buying the Odroid C2 which was my original plan I’ve ordered myself an Intel board instead. Can’t wait for it to turn up. The weekend dragged with all the testing and testing.

Tonight I decided to get a spreadsheet together. Being on the extremes of pessimism, the figures still look damn good. It’s given me a positive frame of mind to move on. I will be expanding on the spreadsheet a hell of a lot as this is the first set of figures I’ve started to work with. I plan on getting a full set of test data to start with to get the numbers down to the penny. I’ve still got to price up servers, etc.

Then I got another quick blast at blender. Two things I wanted to get working, alpha transparency for PNG images and playing a video clip in a texture. Yes, I can do them both. And boy, it’s looks good as a 3D rendered movie with transparent images and movie clips playing.

Libvlc and my Odroid

Before I go ahead and actually buy the Odroid C2, I thought I’d dig out my U3 and try the vlc library on that. All I had to do was to copy the project folder over SSH to it and build it. At first it didn’t compile because I needed to install the X11 dev files, and then again I had to install the libvlc-dev files. And then it built just fine.

Major problem though, VLC doesn’t have hardware acceleration on any of the Arm processors yet.

Well, now it looks like I’ll either go down the Qt route, FFMpeg route, OGV decoder route, or find another player library.

One thing I do know is that I’d like to stick to a single video format, ie OGV. So that makes writing my own player easy enough.

My next step is to get a player working by myself and make it work on the Odroid. I’m going to see about the OGV sources before checking out other open source players.

I’ll keep you posted.

 

Fullscreen video playlist done

Using Linux and libvlc I’ve finally got what I was aiming for. A full screen video playlist player. And it was quite easy.

The steps to get here:

  1. Monday: Play a media file. A few lines of code did this. And with the addition of one extra line of code made it full screen.
  2. Play a playlist of videos full screen. This is where things went wrong. After one video had finished, the vlc player would quit fullscreen, flash the desktop and then play the next video in full screen. This was not acceptable.
  3. Tuesday: Using the stock Linux libraries to go full screen. This took all of about 20 minutes from start to end. And again, in just a few lines of code. It was a chaotic night at home so I just finished up there.
  4. Wednesday: Just chilled out and watched TV after work instead.
  5. Thursday: I now needed to use the full screen window and attach the videos to it so that the desktop doesn’t appear. By just passing the window ID to the vlc media player, this was done.

Now all I need to work on the managing the playlists over the internet. And order myself and Odroid C2 with a few other gadgets. So far, this is going 100% perfectly.

By my reckoning, I should have a media player that boots up in less than 10 seconds and playing. How awesome…

The hefty part of the coding is about to start…

Linux X11 full screen

Wow! Just how easy was it to have a full screen window in Linux?

In windows, you had to include a shed load of libraries and link to them. In Linux you just link to X11, one or two parameters, and that’s it.

All I required was a basic window that I could attach the VLC player to, similar to any 3D API requirements, so that I could bypass VLC switching from full screen to desktop all the time. And all in 20 lines of code, not obfuscated, and one instruction per line, with a while loop for a pause, I got it. Windows couldn’t do that. It would take, erm, lots of, erm, junk to do it. erm 😉

Again, not a lot of time tonight to do stuff, so by the time I came round to getting this done, I thought I might as well set a target for this step to be done by tomorrow night. Now it looks like tomorrow night I can attach VLC to play a playlist.

See what happens tomorrow if chaos don’t arise.

libVLC and fullscreen

Okay, so I was successful with getting libVLC to play a video in full screen in just a few lines of code. This was a great success. However, when using a play list, each item is shown in a window.

Tonight I haven’t the time to set up a full screen window and attach libVLC to it, so I will try that tomorrow. There’s tons of Linux windowing API’s I can use. Just a standard X11 window will be fine as there will be no user input at all.

It’s no use having a black background as a desktop as some videos will end with a different coloured background.

Ah well. Plod on tomorrow. Almost there.

If I fail then it will be a minimal build of ffmpeg or maybe just the OGV libraries and I will write a player myself which will take a tad longer than I wanted.

Sample C code on Linux:

#include <X11/X.h>
#include <X11/Xlib.h>
#include <strings.h>
#include <memory.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

extern "C" {
#include <vlc/vlc.h>
}

const char *files[] = {
	"/media/wlgfx/WLGfx/WLGfxMedia/2017July/WLGfxJul/wlgfx.ogv",
	"/media/wlgfx/WLGfx/WLGfxMedia/2017July/sample1/sample.ogv"
};
const int files_count = 2;

void play_media(libvlc_instance_t *inst, const char *uri, uint32_t win) {
	libvlc_media_t *m = libvlc_media_new_path(inst, uri);
	libvlc_media_player_t *mp = libvlc_media_player_new_from_media(m);
	libvlc_set_fullscreen(mp, 1);
	libvlc_media_player_set_xwindow(mp, win);
	libvlc_media_player_play(mp);
	sleep(1); // enough time to start
	while (libvlc_media_get_state(m) == libvlc_Playing) usleep(200);
	libvlc_media_release(m);
	libvlc_media_player_release(mp);
}

int main() {
	Display* dis = XOpenDisplay(NULL);
	Window win = XCreateSimpleWindow(dis, RootWindow(dis, 0), 0, 0, 10, 10,
			0, BlackPixel (dis, 0), BlackPixel(dis, 0));

	Screen *screen; // get screen size
	screen = ScreenOfDisplay(dis, 0);
	int dwid = screen->width;
	int dhgt = screen->height;

	Window root; // position mouse to bottom left (hide it)
	root = XRootWindow(dis, 0);
	XSelectInput(dis, root, KeyReleaseMask);
	XWarpPointer(dis, None, root, 0, 0, 0, 0, dwid, dhgt);
	XFlush(dis);

	XInitThreads();

	Atom wm_state = XInternAtom(dis, "_NET_WM_STATE", False);
	Atom fullscreen = XInternAtom(dis, "_NET_WM_STATE_FULLSCREEN", False);

	XEvent xev;
	memset(&xev, 0, sizeof(xev));
	xev.type = ClientMessage;
	xev.xclient.window = win;
	xev.xclient.message_type = wm_state;
	xev.xclient.format = 32;
	xev.xclient.data.l[0] = 1;
	xev.xclient.data.l[1] = fullscreen;
	xev.xclient.data.l[2] = 0;

	XMapWindow(dis, win);

	XSendEvent (dis, DefaultRootWindow(dis), False,
		SubstructureRedirectMask | SubstructureNotifyMask, &xev);

	XFlush(dis);

	printf("XWindow initialised with threading enabled\n");

	libvlc_instance_t *vlc_instance = libvlc_new(0, NULL);

	printf("Playing media files in vlc attached to window\n");

	uint32_t id = (uint32_t) win;

	play_media(vlc_instance, files[0], id);
	play_media(vlc_instance, files[1], id);
	play_media(vlc_instance, files[0], id);
	play_media(vlc_instance, files[1], id);

	libvlc_release(vlc_instance);

	printf("Hopefully all was successful\n");

	return 0;
}

Blender and Python and VLC

Since getting home on Friday after work, I had a plan.

  1. Figure out the animation and timeline in Blender. I’ve done this. I can now rotate, translate, scale and modify objects on the timeline. As well as texturing, particles and other things useful for animations. I’ve still yet to show video in a texture, but that looks a doddle.
  2. Play animations (for testing) from the ‘.blend’ file. This was a bit fiddly as I had to use the Blender Game Engine and all the animations I had done for each individual objects, I had to add in the ‘BGE’. The Blender player works fine with the ‘.blend’ files with many exceptions. There’s a lot that Blender can do that the player doesn’t handle. A simple one is the morphing of an object. Which rules out a hell of a lot of Blenders stuff.
  3. Blender rendering videos. Awesome this one. It will render videos to OGV format. All effects included, or at least I hope so. I’ve rendered a 15 second video many times on my laptop in the background (it is an i7) and I can still get on with other stuff. This will be much quicker on my PC, but my laptop is darn fast as is.
  4. Use Bash or another scripting language to play the videos because the Blender player, although fast and smooth, doesn’t do everything. I’ve been successful with Python and the VLC plugin for it, so I now know I can use the VLC library to play these files. I’m still beginning with Python, but it did show me how easy the VLC library is to use.

Although I’ve made sure I’ve put time out to get out this weekend just to keep myself in a good mood, this progress has been great.

It’s a long learning curve with Blender, but at the moment, I can make use of it to do 90% of what I need it for. 30 frames per second with a medium 3D scene was taking on my laptop 2.0 seconds per frame to render at 1920 x 1080. And 15 seconds of full quality is about 12Mb.

The framework around all of this will be a WIP from today and it is going to be so awesome even I can’t wait.

The next stage for me will be integrating custom engines to produce these animations better then the Blender player without the need to render video files.

Back to Blender… See y’all soon…

Parallax3D WebGL

This is proving to be easier than I thought.

The Eclipse GWT project was setup. The parallax3D jar library added. A test AnimatedScene class with some basic geometry tests done. Spin a few of them around.

That’s me done for tonight. Got work in the morning.

I’m hoping I can load in Blender models, or even .OBJ models. If not, I’ll figure something out. Also 3D text I need.

No screeny yet cos of screen tearing.

VPS and WebGL project

Tonight I had a full on plan to get my own VPS (Linux based) and setup a Tomcat server ready for my WebGL personal project showcase. I’m planning on porting some old school samples from years ago from both IrrLicht and Dark Basic Pro.

So far, I’ve not made a start as the missus passed her CBT today (Motorbike Compulsory Basic Training) and she is way over excited.

VPS and Tomcat are still in progress.

I also plan on studying this WebAsm too for much faster rendering.

To start with I will be using Parallax3D for GWT which I’ve played around with a few times before. I finally decided on Parallax3D after giving up on LibGDX (which is very good and easy), and CopperLicht (which I don’t like using Javascript).

If it chills out tonight, which is highly unlikely, then I’ll make a start.

WebGL 3D

After faffing about with CopperCube and CopperLicht, which is fun to play around with, I’ve found it quite restricting for the type of demonstrations that I want to do. So I’ve decided to head on back to Parallax3D, bypassing the urge to play with LibGDX again.

The reason for dumping CopperLicht is simple. I don’t like Javascript at all. With GWT, it is rare I need to use JSNI with it.

LibGDX is good but each LibGDX project has to be a complete GWT module in itself, which means copying over all the GWT stuff again. It probably is likely that I could integrate it into a GWT project and I might try it at some point.

However, Parallax3D just appears to have everything and is a simple Jar file which is added to a GWT project.

So… It’s finding out what mesh files (hopefully wavefront OBJ’s as well) and I’ll be up and running if the weather is bad this weekend.

I also need to FTP this site as my homes Sky router isn’t working with the DNS service.

Enough of this. Time to setup a project on my lappy.