Openfl.media.Video

Sorry about the delay! When testing this on mac I received the following error when doing lime rebuild mac

Do you know what might be causing this?

It seems that Iā€™m linking with my own cpp SDL (and probably OpenAL) headers instead of those in project folder. But I run into a problem I cannot solve - generally it seems that openfl doesnā€™t work with SDL textures (I couldnā€™t find any linkage with lime.ndll functions that operates on SDL Textures and updates SDLRenderer :confused: Generally I hardly understand anything from graphic part of openfl :smiley: )
I think I could extract pointers to yuv planes for implementing shader functionality, but I donā€™t know shaders yet. So for now Iā€™ll leave it again :confused:

And for error -> try cutting SDL2, and leave <SDL.h> in OGV.h

From the other hand - do You know a method of fast swapping rgba pixels of OpenFl Sprite? Could this be done easily (or - could it be done at all?) ā€¦ ?

Hey, just checking in to say Iā€™m still here, and very excited about progress.

Please keep us up to date, and thank you very much for your efforts!

1 Like

jeah swaping pixels on a sprite can be done and seems to be reasonable in terms of performance. This post should give you an idea how to do it. Up till now this has been working fine for me playing back videos.

Hi, sorry for not responding for so long. I think I guess Iā€™m starting to nail the problem down :wink:
Here is link to zip file (zipped under linux, so on Windows You could open it with 7-zip probably, not the system zip):


ā€“edited:
here was a link to a version in which openfl was in openfl/3.6.1/3.6.1 dir(double 3.6.1). fixed in new link
ā€“end

in lime folder there is my full lime source
openfl - full openfl source
pong folder -> first few lessons from haxecoder pong intro, with video usage.

Generally video works (at least on my machine), so if Youā€™ll be able to setup folders correctly (haxelib could find lime and openfl folder from this zip), compile lime (on my machine it works, but I fixed a <SDL/sdl.h> missing file also) and compile test app, it should play Big Buck Bunny.

Generally there is plenty of stuff to do, like switch opening movie from FILE* to lime::file in OGV.cpp (which maps to SDL_RWops* , so it could work on android also), removing duplicated music code (Iā€™m using vorbisfile to manage video music -> it uses intrinsics if itā€™s possible, so itā€™s faster than manually switching floats to chars while filling OpenAl audio buffers), handling decoupled code (playing video need to know about SDL_Renderer, music needs to know about OpenAL, etc), and linking c with haxe.

I avoided copying data into sprite by extending Sprite itself, and overriding __renderGL method -> if video is added to stage, it should be handled automatically. But there should be nothing else on stage - if there is, video will be hidden (?!).

If Youā€™ll have trouble with compiling this, Iā€™ll try to help :slight_smile:

2 Likes

Hmm, anyone tried to compile lime? Any errors with inclusion files?

Paging @JayMaxArmstrong

Ymmā€¦ By this You mean that You have the same problem as @JayMaxArmstrong with sdl include file?

Ah, and In zip there is lime 2.9.1 and openfl 3.6.1.

Nono, I just canā€™t test this right now and was calling him to the thread as heā€™s interested too :slight_smile:

Iā€™ve started a git repo for this.


It could be easier to check code this wayā€¦

Version on git has decoupled renderer and audio from videodecoder -> but at the cost of just decoding video now, without frame time checking and without sound :confused:

2 Likes

Iā€™m sorry to bring this up again so much time later, but did you get webm working with openfl next? Iā€™ve managed good quality/memory/performance by removing sound code from the cpp interface (which contained a memory leak, afaik), but on legacy, and canā€™t get it to do properly on -Dnext (using openfl 3.6.1 because flixel :confused: ).

(Also paging @singmajesty because this seems to be reaching a level of maturity that might interest him)

For anyone googling this thread, this is my fork of the lib.

1 Like

Iā€™ve updated repo, test project with movie should be played with correct time, with proper scaling, but without voice :confused:

I manage to test it on Windows - got green screen; seems that it works just for linux now (maybe mac also).
And probably the only option would be to do the OpenGL shader stuff, becouse SDL draw texture dont work on win :confused:

#####edit:

@MikeEvmm there is libyuv in webm packet, maybe You could use it in your library tests, it could speedup conversion to rgb (but as far as I remember I got poor performance from this library, poorer than from SDL draving YUV texture directly). Other option is, like Joshua suggested - get yuv planes and strides into haxe and draw it with shader (but it could be also time eater - for 1000x1000 px there will be 6mb1,5mb of data passed to gpu every frame :confused: generally in e.g. vlc player, code for handling yuv->rgb conversion works on cpu).
And, from the other hand, how do You handle audio? AFAIK container for webm is simplified version of matroska, and every lib I could find for handle this were GPLā€™ed :confused:
I saw You are including ogg headers, so You are decoding sound. Could You share how are You extracting music from webm videofile?

And I got windows version working - I got errors in tools.n file (ā€œlime managerā€ is uploading bad libraries into bin directory. I messed up my project hx files :smirk: and it will take time to clean it up (now I dunno whatā€™s happening there :frowning:) .

2 Likes

Iā€™m not decoding sound at all! In fact, I know very little about video decoding and cpp extentions ā€“ I just removed all code related to sound in the webm library @soywiz made to stop a memory leak that was hiding somewhere. (Since audio decoding was not working anyway)

Regarding YUV to RGB conversion, I see no reason to convert to RGB; to write YUV directly using SDL seems like the best option.

Ah Yes, You wrote that before :slight_smile:
Okay, in original lib thereā€™s header for mkv decoder with proper links, thank You;)

#####edit:
I made changes to windows version, so hopefully it should work. unfortunately first thing after cloning should be run lime/tools.hxml file for now.

#####edit:
Windows VS2010 now works -> I compiled lime and testapp with visual studio EE 2010 32 bit, usind SDL_textures. Movie is shown, but as You could see -> while changing window size opengl context is frozen, and it looks crappy.
Mingw sometimes work (but I think it depends of MinGW version being used -> some versions broke debugger even on simple int main(){printf("%d",1);return 0;} , so its a lottery I guess), android ā€œshouldā€ open movie file, but it does not render (logcat shows movie values correctly - width and height).
Linux works for 64 and 32 bits.

1 Like