Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tabs in python code #35

Closed
dmopalmer opened this issue Apr 25, 2014 · 9 comments
Closed

Tabs in python code #35

dmopalmer opened this issue Apr 25, 2014 · 9 comments

Comments

@dmopalmer
Copy link

Some of the files have tabs instead of spaces in some places. This is a barrier against using the package in Python3

The files I found were:
moviepy/video/compositing/transitions.py
moviepy/video/fx/even_size.py
moviepy/video/fx/fadeout.py
moviepy/video/fx/headblur.py
moviepy/video/fx/mirror_x.py
moviepy/video/fx/mirror_y.py
moviepy/video/fx/scroll.py
moviepy/video/fx/time_mirror.py
moviepy/video/io/sliders.py
moviepy/video/tools/tracking.py

and after detabbing, I could import moviepy.editor in python3 .

@Zulko
Copy link
Owner

Zulko commented Apr 26, 2014

Thanks for that! It is fixed now. The strange thing is that I have never had any problem in Python3 with these tabs, what is your version exactly?

@dmopalmer
Copy link
Author

I am using python3.3.5 under Mac OSX, installing using Macports.

(I don't know whether MacPorts uses pip, easy_install or something else under the hood. I don't know if it uses six or other packages to mutate Python2 code into Python3 as it does it.)

@Zulko
Copy link
Owner

Zulko commented Apr 26, 2014

Ok thanks for the info. Could you try to reinstall and see it it works now? So that I can safely close the issue.

@Zulko Zulko closed this as completed Apr 26, 2014
@dmopalmer
Copy link
Author

Quick correction, I originally installed it using pip .

More trouble: old-style print statements in
File "build/bdist.macosx-10.9-x86_64/egg/moviepy/video/tools/segmenting.py", line 47
print "found %d objects"%(num_features)
File "build/bdist.macosx-10.9-x86_64/egg/moviepy/video/tools/tracking.py", line 20
print "WARNING: OpenCV not found: automated tracking not possible"

After fixing that, it installs and imports correctly.

Unfortunately, for my particular movie file, ffmpeg can't determine the duration, and so it chokes at
video/io/ffmpeg_reader.py:215 (where it is trying to find an HH:MM:SS pattern, and ffmpeg puts up
"Duration: N/A, bitrate: N/A") This is from a Raspberry Pi reading off its camera in an h264 raw stream, so some of the encoding may be a bit skanky. Any suggestions?

@Zulko
Copy link
Owner

Zulko commented Apr 28, 2014

This sounds like an interesting project. Just to be sure, are you reading from a finite video, or from a video that is still being recorded ? In the first case, what you could try is to rewrite the video with ffmpeg and see if the result has the good metadata (but this might take some time):

ffmpeg -i myvideo.flv mycopy.flv

Otherwise I can also make the duration search optional (and send a warning when a video has no duration). Could you try this and see if it works? That is, replace that line 215 by duration=None, then do things like

myvideo = VideoFileClip("my_rpi_video.avi").set_duration(arbitrary_duration)

Not ideal, but that would be a start.

Does ffmpeg at least find the fps of the video ?

The "print" statements are fixed, thanks for the report.

@dmopalmer
Copy link
Author

I am reading from a file which was previously piped from the raspivid application (over the network).
This permits seeking (so ffmpeg can probe the file and then back up to the start and read.)

Since the compression is not too extreme, it requests a larger -probesize to get enough information to do what it can, but even with an arbitrarily large probesize, it doesn't get the duration.

It returns an FPS of 25. However, this is wrong (actual FPS is 10 in my case).

If I put the duration section in a try/except block, I can use FFMPEG_VideoReader() directly to get sequential frames from the beginning.

However, when I use moviepy.editor.VideoFileClip(), I always get the same frame from fullclip.get_frame(t) independent of how I change t.

Another Python3 change I found (which I needed for the coolTextEffects demo) was

diff --git a/moviepy/video/VideoClip.py b/moviepy/video/VideoClip.py
index 2e4fd03..e6be144 100644
--- a/moviepy/video/VideoClip.py
+++ b/moviepy/video/VideoClip.py
@@ -1036,7 +1036,7 @@ class TextClip(ImageClip):
         if not txt.startswith('@'):
             if temptxt is None:
                 temptxt_fd, temptxt = tempfile.mkstemp(suffix='.txt')
-                os.write(temptxt_fd, txt)
+                os.write(temptxt_fd, bytes(txt,'UTF8'))
                 os.close(temptxt_fd)
             txt = '@'+temptxt
         else:

@Zulko Zulko reopened this Apr 30, 2014
@Zulko
Copy link
Owner

Zulko commented Oct 12, 2014

Hi there, sorry to bother you with this old issue, but have you given it a try with the recent version ? There are chances that it may work properly.

@dmopalmer
Copy link
Author

It's back to not working with Python 3.3

% python
Python 3.3.5 (default, Sep 20 2014, 19:48:21)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import moviepy.editor as med
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "./moviepy/editor.py", line 22, in <module>
    from .video.io.VideoFileClip import VideoFileClip
  File "./moviepy/video/io/VideoFileClip.py", line 3, in <module>
    from moviepy.video.VideoClip import VideoClip
  File "./moviepy/video/VideoClip.py", line 18, in <module>
    from .io.ffmpeg_writer import ffmpeg_write_image, ffmpeg_write_video
  File "./moviepy/video/io/ffmpeg_writer.py", line 15, in <module>
    from moviepy.config import get_setting
  File "./moviepy/config.py", line 8, in <module>
    from config_defaults import (FFMPEG_BINARY, IMAGEMAGICK_BINARY)
ImportError: No module named 'config_defaults'
>>>

No such problem with python2.7.

@dmopalmer dmopalmer reopened this Oct 14, 2014
@Zulko
Copy link
Owner

Zulko commented Oct 14, 2014

Thanks for catching that, I corrected it. Now working with Python3 too.

@Zulko Zulko closed this as completed Oct 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants