Discussion:
(1)Keyboard interaction no longer working. (2)Video support request.
tristan@hxgraphics
2009-06-09 19:37:23 UTC
Permalink
(1)
The following predefined variables for keyboard interaction were working:
key, keycode, keydown; but when I retrieved the latest version from the
repository they ceased to function. However, the mouse interaction still
works, so I'm still able to make use of this for interaction.

(2)
Another feature which would prove handy is some kind of 'export as video'. I
may have overlooked something, but I cannot find a feature to do it. I am
currently delivering a Shoebot course to my students and they are excited
about the course so far -- often emailing .png examples of what they are
busy with to their friends. Some of the initial feedback is that they are
unable to send animated examples.

Provided a series of frames could be compiled into any given video format --
thus creating a rather large video file -- it then be compressed and
transcoded using any other software. Short of this, a series of .png files
would suffice -- these could be compiled into a video outside of Shoebot.
--
View this message in context: http://n2.nabble.com/%281%29Keyboard-interaction-no-longer-working.-%282%29Video-support-request.-tp3051638p3051638.html
Sent from the ShoeBot mailing list archive at Nabble.com.
ricardo lafuente
2009-06-10 13:25:00 UTC
Permalink
Post by ***@hxgraphics
(1)
key, keycode, keydown; but when I retrieved the latest version from the
repository they ceased to function. However, the mouse interaction still
works, so I'm still able to make use of this for interaction.
Same happens here, looking at the changesets i am at a loss of what
could have happened...
I'll take a look at this during the weekend and try to find the culprits.
Post by ***@hxgraphics
(2)
Another feature which would prove handy is some kind of 'export as video'. I
may have overlooked something, but I cannot find a feature to do it. I am
currently delivering a Shoebot course to my students and they are excited
about the course so far -- often emailing .png examples of what they are
busy with to their friends. Some of the initial feedback is that they are
unable to send animated examples.
Provided a series of frames could be compiled into any given video format --
thus creating a rather large video file -- it then be compressed and
transcoded using any other software. Short of this, a series of .png files
would suffice -- these could be compiled into a video outside of Shoebot.
you can do this using the snapshot(filename) function. If you place it
in the draw loop and have a frame counter that you append to the
filename, you'll be able to generate an image sequence. In a very messy
way, this would be it:

filenameroot = 'output'
extension = '.png'
counter = 0

def draw():
# do your drawing here
filename = filenameroot + str(counter) + extension
snapshot(filename)

from there, you can create an .avi file using ffmpeg. According to
http://www.3daet.com/pages/540/image_sequence_to_avi/ and
http://ffmpeg.arrozcru.org/forum/viewtopic.php?f=1&t=937 , this would be
the way:

ffmpeg -i output%d.jpg movie.avi

mencoder is also able to do this, though i couldn't quickly find an
example of this.

let us know how it turned out for you!
ricardo lafuente
2009-06-10 13:30:49 UTC
Permalink
garf, copypasting commands without double checking sucks.
Post by ricardo lafuente
ffmpeg -i output%d.jpg movie.avi
of course, you'd want .png instead of .jpg in the example above.

also, '-vcodec png' might or might not be necessary.
Dave Crossland
2009-06-10 14:39:09 UTC
Permalink
Could we add a feature to write out every cairo canvas instance to png?
Obviously this would make 1000s of files and hog disk space, but could be a
interim hackish way of getting video export soon?

Regards, Dave

On 10 Jun 2009, 2:30 PM, "ricardo lafuente" <***@sollec.org> wrote:

garf, copypasting commands without double checking sucks.
Post by ricardo lafuente
ffmpeg -i output%d.jpg movie.avi
of course, you'd want .png instead of .jpg in the example above.

also, '-vcodec png' might or might not be necessary.

_______________________________________________ Shoebot-devel mailing list
Shoebot-devel-***@public.gmane.org
ricardo lafuente
2009-06-11 16:59:37 UTC
Permalink
this is achievable by placing a snapshot() call at the end of the draw
loop, along with a counter (see my mail up in the thread for the code).
that's also how Processing and Nodebox make that possible. Do you think
it would be useful to add an option to do that automatically? It would
be repeating something that's already easily done, IMHO, but should be
something that's featured in the docs... my plans are to spend part of
the weekend writing the remaining docs, this should definitely go there.
Maybe a 'cookbook' section detailing how to do common actions.

now that i think of it, implementing video export would be a matter of
saving snapshots automatically, and calling ffmpeg in the end -- no
python bindings for it, sadly :/
Post by Dave Crossland
Could we add a feature to write out every cairo canvas instance to png?
Obviously this would make 1000s of files and hog disk space, but could be a
interim hackish way of getting video export soon?
Regards, Dave
garf, copypasting commands without double checking sucks.
Post by ricardo lafuente
ffmpeg -i output%d.jpg movie.avi
of course, you'd want .png instead of .jpg in the example above.
also, '-vcodec png' might or might not be necessary.
_______________________________________________ Shoebot-devel mailing list
------------------------------------------------------------------------
_______________________________________________
Shoebot-devel mailing list
http://lists.tinkerhouse.net/listinfo.cgi/shoebot-devel-tinkerhouse.net
architetto francesco fantoni <hva - hermanitos verdes architetti>
2009-06-11 19:25:09 UTC
Permalink
the opencv libraries with python bindings that i was using for the video
input can rather easily output video, but i think there are better
solutions (and less exotic dependencies, opencv is not widely spread).

francesco
Post by ricardo lafuente
this is achievable by placing a snapshot() call at the end of the draw
loop, along with a counter (see my mail up in the thread for the code).
that's also how Processing and Nodebox make that possible. Do you
think it would be useful to add an option to do that automatically? It
would be repeating something that's already easily done, IMHO, but
should be something that's featured in the docs... my plans are to
spend part of the weekend writing the remaining docs, this should
definitely go there. Maybe a 'cookbook' section detailing how to do
common actions.
now that i think of it, implementing video export would be a matter of
saving snapshots automatically, and calling ffmpeg in the end -- no
python bindings for it, sadly :/
Post by Dave Crossland
Could we add a feature to write out every cairo canvas instance to png?
Obviously this would make 1000s of files and hog disk space, but could be a
interim hackish way of getting video export soon?
Regards, Dave
garf, copypasting commands without double checking sucks.
Post by ricardo lafuente
ffmpeg -i output%d.jpg movie.avi
of course, you'd want .png instead of .jpg in the example above.
also, '-vcodec png' might or might not be necessary.
_______________________________________________ Shoebot-devel mailing list
____________________________________________________________________
_______________________________________________
Shoebot-devel mailing list
http://lists.tinkerhouse.net/listinfo.cgi/shoebot-devel-tinkerhouse.net
_______________________________________________
Shoebot-devel mailing list
http://lists.tinkerhouse.net/listinfo.cgi/shoebot-devel-tinkerhouse.net
Dave Crossland
2009-06-11 21:52:49 UTC
Permalink
this is achievable by placing a snapshot() call at the end of the draw loop,
along with a counter (see my mail up in the thread for the code).
that's also how Processing and Nodebox make that possible. Do you think it
would be useful to add an option to do that automatically?
Yes. What I mean is, taking
/usr/share/shoebot/examples/animation/Hypnoval.py as an example, you
would go from:

---- 8< ---
from math import sin, cos
size(300,300)
speed(100)
filenameroot = 'output'
extension = '.png'
def setup():
global cnt
cnt = 0.0
global counter
counter = 0
def draw():
global cnt
global counter
background(0.5)
s = 0.0
translate(29,40)
for x, y in grid(5,5,45,42):
fill(0, 0, sin(cnt+s*5.0)/2.0)
oval(x + sin(cnt+s)*10.0, y + cos(cnt+s)*-6.0, 41.0, 36.0)
s += 0.05
cnt += 0.19
filename = filenameroot + str(counter) + extension
snapshot(filename)
counter += 1
# Then install ffmpeg2theora and run this command:
# ffmpeg2theora output%d.png -o movie.ogm -v 10
# Don't forget to delete the frames and watch it.
# rm output*png && vlc movie.ogm
---- 8< ---

to a single function at the top:

---- 8< ---
from math import sin, cos
videoexport("video.ogm")
size(300,300)
speed(100)
filenameroot = 'output'
extension = '.png'
def setup():
global cnt
cnt = 0.0
global counter
counter = 0
def draw():
global cnt
global counter
background(0.5)
s = 0.0
translate(29,40)
for x, y in grid(5,5,45,42):
fill(0, 0, sin(cnt+s*5.0)/2.0)
oval(x + sin(cnt+s)*10.0, y + cos(cnt+s)*-6.0, 41.0, 36.0)
s += 0.05
cnt += 0.19
filename = filenameroot + str(counter) + extension
snapshot(filename)
counter += 1
---- 8< ---

And shoebot would assume ffmpeg2theora is installed, and take care of
making the output*png in /tmp and then making the OGM in the current
working directory.

Also, I tried to extend my first example to only make the number of
output.png required for a specified number of seconds of video output,
but I couldn't see how to make the script end when the counter got to
a certain limit. Here is what I tried:

- - - 8< - - -
from math import sin, cos
size(300,300)
speed(30)
filenameroot = 'output'
extension = '.png'
seconds = 10
number_of_frames_needed = seconds / 0.04
def setup():
global cnt
cnt = 0.0
global counter
counter = 0
def draw():
global cnt
global counter
background(0.5)
s = 0.0
translate(29,40)
for x, y in grid(5,5,45,42):
fill(0, 0, sin(cnt+s*5.0)/2.0)
oval(x + sin(cnt+s)*10.0, y + cos(cnt+s)*-6.0, 41.0, 36.0)
s += 0.05
cnt += 0.19
filename = filenameroot + str(counter) + extension
snapshot(filename)
counter += 1
if counter == int(number_of_frames_needed):
# XXX not sure how to do this :)
quit()
# Then install ffmpeg2theora and run this command:
# ffmpeg2theora output%d.png -o movie.ogm -v 10
# Don't forget to delete the frames and watch it.
# rm output*png && vlc movie.ogm
- - - 8< - - -

And then, of course, the videoexport() function could be extended to
take the number of seconds as an argument:

videoexport("video.ogm", 10)
It would be repeating something that's already easily done, IMHO, but should be
something that's featured in the docs... my plans are to spend part of the
weekend writing the remaining docs, this should definitely go there. Maybe a
'cookbook' section detailing how to do common actions.
I hope the above is useful for this.

Still, I think making video export an over feature of ShoeBot would be
good - of course being able to manually make a video export
functionality as above is a very useful learning exercise, but the
convenience and "marketing power" of a built-in feature for it is also
useful.
now that i think of it, implementing video export would be a matter of
saving snapshots automatically, and calling ffmpeg in the end -- no python
bindings for it, sadly :/
I think this is okay.
tristan@hxgraphics
2009-06-10 16:58:38 UTC
Permalink
snapshot() works great!

I'm familiar with ffmpeg already, so getting that part right was easy
enough. Now I will just create a bat/bash script (or something) for
different video quality settings.

Thanks!
--
View this message in context: http://n2.nabble.com/%281%29Keyboard-interaction-no-longer-working.-%282%29Video-support-request.-tp3051638p3057077.html
Sent from the ShoeBot mailing list archive at Nabble.com.
Dave Crossland
2009-06-11 08:33:54 UTC
Permalink
Hi,

I'd be very grateful if you can post your own hg tree or the scripts on this
list, so they can be included in the next release :)

Regards, Dave

On 10 Jun 2009, 5:58 PM, "***@hxgraphics" <tristan-pANHbKdXEU/***@public.gmane.org>
wrote:


snapshot() works great!

I'm familiar with ffmpeg already, so getting that part right was easy
enough. Now I will just create a bat/bash script (or something) for
different video quality settings.

Thanks!
--
View this message in context:
http://n2.nabble.com/%281%29Keyboard-interaction-no-longer-working.-%282%29Video-support-request.-tp3051638p3057077.html

Sent from the ShoeBot mailing list archive at Nabble.com.
_________________________________________...

Shoebot-devel mailing list Shoebot-devel-***@public.gmane.org
http://lists.tinkerhouse.net/listinfo...
tristan@hxgraphics
2009-06-14 19:21:07 UTC
Permalink
This still needs work, but I used a mouse click to execute ffmpeg so that
there is no need to predefine how many frames you wish to use:

import sys

import os

size(500,500)

speed(30)



os.system('mkdir temp')

filename = 'temp/output'

ext = '.png'

filenameext = ''

count = 0



def setup():

global x

x = 10



def draw():

global filenameext, count



global x

x += 10

rect(x,10,10,10)



filenameext = filename + str(count) + ext

snapshot(filenameext)

count += 1



if mousedown:

# '-y' to force overwrite any existing video
file:
os.system('ffmpeg -i -y temp/output%d.png video.avi')

os.system('rm -r temp')

# totem is my media player
:
os.system('totem video.avi')

# quit script:
sys.exit()
Post by Dave Crossland
Hi,
I'd be very grateful if you can post your own hg tree or the scripts on this
list, so they can be included in the next release :)
Regards, Dave
--
View this message in context: http://n2.nabble.com/%281%29Keyboard-interaction-no-longer-working.-%282%29Video-support-request.-tp3051638p3076710.html
Sent from the ShoeBot mailing list archive at Nabble.com.
Dave Crossland
2009-06-14 20:24:14 UTC
Permalink
Aha, yes! Clearly I need to learn a lot more simple basic standard
python libraries :-)

Here is a working version of my "seconds to generate" script:

--- 8< ---
from math import sin, cos
import sys, os
size(300,300)
speed(30)
filenameroot = 'output'
extension = '.png'
seconds = 1
number_of_frames_needed = seconds / 0.04
def setup():
global cnt
cnt = 0.0
global counter
counter = 0
def draw():
global cnt
global counter
background(0.5)
s = 0.0
translate(29,40)
for x, y in grid(5,5,45,42):
fill(0, 0, sin(cnt+s*5.0)/2.0)
oval(x + sin(cnt+s)*10.0, y + cos(cnt+s)*-6.0, 41.0, 36.0)
s += 0.05
cnt += 0.19
filename = filenameroot + str(counter) + extension
snapshot(filename)
counter += 1
if counter == int(number_of_frames_needed):
os.system('ffmpeg2theora output%d.png -o movie.ogm -v 10')
os.system('rm output*png')
os.system('totem movie.ogm')
sys.exit()
ricardo lafuente
2009-06-12 09:47:35 UTC
Permalink
Post by ricardo lafuente
Post by ***@hxgraphics
(1)
key, keycode, keydown; but when I retrieved the latest version from the
repository they ceased to function. However, the mouse interaction still
works, so I'm still able to make use of this for interaction.
Same happens here, looking at the changesets i am at a loss of what
could have happened...
I'll take a look at this during the weekend and try to find the culprits.
somehow the changes i had made in gtkui.py to implement keyboard
interaction were gone... i put them back, and the keyboard example now
works fine for me.
it's now in the repository, please test!
tristan@hxgraphics
2009-06-12 17:33:45 UTC
Permalink
I ran a hg clone https://code.goto10.org/hg/shoebot shoebot to retrieve the
changes.
Maybe this is the wrong command?, but unfortunately the key interaction is
still not functioning.
Post by ricardo lafuente
somehow the changes i had made in gtkui.py to implement keyboard
interaction were gone... i put them back, and the keyboard example now
works fine for me.
it's now in the repository, please test!
--
View this message in context: http://n2.nabble.com/%281%29Keyboard-interaction-no-longer-working.-%282%29Video-support-request.-tp3051638p3068945.html
Sent from the ShoeBot mailing list archive at Nabble.com.
ricardo lafuente
2009-06-12 17:53:28 UTC
Permalink
Post by ***@hxgraphics
I ran a hg clone https://code.goto10.org/hg/shoebot shoebot to retrieve the
changes.
Maybe this is the wrong command?, but unfortunately the key interaction is
still not functioning.
doh :/
well, let's try and see what's going on: after cloning the repository
(yes, that's the right command), did you cd to it and run 'sudo python
setup.py install'?
Post by ***@hxgraphics
Post by ricardo lafuente
somehow the changes i had made in gtkui.py to implement keyboard
interaction were gone... i put them back, and the keyboard example now
works fine for me.
it's now in the repository, please test!
tristan@hxgraphics
2009-06-13 08:55:15 UTC
Permalink
I don't actually make use of the install, but rather just run sbot
directly using the command line. I assumed this would not make a
difference. Anyhow, I used 'setup.py install' this time around, but
still no key interaction.

Quoting "ricardo lafuente (via Nabble)"
Post by ricardo lafuente
doh :/
well, let's try and see what's going on: after cloning the repository
(yes, that's the right command), did you cd to it and run 'sudo python
setup.py install'?
--
View this message in context: http://n2.nabble.com/%281%29Keyboard-interaction-no-longer-working.-%282%29Video-support-request.-tp3051638p3071770.html
Sent from the ShoeBot mailing list archive at Nabble.com.
ricardo lafuente
2009-06-15 09:35:36 UTC
Permalink
please try it again now -- for some weird reason the changes didn't make
it into the repository (now fixed).
Post by ***@hxgraphics
I don't actually make use of the install, but rather just run sbot
directly using the command line. I assumed this would not make a
difference. Anyhow, I used 'setup.py install' this time around, but
still no key interaction.
Quoting "ricardo lafuente (via Nabble)"
Post by ricardo lafuente
doh :/
well, let's try and see what's going on: after cloning the repository
(yes, that's the right command), did you cd to it and run 'sudo python
setup.py install'?
------------------------------------------------------------------------
_______________________________________________
Shoebot-devel mailing list
http://lists.tinkerhouse.net/listinfo.cgi/shoebot-devel-tinkerhouse.net
tristan@hxgraphics
2009-06-15 14:32:06 UTC
Permalink
Key interaction works perfectly now. Thanks.
Post by ricardo lafuente
please try it again now -- for some weird reason the changes didn't make
it into the repository (now fixed).
--
View this message in context: http://n2.nabble.com/%281%29Keyboard-interaction-no-longer-working.-%282%29Video-support-request.-tp3051638p3080549.html
Sent from the ShoeBot mailing list archive at Nabble.com.
Continue reading on narkive:
Loading...