Contextfree python video maker

If you have a design you're proud of, share the cfdg file here. It's also a good place to ask for feedback and collaborate.

Moderators: chris, mtnviewmark, MtnViewJohn

Post Reply
nak
Posts: 15
Joined: Tue Jul 01, 2008 10:39 pm
Contact:

Contextfree python video maker

Post by nak » Wed Sep 23, 2009 11:03 pm

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*
Last edited by nak on Sun May 29, 2011 6:55 pm, edited 2 times in total.

nak
Posts: 15
Joined: Tue Jul 01, 2008 10:39 pm
Contact:

Post by nak » Thu Sep 24, 2009 11:32 am

Oh yeah here's a rendered vid: http://www.youtube.com/watch?v=x6WF_Mv1wK8

User avatar
kipling
Posts: 91
Joined: Wed Jun 18, 2008 2:36 am

Bewdy!

Post by kipling » Fri Sep 25, 2009 12:51 am

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)

nak
Posts: 15
Joined: Tue Jul 01, 2008 10:39 pm
Contact:

Re: Contextfree python video maker

Post by nak » Thu Feb 03, 2011 2:03 am

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

User avatar
minimaleye
Posts: 14
Joined: Sat Jan 22, 2011 1:03 am

Re: Contextfree python video maker

Post by minimaleye » Thu Mar 17, 2011 8:32 am

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...
there is no end...
...therefore there isn't now and here

nak
Posts: 15
Joined: Tue Jul 01, 2008 10:39 pm
Contact:

Re: Contextfree python video maker

Post by nak » Sun May 29, 2011 2:56 pm

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

magnetandsteel
Posts: 4
Joined: Tue Aug 30, 2011 12:58 pm

Re: Contextfree python video maker

Post by magnetandsteel » Fri Oct 07, 2011 11:07 am

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

User avatar
minimaleye
Posts: 14
Joined: Sat Jan 22, 2011 1:03 am

Re: Contextfree python video maker

Post by minimaleye » Mon Nov 07, 2011 2:08 pm

post your code I'll try to help you if I can... )
there is no end...
...therefore there isn't now and here

magnetandsteel
Posts: 4
Joined: Tue Aug 30, 2011 12:58 pm

Re: Contextfree python video maker

Post by magnetandsteel » Wed Mar 28, 2012 8:31 am

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!

magnetandsteel
Posts: 4
Joined: Tue Aug 30, 2011 12:58 pm

Re: Contextfree python video maker

Post by magnetandsteel » Wed Mar 28, 2012 8:38 am

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

User avatar
minimaleye
Posts: 14
Joined: Sat Jan 22, 2011 1:03 am

Re: Contextfree python video maker

Post by minimaleye » Thu Mar 29, 2012 10:57 am

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 )
there is no end...
...therefore there isn't now and here

phonx
Posts: 3
Joined: Sat Feb 23, 2008 9:57 pm

Re: Contextfree python video maker

Post by phonx » Sat Aug 09, 2014 2:20 am

dead link????? :cry:

TimothyAquat
Posts: 5
Joined: Thu Jan 24, 2019 8:15 pm
Location: Denmark
Contact:

Contextfree python video maker

Post by TimothyAquat » Sun Feb 10, 2019 10:38 am

out w the new and in w the old...Thanks for the link to the video, cant wait to share w my daughter.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest