Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
9th July 2011, 05:49 | #1 | Link |
Registered User
Join Date: Mar 2011
Location: Germany
Posts: 64
|
FLuaG - OpenGL rendering on video stream
After some time of karaoke effect making, tools like VSFilter (WinGDI) and Overlua (Cairo) weren't enough anymore, so the next step should be an OpenGL filter for Avisynth - and here it is.
FLuaG calls scripts in scripting language Lua to render with OpenGL on video frames or modify audio data. Downloads: Github Usage: Code:
FLuaG(clip c, string video = void, string audio = void, bool onscreen = false, bool samples32 = false, string userdata = void)
Todo:
Changelog:
Last edited by Youka; 21st May 2012 at 12:17. |
9th July 2011, 08:27 | #2 | Link |
Registered User
Join Date: Mar 2005
Posts: 366
|
Thank you. Looking forward to tinker with it.
[the download links seems dead atm.]
__________________
DVD slideshow GUI(Freeware). Last edited by tin3tin; 9th July 2011 at 08:30. |
9th July 2011, 10:31 | #4 | Link |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Thanks for the new version, Youka.
Looking through the source code, I've spotted a minor efficiency glitch in GLWindow.cpp: Code:
valid = wglChoosePixelFormatARB(hdc, iAttributes, fAttributes, 1, &pformat, &num); if(!(valid && num >= 1)) //8x AA iAttributes[23] = 8; valid = wglChoosePixelFormatARB(hdc, iAttributes, fAttributes, 1, &pformat, &num); if(!(valid && num >= 1)) //4x AA iAttributes[23] = 4; valid = wglChoosePixelFormatARB(hdc, iAttributes, fAttributes, 1, &pformat, &num); if(!(valid && num >= 1)) //2x AA iAttributes[23] = 2; wglChoosePixelFormatARB(hdc, iAttributes, fAttributes, 1, &pformat, &num); Last edited by Gavino; 9th July 2011 at 11:21. Reason: use narrower code window |
9th July 2011, 12:15 | #5 | Link |
Registered User
Join Date: Mar 2011
Location: Germany
Posts: 64
|
Arg, you're right. Tried in past with a computer without graphic card, so i didn't noticed it + forgot in my last check the GLWindow class ^^"
Will add brackets immediatly! Thx for reporting. Last edited by Youka; 9th July 2011 at 12:21. |
13th July 2011, 15:37 | #6 | Link |
Registered User
Join Date: Mar 2011
Location: Germany
Posts: 64
|
Version 0.3 released.
There're just 2 small changes.
Code:
glMatrixMode(GL_TEXTURE) glLoadIdentity() glMatrixMode(GL_PROJECTION) glLoadIdentity() glMatrixMode(GL_MODELVIEW) glLoadIdentity() glViewport( 0, 0, flGetVideoWidth(), flGetVideoHeight() ) glClearColor(0, 0, 0, 0) glClearDepth(1.0) glClearStencil(0) glClearAccum(0, 0, 0, 0) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_ACCUM_BUFFER_BIT) local frame = --Gets video frame pixels glDepthMask(false) glDrawPixels(flGetVideoWidth(), flGetVideoHeight(), GL_RGBA, frame) glDepthMask(true) --Calls registered functions from user in right order!!! frame = glReadPixels(0, 0, flGetVideoWidth(), flGetVideoHeight(), GL_RGBA) --Sets video frame pixels (frame) Added a small example how to make karaoke effects. Advanced creations of me i cannot post here or upload to YT regrettably because of music and video material Documentation just reaches until OpenGL 1.1, but 1.3 is available. Documentation is more work than the source, so it will take some time, but will continue it. Because of the plan to allow audio access: Video and audio runs in 2 threads, so i cannot bring it together in one function. Another developer used ffmpeg for loading audio data separatly... will think about it. Last edited by Youka; 13th July 2011 at 16:25. |
13th July 2011, 17:40 | #7 | Link | |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Quote:
Code:
if(CheckMultisampling()) { ... //Set pixel format SetPixelFormat(hdc, pformat, &pfd); //My OpenGL context to current window cx = wglCreateContext(hdc); } |
|
14th July 2011, 04:39 | #8 | Link | |
Registered User
Join Date: Mar 2011
Location: Germany
Posts: 64
|
Quote:
(always the GLWindow part, ~grrr~) Last edited by Youka; 14th July 2011 at 08:53. |
|
14th July 2011, 10:15 | #9 | Link | |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Quote:
Incidentally, the reason I was so quick to spot this issue (and the previous one) is that I am working on something similar (without Lua) for my own purposes, and I had already made a similar change (create the context only once) in my own code. Other points which you might find helpful: - Some graphics cards/drivers (like my laptop!) will not render to an invisible window. You can use a pbuffer context (where supported) to avoid this problem. - Instead of copying to and from an intermediate buffer when passing pixel data between Avisynth and OpenGL, you can use glPixelStorei(GL_[UN]PACK_ROW_LENGTH, pitch/4) with a format of GL_BGRA_EXT in glReadPixels and glDrawPixels. (This probably makes your PixelHandler class redundant.) |
|
14th July 2011, 11:24 | #10 | Link | |||
Registered User
Join Date: Mar 2011
Location: Germany
Posts: 64
|
Quote:
Quote:
Quote:
|
|||
14th July 2011, 11:49 | #11 | Link | ||
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Quote:
Quote:
Last edited by Gavino; 14th July 2011 at 11:53. |
||
19th July 2011, 11:54 | #12 | Link |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Revisiting this, it occurs to me that the reason you are seeing this could be multithreading. The OpenGL context is specific to a single thread, but depending on your encoder (or if using a MT version of Avisynth), GetFrame() may be called from a different thread than the constructor.
|
12th November 2011, 13:23 | #13 | Link |
Registered User
Join Date: Jan 2008
Posts: 17
|
FLuaG x64 v0.5
Updated v0.5 x64 build: FLuaG64.dll v0.4 FLuaG64.dll v0.3 I've compiled FLuaG v0.3 for AviSynth64 (MSVC++ 10): FLuaG64.dll The source code is almost the same, just converted inline ASM to intrinsic functions for MSVC to compile fine in x64. Replace PixelHandler.h in the Source folder and libs\Lua_5.1.4_static.lib with a suitable Win64 VC lib from here: Lib for MVSC++ 10 Last edited by EmuAGR; 14th December 2011 at 21:53. |
22nd November 2011, 21:50 | #15 | Link |
Registered User
Join Date: Jul 2010
Posts: 4
|
You are awesome Youka! This opens worlds of possibilities for AviSynth.
I am especially looking forward to fragment shader support. Multiple inputs would be nice too, but I imagine, one workaround would be StackVertical() for video... |
24th November 2011, 08:07 | #16 | Link |
Registered User
Join Date: Mar 2011
Location: Germany
Posts: 64
|
FLuaG 0.4 release (see first post).
|
25th November 2011, 19:50 | #19 | Link |
Registered User
Join Date: Mar 2005
Posts: 366
|
Truely great work Youka! Very nice with all the included examples, but why did you leave out your previous 3D OpenGl examples?
I've got to investigate further myself, but is it possible in this version to make video 3D transitions over a video background?
__________________
DVD slideshow GUI(Freeware). |
26th November 2011, 13:09 | #20 | Link |
Registered User
Join Date: Mar 2011
Location: Germany
Posts: 64
|
My old examples are all rewritten and included into the new ones, so there's nothing missing except the video cube.
Making a video 3D transition over a video background won't be a problem but it might be you mean working with more than one video stream. That will come with clip array input to FLuaG soon, but for now you have to use some tricks. |
Thread Tools | Search this Thread |
Display Modes | |
|
|