[theora] python-theora: some comments

Timo Juhani Lindfors timo.lindfors at iki.fi
Thu Jan 21 04:51:39 PST 2010


Hi,

here's a list of comments on python-theora:

1) http://certik.github.com/python-theora/module_theora.html#class-theora

uses theora.test_files but setup.py does not install the test files so
using this API fails with

Traceback (most recent call last):
  File "browse-video.py", line 4, in <module>
    t = theora.Theora(theora.test_files[2])
  File "theora.pyx", line 209, in theora.Theora.__init__ (theora.c:1211)
IOError: [Errno 2] No such file or directory: 'tests/videos/videotestsrc-720x576-16-15.ogg'

When I build a debian package of python-theora should I download the
test files manually? If not, how about modifying the API documentation
to say that the test files are not normally distributed with the
library?

2) t.get_frame_image() fails with

Traceback (most recent call last):
  File "browse-video.py", line 8, in <module>
    img = t.get_frame_image()
  File "theora.pyx", line 681, in theora.Theora.get_frame_image (theora.c:3553)
ImportError: No module named scipy.misc

should setup.py declare this as a dependency? If not, can you add a
list of dependencies to README?

3) after installing scipy misc I get

Traceback (most recent call last):
  File "browse-video.py", line 8, in <module>
    img = t.get_frame_image()
  File "theora.pyx", line 681, in theora.Theora.get_frame_image (theora.c:3556)
AttributeError: 'module' object has no attribute 'toimage'

and indeed

Python 2.5.4 (r254:67916, Nov 19 2009, 22:14:20) 
[GCC 4.3.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from scipy.misc import toimage
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name toimage

Do I need some specific version of scipy? I have

python-scipy                     0.7.0-2

from debian unstable. I tried also with python2.6 and get

Python 2.6.4+ (r264:75706, Jan 17 2010, 11:37:20) 
[GCC 4.4.3 20100108 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from scipy.misc import toimage
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named scipy.misc

since python-scipy seems to be only for python 2.4 and 2.5 in debian.

I read the source code of python-scipy and noticed that I can do

Python 2.5.4 (r254:67916, Nov 19 2009, 22:14:20) 
[GCC 4.3.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from scipy.misc.pilutil import toimage
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/scipy/misc/pilutil.py", line 10, in <module>
    import Image
ImportError: No module named Image

which works after I install python-imaging.

4) I modified python-theora with

diff --git a/theora.pyx b/theora.pyx
index 4abca20..78722be 100644
--- a/theora.pyx
+++ b/theora.pyx
@@ -678,7 +678,7 @@ cdef class Theora:
         <Image.Image instance at 0x...>
 
         """
-        from scipy.misc import toimage
+        from scipy.misc.pilutil import toimage
         return toimage(self.YCbCr2RGB(self.get_frame_array()), channel_axis=2)
 
     def read_headers(self):

and was then able to run

#!/usr/bin/python                                                                                         
import theora
import sys

t = theora.Theora(sys.argv[1])
t.seek(frame=1200)
img = t.get_frame_image()
img.save("c.png")

and get a picture that looks good. thanks a lot for your work!

5) "Currently it can only seek forward." is a serious problem for my
application. Is there this an inherent limitation of the theora
library or is there something that could be done about it?

6) seeking N frames seems to take O(N) time:

N    time to seek N frames
1000 1.93s
2000 3.39s
3000 4.65s
4000 5.97s
5000 7.12s
6000 8.71s

Is there some way to create an index to make seeking O(1)?

If not, I guess my only option is to write each frame to a separate
file with "mplayer -vo jpeg video.ogv" and access them from
filesystem.


best regards,
Timo Lindfors


More information about the theora mailing list