Page 1 of 1

Contextfree python video maker

Posted: Wed Sep 23, 2009 11:03 pm
by nak
Here's a script that takes sections of your cfdg file and generates a set of PNGs varying slightly from the last.
Read more here:
http://www.abovesobelow.com/CFA/index.html

Download here:
http://www.abovesobelow.com/CFA/ContextFreeAni.rar

Just run animator.py, and it makes an AVI file from the PNGs, using imgcon.exe

Peace!

*edit for maturity and updated links*

Posted: Thu Sep 24, 2009 11:32 am
by nak
Oh yeah here's a rendered vid: http://www.youtube.com/watch?v=x6WF_Mv1wK8

Bewdy!

Posted: Fri Sep 25, 2009 12:51 am
by kipling
Nice job. If you put size{} or size{ s 2 } (etc) as a CF directive you won't get the image rescaling that happens in the first 20 or so seconds of the movie.
incidentally, version 3 of CF may have some built-in animation capability (other than the existing render-progress animation)

Re: Contextfree python video maker

Posted: Thu Feb 03, 2011 2:03 am
by nak
Hey, thanks
...and wow, I can be quite immature sometimes! I guess I felt ~godlike~ (krisha...) oh well. Anyway, my friend is learning python and I shot him a couple links to python stuff I had around the internet, this being one of them.
I saw another post about a context free animator, then someone said a beta with animation capibility, but it didn't seem like they were aware of this soo *bump* and *link* -- 8)
*edit*
Yeeesh, I wont bump the other thread, its super old too.
Peace

Re: Contextfree python video maker

Posted: Thu Mar 17, 2011 8:32 am
by minimaleye
Hey, man your python video maker simply rulz!!!
Thanks very much for sharing it! 8)

I have a question - Is it possible to make the .png any other size then 500x500 pixels and how if so?

edit: I did found how...

os.system("ContextFreeCLI.exe /w 960 /h 960 acid_temp.cfdg ./pngs/frame_" + str(num-1) + ".png")

if you want the images to be 960x960 pixels... or just /s 960

edit2: I'd noticed that when python going from negative value to zero it replaces 0 with very small negative value which confuses CFA and resulting a missing .png in the sequence... simple way to go around this is to use "round" command in the .py file...

Re: Contextfree python video maker

Posted: Sun May 29, 2011 2:56 pm
by nak
minimaleye wrote:Hey, man your python video maker simply rulz!!!
Thanks very much for sharing it! 8)

I have a question - Is it possible to make the .png any other size then 500x500 pixels and how if so?

edit: I did found how...

os.system("ContextFreeCLI.exe /w 960 /h 960 acid_temp.cfdg ./pngs/frame_" + str(num-1) + ".png")

if you want the images to be 960x960 pixels... or just /s 960

edit2: I'd noticed that when python going from negative value to zero it replaces 0 with very small negative value which confuses CFA and resulting a missing .png in the sequence... simple way to go around this is to use "round" command in the .py file...
Hey thanks! I'm going to do a little rewrite of this application so it works on linux with open source tools. ^.^
I'll update this thread with a link to the project page once I get it up. *edit* here: http://abovesobelow.com/CFA/
Cheers

Re: Contextfree python video maker

Posted: Fri Oct 07, 2011 11:07 am
by magnetandsteel
Hello everybody (first post! :D )

This looks awesome, I think once I really get a hang of it I'll be able to do some cool things, so thanks for putting it up!

I'm having one problem though...
I've gotten the script to run, and everything seems alright, but the png files are all "empty".

Each time it renders a new frame it says "DONE!" at the end, but a few lines before that it is saying "A GDI error occurred" and something about "Invalid Paramater" ??? As far as programming goes I'm a hobbyist / essentially self taught so I could be missing something obvious???

Any help would be appreciated, hopefully some one still has an eye on this thread! Thanks! Bryan

Re: Contextfree python video maker

Posted: Mon Nov 07, 2011 2:08 pm
by minimaleye
post your code I'll try to help you if I can... )

Re: Contextfree python video maker

Posted: Wed Mar 28, 2012 8:31 am
by magnetandsteel
Whoops sorry for the delayed reaction here! :D
I'm just using a very simple cfdg to try and get the hang of things, that code is:

-------------------------------------

startshape CIRC rule CIRC {CIRCLE {h
0
sat 0.9763 b 1.0000} CIRC {s .99 r 4 y -.1 h 1}}

-------------------------------------
and the python code is:
-------------------------------------

import os
f = open('dots.cfdg', 'r')
h = open('list.txt', 'a')
num = 0
frames = 50

allLines = f.readlines()

for i in range (-50, frames):
num = num + 1
g = open('dots.cfdg', 'w')
change = str(num)
allLines[1] = change
g.writelines(allLines)
os.system("ContextFreeCLI.exe dots.cfdg ./pngs/frame_" + str(num-1) + ".png")
if i < frames-2:
h.write("./pngs/frame_" + str(num) + ".png\n")
if i == frames-2:
h.write("./pngs/frame_" + str(num) + ".png")

f.close()
g.close()
h.close()
os.system("imgcon -avi -list list.txt")

-------------------------------------

The idea is that lonely "0" would increase with each frame, and there would be a nice hue shift on the spiral, but, like i mentioned, it runs but all the pngs are empty or incorrectly saved? Any help would be great! (I've got this bookmarked now so I can check back frequently) Thanks!

Re: Contextfree python video maker

Posted: Wed Mar 28, 2012 8:38 am
by magnetandsteel
if its of any use the window when its rendering says:


Reading rules file dots.cfdg
1 rules loaded
Generating color PNG image, variation XENIM...
500w x 500h pixel image.
Generating...

Rendering...

Writing 500w x 500h pixel image...

A GDI+ error occured during PNG write: Invalid Parameter
622 shapes
DONE!
The output file name is ./pngs/frame_14.png

Re: Contextfree python video maker

Posted: Thu Mar 29, 2012 10:57 am
by minimaleye
python screamed for some reason and I wrote:

Code: Select all

import os
f = open('dots.cfdg', 'r')
h = open('list.txt', 'a')
num = 0
frames = 50

allLines = f.readlines()

for i in range (-50, frames):
    num = num + 1
    g = open('dots.cfdg', 'w')
    change = str(num)
    allLines[1] = change
    g.writelines(allLines)
    os.system("ContextFreeCLI.exe /s 500 dots.cfdg ./pngs/frame_" + str(num-1) + ".png")

if i < frames-2:
    h.write("./pngs/frame_" + str(num) + ".png\n")
if i == frames-2:
    h.write("./pngs/frame_" + str(num) + ".png")

f.close()
g.close()
h.close()
os.system("imgcon -avi -list list.txt") 
and after that ContextFreeCLI.exe rendered 99 pngs with proper HUE change...

try to open the cfdg file after runing the python one with ContextFree.exe and see how it looks like
sometimes I get strange python related adds in chdg code - messed up rows, some extra text etc.

I guess in your case the problem is in ContextFreeCLI -> put a new copy of it - sometimes it helps )

Re: Contextfree python video maker

Posted: Sat Aug 09, 2014 2:20 am
by phonx
dead link????? :cry:

Contextfree python video maker

Posted: Sun Feb 10, 2019 10:38 am
by TimothyAquat
out w the new and in w the old...Thanks for the link to the video, cant wait to share w my daughter.

Re: Contextfree python video maker

Posted: Fri Mar 05, 2021 10:45 am
by shevy
The video is still up. :)

It's a great idea. I wish I could do this via ruby too; I lack knowledge how
to properly do animations like that.

In theory we can probably randomize a .cfdg a bit, and play with that?
Then we could render different .png files I suppose, and then use ffmpeg
to make a video and add some music to it. \o/

Unfortunately, the part about "randomizing .cfdg" is probably the hardest.

If someone comes up with simple ideas for this, then perhaps I can turn it
into working code. I am semi-ok when writing ruby code + ruby-gtk3 too,
and when people have ffmpeg installed, I could simplify that part too. I
just lack tons of domain-specific knowledge in regards to .cfdg itself.