Git Product home page Git Product logo

Comments (23)

Zulko avatar Zulko commented on May 19, 2024

Did you update FFMPEG to a recent version from the website as indicated in the README and the documentation ? That might be the issue.

from moviepy.

kviktor avatar kviktor commented on May 19, 2024

You are correct, with a more recent version of ffmpeg it works!

from moviepy.

Zulko avatar Zulko commented on May 19, 2024

In the next version the program will throw a special warning for Ubuntu/Debian users. I am closing the issue, have fun and let me know if you meet any other problem.

from moviepy.

kviktor avatar kviktor commented on May 19, 2024

I got this "error" after trying to create a gif

MoviePy: Generating GIF frames
sh: 1: convert: not found
                         MoviePy: GIF generated !

After installing imagemagick it worked, maybe a warning should be added for this too (I know it's in the docs, but people are lazy! :)

from moviepy.

colblitz avatar colblitz commented on May 19, 2024

I'm getting an error when creating a gif as well, but it doesn't seem to be an imagemagick issue (I have 6.8.7-7 installed) - it's the same as the original issue

Python 2.7.2 (default, Oct 11 2012, 20:14:37) 
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "copyright", "credits" or "license()" for more information.
>>> from moviepy.editor import *
>>> VideoFileClip("test.mp4")
<moviepy.video.io.VideoFileClip.VideoFileClip instance at 0x1077b9368>
>>> VideoFileClip("test.mp4").to_gif("test4.gif")

MoviePy: building GIF file test4.gif
----------------------------------------
Generating GIF frames.

|----------| 0/1   0% [elapsed: 00:00 left: ?, ? iters/sec]
16 [elapsed: 00:00, 31.27 iters/sec]                       
## More output.... ##
137 [elapsed: 00:05, 24.19 iters/sec]
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    VideoFileClip("test.mp4").to_gif("test4.gif")
  File "/Library/Python/2.7/site-packages/moviepy/video/VideoClip.py", line 393, in to_gif
    self.save_frame(name, t, savemask=True)
  File "/Library/Python/2.7/site-packages/moviepy/video/VideoClip.py", line 112, in save_frame
    im = self.get_frame(t)
  File "/Library/Python/2.7/site-packages/moviepy/video/io/VideoFileClip.py", line 66, in <lambda>
    self.get_frame = lambda t: self.reader.get_frame(t)
  File "/Library/Python/2.7/site-packages/moviepy/video/io/ffmpeg_reader.py", line 154, in get_frame
    result = self.read_frame()
  File "/Library/Python/2.7/site-packages/moviepy/video/io/ffmpeg_reader.py", line 117, in read_frame
    assert len(s) == nbytes
AssertionError

I got the same error with ffmpeg installed from HEAD

colblitz:video jlee$ ffmpeg
ffmpeg version 2.1.4 Copyright (c) 2000-2014 the FFmpeg developers
  built on Feb 24 2014 14:56:08 with llvm-gcc 4.2.1 (LLVM build 2336.11.00)
  configuration: --prefix=/Volumes/Ramdisk/sw --enable-gpl --enable-pthreads --enable-version3 --enable-libspeex --enable-libvpx --disable-decoder=libvpx --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-avfilter --enable-libopencore_amrwb --enable-libopencore_amrnb --enable-filters --enable-libgsm --arch=x86_64 --enable-runtime-cpudetect
  libavutil      52. 48.101 / 52. 48.101
  libavcodec     55. 39.101 / 55. 39.101
  libavformat    55. 19.104 / 55. 19.104
  libavdevice    55.  5.100 / 55.  5.100
  libavfilter     3. 90.100 /  3. 90.100
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'
colblitz:video jlee$ pip freeze
moviepy==0.2.1.7.09
numpy==1.8.0
tqdm==1.0
[other stuff]

from moviepy.

colblitz avatar colblitz commented on May 19, 2024

I got it to work - I wasn't too concerned with losing a few frames, so I hacked in a try/catch for the save_frame call on line 392 of VideoClip.py. I have no idea why it wasn't working, though, so this may still warrant some investigation, or at least a more elegant solution than just silently dropping frames...

from moviepy.

Zulko avatar Zulko commented on May 19, 2024

Thanks for the feedback.
Could you try uncommenting this line in the same function and tell me if it works ?

#self.proc.stdout.flush()

from moviepy.

colblitz avatar colblitz commented on May 19, 2024

I don't see that line in VideoClip.py (version 0.2.1.7.09) - I found that line in ffmpeg_reader, though, but it wasn't commented out to begin with?

from moviepy.

Zulko avatar Zulko commented on May 19, 2024

Ah... sorry for that, maybe its just the github version.

It is difficult to have subprocess working as expected in python 2/3 and
windows/OSX/Unix, so we will need to experiment a little. I suggest you
install it in develop mode and try a few variants, like commenting that
line if it is not commented.

That would be really cool if you could do that. Debuging bugs that I
don't have is very time-consuming and I really am under the water at the
moment.

Le 05/03/2014 18:47, Joseph Lee a Γ©crit :

I don't see that line in VideoClip.py (version 0.2.1.7.09) - I found
that line in ffmpeg_reader, though, but it wasn't commented out to
begin with?

β€”
Reply to this email directly or view it on GitHub
#14 (comment).

from moviepy.

Dhertz avatar Dhertz commented on May 19, 2024

Hi Zulko,

I get this error pretty much every time I try and concatenate videos - it seems to be ffmpeg doesn't fill the pipe at all as the assertion fails after comparing 0 with nbytes.

I have tried uncommenting the line you suggested to no avail, as well as running ffmpeg with unbuffered to see if that made a difference. The movies I am trying to concatenate play fine in both QuickTime and VLC. I am currently running on Ubuntu 14.04 with the latest ffmpeg from here.

Thanks,

Daniel

from moviepy.

kivo360 avatar kivo360 commented on May 19, 2024

Same exact situation as Dhertz for me.

from moviepy.

Zulko avatar Zulko commented on May 19, 2024

@kivo360 @Dhertz
Thanks for the feedback ! I believe I fixed that last week in the Github version. Could you try to download the current Github version and install it (with python setup.py install), and tell me if your scripts work now ? If it does I will update the version on PyPI. thanks in advance !

from moviepy.

Dhertz avatar Dhertz commented on May 19, 2024

@Zulko No, it still fails this assertion for me unfortunately.

from moviepy.

Zulko avatar Zulko commented on May 19, 2024

Ok, I'll look at this later, in the meantime can you paste your code somewhere ? (ideally: could you provide a file(s) with which it fails ?)

from moviepy.

Dhertz avatar Dhertz commented on May 19, 2024

Here is some test code and some movie files: https://www.dropbox.com/s/589rnbt22hsz9j9/moviepy_test.zip

Thanks for all your help!

from moviepy.

Zulko avatar Zulko commented on May 19, 2024

I have made some tests and I am quite positive that there is a problem with the first input file in your video concatenation. As it seems that many other video files out there have the same problem, I modified the program: now when moviepy has trouble reading a frame (which should only happen at the far end of video files), it prints a warning, and uses the last frame read as a replacement. I tried it on your file and you really can't tell a difference, given the high frame rate.

For the details on why I think there is something wrong with your file (the first file of the two you gave me):

  • Just trancoding the file with VideoFileClip("yourfile.mp4").to_videofile('test.mp4') creates a bug at the end of the file. This is a very rare bug.
  • When I open the file in the VLC media player and play it frame by frame, there is a problem at the end of the file (frame not accessible).
  • Just transcoding the file with ffmpeg -i yourfile.mp4 newfile.mp4 solved the problem (I am not saying this is a solution !).

In short, you can update you version of moviepy, (hopefully) you won't have this bug, but beware of the repeated-frame-trick that will possibly happen at the end of your file.

from moviepy.

Dhertz avatar Dhertz commented on May 19, 2024

Hmm - I don't think it is just at the end of the file - when I write out the video file once it reports a few errors at the end frames, but I cannot diagnose where these are coming from. The real issue seems to be when concatenating it with other files, it causes hundreds of frames to be lost.

If it helps, the video is being recorded and uploaded by iOS devices.

from moviepy.

Zulko avatar Zulko commented on May 19, 2024

Just to be sure, did you try it with my last update ? What exactly do you mean by "it causes hundreds of frames to be lost" ? From what I have seen, the problem is just that in a concatenation the program bugs at the end of the first file to be concatenanted (this is the same bug as when you write the file out once), and as a consequence it doesn't write the subsequent files. When the bug at the end of File 1 is solved, the concatenation works properly.

With the example files that you provided, the concatenation now works perfectly on my computer, you just loose 1 frame at the end of the first file (this frame is replaced by the frame before).

If it were not this situation, could you provide an example (or files) for which this happens ?

from moviepy.

Dhertz avatar Dhertz commented on May 19, 2024

Sorry, you're totally right, that seems to be working now! I was using an old reference to a VideoFileClip after trimming the source material causing it to throw that assertion a lot, which confused matters! Maybe there needs to be an extra check on the number of frames in the file just as to_videofile is called? Now it seems to only drop the last two or so frames, and running through FFMPEG with -c:v h264 seems to fix it!

Thanks again for the great library!

from moviepy.

Zulko avatar Zulko commented on May 19, 2024

@Dhertz Very cool, thanks for the testing. I am still a little confused as to what causes these problems, maybe in the future someone with real knownledge of ffmpeg/encoding/etc. can help on that matter.

I will leave this issue open, at least until @kivo360 can tell me if the new version works for him too.

from moviepy.

kivo360 avatar kivo360 commented on May 19, 2024

@Zulko Thanks for the fast response.

I decided on an alternative method to concatenate my videos that doesn't heavily use ffmpeg. It is actually a bit better for my project. So you can know if your patch works well, I'll do some testing later today and let you know of the results. Thanks again. I'll let you know when I have the time to sit down and do it.

from moviepy.

Zulko avatar Zulko commented on May 19, 2024

@kivo360 Sure, if you only need to concatenate videos, MoviePy is not the best solution. Thanks, I am closing the issue.

from moviepy.

kivo360 avatar kivo360 commented on May 19, 2024

Yeah, I figured. I'm using it mostly for the video fx, composition and masking components.

from moviepy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.