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: MtnViewJohn, chris, mtnviewmark

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

Contextfree python video maker

Post 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*
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 »

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 »

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 »

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 »

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 »

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 »

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 »

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 »

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 »

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 »

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 »

dead link????? :cry:

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

Contextfree python video maker

Post 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.

shevy
Posts: 8
Joined: Thu Jan 02, 2014 11:59 am

Re: Contextfree python video maker

Post 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.

Post Reply