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.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 25th February 2009, 12:59   #1  |  Link
tin3tin
Registered User
 
tin3tin's Avatar
 
Join Date: Mar 2005
Posts: 366
OpenGl in Avisynth!

Here it's descriped how to use OpenGl in Avisynth. Youtube example here.

Unfortunately there is no downloadable plugin file, but the whole idear of adding OpenGl to Avisynth sounds great. Maybe someone with the right plugin writing skills could be inspired to take this even further?

(I know... one of these days I need to take the leap into plugin writing myself).
__________________
DVD slideshow GUI(Freeware).

Last edited by tin3tin; 5th March 2009 at 13:32.
tin3tin is offline   Reply With Quote
Old 25th February 2009, 13:32   #2  |  Link
Leak
ffdshow/AviSynth wrangler
 
Leak's Avatar
 
Join Date: Feb 2003
Location: Austria
Posts: 2,441
Quote:
Originally Posted by tin3tin View Post
Unfortunately there is no downloadable plugin file, but the whole idear of adding OpenGl to Avisynth sounds great. Maybe someone with the right plugin writing skills could be inspired to take this even further?
Well, OpenGL is just a rendering API that by itself doesn't do anything in particular. The blog entry lists code for an AviSynth filter to set up OpenGL to work on the frames the filter gets from AviSynth and how to return back the processed frames, but it's not doing any filtering per se - so it's just a building block, but no full filter.

np: Gold Chains & Sue Cie - Show Us Your Heart (When The World Was Our Friend)
__________________
now playing: [artist] - [track] ([album])
Leak is offline   Reply With Quote
Old 25th February 2009, 15:01   #3  |  Link
tin3tin
Registered User
 
tin3tin's Avatar
 
Join Date: Mar 2005
Posts: 366
Do you think that this is a valid/okay way to add 3D manipulation of clips in Avisynth? (I guess the glut stuff can't be included in a plugin, and it might be a bit dated?) Or do you think there are better ways?
__________________
DVD slideshow GUI(Freeware).
tin3tin is offline   Reply With Quote
Old 5th March 2009, 10:38   #4  |  Link
tin3tin
Registered User
 
tin3tin's Avatar
 
Join Date: Mar 2005
Posts: 366
From simple scenes in Blender3D to OpenGL C / C++ code

Another interresting thing in this line of thought here.

This is a Blender 3D .py script which can make Blender 3D export to a OpenGl friendly format(For every scene exported, a corresponding .C and .H file is generated).

I imagine that this combined with the stuff above it would be possible to use Blender 3D for making 3D transitions in Avisynth.
__________________
DVD slideshow GUI(Freeware).
tin3tin is offline   Reply With Quote
Old 14th September 2009, 18:39   #5  |  Link
tin3tin
Registered User
 
tin3tin's Avatar
 
Join Date: Mar 2005
Posts: 366
Roy has released the sourcecode:
http://www.morethantechnical.com/200...-for-avisynth/
__________________
DVD slideshow GUI(Freeware).
tin3tin is offline   Reply With Quote
Old 28th January 2010, 11:44   #6  |  Link
tin3tin
Registered User
 
tin3tin's Avatar
 
Join Date: Mar 2005
Posts: 366
Quote:
Roy has released the sourcecode:
http://www.morethantechnical.com/200...-for-avisynth/
I've tried several times to get this to work - but still unsuccesful. Could I get one of you C++ enlighted people to check if this code is working, and if it does give me a few pointers on how to make more 3D transitions this way in C++/Avisynth?
__________________
DVD slideshow GUI(Freeware).
tin3tin is offline   Reply With Quote
Old 6th May 2011, 02:15   #7  |  Link
Youka
Registered User
 
Youka's Avatar
 
Join Date: Mar 2011
Location: Germany
Posts: 64
This thread is old, but maybe someone helps this.
Create this object in your plugin constructor, use InitGL at beginning of GetFrame and CloseGL at the end. Destroy object in plugin destructor.
No need for GLUT.

Works for me in my plugin avisynth + opengl + lua (similar to Overlua).
Youka is offline   Reply With Quote
Old 7th May 2011, 18:15   #8  |  Link
tin3tin
Registered User
 
tin3tin's Avatar
 
Join Date: Mar 2005
Posts: 366
Looks very interesting, but I'm pretty ignorant when it comes to c++.
__________________
DVD slideshow GUI(Freeware).
tin3tin is offline   Reply With Quote
Old 12th June 2011, 15:15   #9  |  Link
Youka
Registered User
 
Youka's Avatar
 
Join Date: Mar 2011
Location: Germany
Posts: 64
Quote:
Originally Posted by Youka View Post
Works for me in my plugin avisynth + opengl + lua (similar to Overlua).
See here. It's just at the beginning but enough.
Youka is offline   Reply With Quote
Old 12th June 2011, 15:40   #10  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
Can't wait to try it out. Could you make your plugin open source so we can learn from it?
Wilbert is offline   Reply With Quote
Old 12th June 2011, 17:07   #11  |  Link
tin3tin
Registered User
 
tin3tin's Avatar
 
Join Date: Mar 2005
Posts: 366
Wow, looks brilliant! This must have taken a lot of time to code! Nice examples

Is it possible to process two videoclips in the lua script - for making transitions? Or devide a clip into two clips and make a transition between them?
__________________
DVD slideshow GUI(Freeware).

Last edited by tin3tin; 12th June 2011 at 19:26.
tin3tin is offline   Reply With Quote
Old 12th June 2011, 18:54   #12  |  Link
Youka
Registered User
 
Youka's Avatar
 
Join Date: Mar 2011
Location: Germany
Posts: 64
It's an avisynth plugin because it should use avs functions, like video splitting and merging, too. You can use FLuaG one time for saving video frames to .tga picture files and next round to use this pictures as video sequence or textures in another FLuaG call with another video.
Youka is offline   Reply With Quote
Old 12th June 2011, 19:30   #13  |  Link
tin3tin
Registered User
 
tin3tin's Avatar
 
Join Date: Mar 2005
Posts: 366
I'm trying to look into the Gl functions.

Just a quick question: Is it possible to use a video as a texture on ex. a 3d box?

What do you use for testing the lua scripts(as you wrote somewhere AvsP crashes with there are errors in the Lua script)?
__________________
DVD slideshow GUI(Freeware).

Last edited by tin3tin; 12th June 2011 at 19:33.
tin3tin is offline   Reply With Quote
Old 12th June 2011, 20:52   #14  |  Link
Youka
Registered User
 
Youka's Avatar
 
Join Date: Mar 2011
Location: Germany
Posts: 64
Save a video as .tga pictures and use picture-for-picture as texture for all cube sides - yes, it's possible.

For testing, i'm using AvsP but are careful. MPC hasn't this problem, because it allows error throwing during rendering too (AvsP just at the initialization of the plugin, bad programming fail).
Youka is offline   Reply With Quote
Old 13th June 2011, 00:17   #15  |  Link
tin3tin
Registered User
 
tin3tin's Avatar
 
Join Date: Mar 2005
Posts: 366
Quote:
Save a video as .tga pictures and use picture-for-picture as texture for all cube sides - yes, it's possible.
That's proberly going to take me some time to figure that stuff out. I guess it's not possible to just add the video to the memory and use it from there(would be faster)? Does this make any sense to you?(I have no clue)

Are there any tutorial/examples on that process you mention of working with video on 3d objects?
__________________
DVD slideshow GUI(Freeware).
tin3tin is offline   Reply With Quote
Old 13th June 2011, 22:28   #16  |  Link
Youka
Registered User
 
Youka's Avatar
 
Join Date: Mar 2011
Location: Germany
Posts: 64
Quote:
Originally Posted by tin3tin View Post
I guess it's not possible to just add the video to the memory and use it from there(would be faster)?
If i would add functions for video importing, encoding, etc. i could write a complete video editing program, but FLuaG is just a video filter with a powerful graphic library.

Quote:
Originally Posted by tin3tin View Post
Does this make any sense to you?(I have no clue)
I know it. One way to write an avisynth plugin with OpenGL drawing on every frame (all in C++).
An example with the video on the cube in FLuaG:
Code:
local w, h = flGetVideoWidth(), flGetVideoHeight()	--Video resolution
local d = 150	--Cube size

--Render function
function Video_Cube(frame_i)
	--Initialize 3D room
	flInit3D(FL_ORTHO, -1000, 1000)
	
	--Just draw the front of polygons (=faster rendering)
	glEnable(GL_CULL_FACE)
	glFrontFace(GL_FRONT)
	
	--Video to texture
	glEnable(GL_TEXTURE_2D)
	local tex = glGenTextures(1)
	glBindTexture(GL_TEXTURE_2D, tex[1])
	glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
	glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
	glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, w, h, 0)
	
	--Clear frame to black
	glClearColor(0, 0, 0, 0)
	glClear(GL_COLOR_BUFFER_BIT)
	
	--Drawing texture with full colors
	glColor(255, 255, 255, 255)
	
	--List drawing of one rectangle with video on it
	local base = glGenLists(1)
	glNewList(base, GL_COMPILE)
		glBegin(GL_QUADS)
			glTexCoord(0, 0); glVertex(-d, d)
			glTexCoord(1, 0); glVertex(d, d)
			glTexCoord(1, 1); glVertex(d, -d)
			glTexCoord(0, 1); glVertex(-d, -d)
		glEnd()
	glEndList()
	
	--Set cube rotation and position to center
	glTranslate(w/2, h/2, 0)
	glRotate(frame_i/2, 1, 1, 0)
	
	--Draw front
	glPushMatrix()
		glTranslate(0, 0, d)
		glCallList(base)
	glPopMatrix()
	
	--Draw back
	glPushMatrix()
		glTranslate(0, 0, -d)
		glRotate(180, 0, 1, 0)
		glCallList(base)
	glPopMatrix()	
	
	--Draw right side
	glPushMatrix()
		glTranslate(d, 0, 0)
		glRotate(90, 0, 1, 0)
		glCallList(base)
	glPopMatrix()	
	
	--Draw left side
	glPushMatrix()
		glTranslate(-d, 0, 0)
		glRotate(-90, 0, 1, 0)
		glCallList(base)
	glPopMatrix()	
	
	--Draw top
	glPushMatrix()
		glTranslate(0, -d, 0)
		glRotate(90, 1, 0, 0)
		glCallList(base)
	glPopMatrix()
	
	--Draw bottom
	glPushMatrix()
		glTranslate(0, d, 0)
		glRotate(-90, 1, 0, 0)
		glCallList(base)
	glPopMatrix()
	
	--Finish
	glDisable(GL_TEXTURE_2D)
	glDeleteLists(base, 1)
end

--Register render function for the whole video
Register("Video_Cube", 0, flGetVideoFrames())
Try it.

Quote:
Originally Posted by tin3tin View Post
Are there any tutorial/examples on that process you mention of working with video on 3d objects?
Decode a video into memory and load frame-per-frame as texture for an OpenGL 3D object. It's really simple.

Last edited by Youka; 13th June 2011 at 23:57.
Youka is offline   Reply With Quote
Old 14th June 2011, 20:02   #17  |  Link
tin3tin
Registered User
 
tin3tin's Avatar
 
Join Date: Mar 2005
Posts: 366
WOW WOW WOW. That's super powerful!

Maybe I could just make two lua scripts(for transitions). Ex.
- One with the first clip processed (on one side of the box)and the rest of the image transparent.
- Process the second clip (on the other side of the box) with the rest of the image transparent.
- Then overlay those two together on a background.
__________________
DVD slideshow GUI(Freeware).
tin3tin is offline   Reply With Quote
Old 14th June 2011, 20:33   #18  |  Link
tin3tin
Registered User
 
tin3tin's Avatar
 
Join Date: Mar 2005
Posts: 366
Did a quick test with your Lua script and plugin in DVD slideshow GUI:
(I wish that this forum would allow posting of videos directly in the thread)
http://www.youtube.com/watch?v=ofTm1A3GNN4
__________________
DVD slideshow GUI(Freeware).

Last edited by tin3tin; 14th June 2011 at 20:36.
tin3tin is offline   Reply With Quote
Old 14th June 2011, 22:15   #19  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
@Youka,

Quote:
Could you make your plugin open source so we can learn from it?
Wilbert is offline   Reply With Quote
Old 14th June 2011, 22:30   #20  |  Link
Youka
Registered User
 
Youka's Avatar
 
Join Date: Mar 2011
Location: Germany
Posts: 64
Comes next time.
Youka is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 13:25.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.