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

set_duration ignored on TextClip #63

Closed
aseeon opened this issue Sep 17, 2014 · 7 comments
Closed

set_duration ignored on TextClip #63

aseeon opened this issue Sep 17, 2014 · 7 comments

Comments

@aseeon
Copy link

aseeon commented Sep 17, 2014

I am using:

  • Windows 8.1 64bit
  • Python 2.7.8 32bit
  • moviepy 0.2.1.8.10
  • latest ffmpeg binary static 32bit build
  • latest imagemagick 32bit build

also installed numpy, Decorator, tqdm, scipy, PyGame and Pillow

I edited the conf.py file to match my paths to binaries - and they both work (i know this because both VideoFileClip and write_gif method works flawlessly)

Now with the actual problem, when i try to execute this code:

from moviepy.editor import TextClip

text = (TextClip("my text",
                 fontsize=16, color='white', font="Arial")
        .set_pos((0, 0))
        .set_duration(5.5))

i get IOError: MoviePy error: failed to read the duration of file:

C:\Programowanie\Python278\python.exe E:/Mega/Dev/python/PyCharm/wanted-gif/example.py
Traceback (most recent call last):
  File "E:/Mega/Dev/python/PyCharm/wanted-gif/example.py", line 4, in <module>
    fontsize=16, color='white', font="Arial")
  File "C:\Programowanie\Python278\lib\site-packages\moviepy\video\VideoClip.py", line 1259, in __init__
    ImageClip.__init__(self, tempfilename, transparent=transparent)
  File "C:\Programowanie\Python278\lib\site-packages\moviepy\video\VideoClip.py", line 1011, in __init__
    img = ffmpeg_read_image(img,with_mask=transparent)
  File "C:\Programowanie\Python278\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 183, in ffmpeg_read_image
    reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt)
  File "C:\Programowanie\Python278\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 22, in __init__
    infos = ffmpeg_parse_infos(filename, print_infos)
  File "C:\Programowanie\Python278\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 239, in ffmpeg_parse_infos
    filename, infos))
IOError: MoviePy error: failed to read the duration of file c:\users\aseeon\appdata\local\temp\tmpwpfe_8.png.
Here are the file infos returned by ffmpeg:

ffmpeg version N-66289-gb76d613 Copyright (c) 2000-2014 the FFmpeg developers
  built on Sep 15 2014 22:02:10 with gcc 4.8.3 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-decklink --enable-zlib
  libavutil      54.  7.100 / 54.  7.100
  libavcodec     56.  1.100 / 56.  1.100
  libavformat    56.  4.101 / 56.  4.101
  libavdevice    56.  0.100 / 56.  0.100
  libavfilter     5.  1.100 /  5.  1.100
  libswscale      3.  0.100 /  3.  0.100
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  0.100 / 53.  0.100
Input #0, png_pipe, from 'c:\users\aseeon\appdata\local\temp\tmpwpfe_8.png':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: png, rgba, 53x18, 25 tbr, 25 tbn, 25 tbc
At least one output file must be specified

So this looks like set_duration on TextClip is ignored, and instead N/A from ffmpeg is taken and error occurs. Could you help me with this issue?

@Zulko
Copy link
Owner

Zulko commented Sep 17, 2014

Interesting. My guess is that ffmpeg changed the way to handle images. In my version (from 2 months ago) a png file appears as a 1-frame video (so with duration 0.04 at 25fps). I'll adapt the code.

@aseeon
Copy link
Author

aseeon commented Sep 17, 2014

Thank you for the quick reply. On a separate note - shouldn't set_druation trump all other forms of duration checking (or even omit them alltogether)?

@Zulko
Copy link
Owner

Zulko commented Sep 17, 2014

set_duration is an effect that comes in after the creation of the VideoClip or TextClip so it cannot influence what happens during creation.
And I really want to check for the duration of videoclips at creation time, it's an important step, it enables to evaluate the number of frames in the video clip, see if it is corrupted, etc.

Here the problem is that with the new ffmpeg we should not check for duration of pictures, since they have none. Once this will be fixed in MoviePy, set_duration will do its job properly.

@Zulko
Copy link
Owner

Zulko commented Sep 18, 2014

now fixed on github if you want to try.

@aseeon
Copy link
Author

aseeon commented Sep 19, 2014

There is this line in editor.py that gives off error:

Traceback (most recent call last):
  File "E:/Mega/Dev/python/PyCharm/wanted-gif/wanted.py", line 1, in <module>
    from moviepy.editor import *
  File "C:\Programowanie\Python278\lib\site-packages\moviepy-0.2.1.8.10-py2.7.egg\moviepy\editor.py", line 41, in <module>
    from .video.io.html_tools import ipython_display
ImportError: No module named html_tools

@Zulko
Copy link
Owner

Zulko commented Sep 19, 2014

Ah thanks, I forgot to git-add it. It is now fixed on github.

@aseeon
Copy link
Author

aseeon commented Sep 19, 2014

Yup, it works now 👍

@aseeon aseeon closed this as completed Sep 19, 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