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
animation save gets error writing to file with ffmpeg and ogv (or ogg) #2764
Comments
Same error happens with |
If I explicitly set the save writer to be FFmpegFileWriter() as suggest here: http://stackoverflow.com/a/16721486/467314 then it computes for a while, and I get this error for
|
BTW, |
I've also tried to pass the ani.save('double_pendulum.ogv', writer=animation.FFMpegFileWriter(), fps=15, extra_args=['--verbose-debug']) |
This doesn't seem to work either: ani.save('double_pendulum.ogv', writer=animation.FFMpegFileWriter(extra_args=['--verbose-debug']), fps=15) |
This fails: ani.save('double_pendulum.ogv', writer=animation.FFMpegFileWriter(), codec='libtheora', fps=15)
|
So, this used to work, at least in Matplollib 1.1.1 and whatever standard install of ffmpeg I had in that version of Ubuntu, see this notebook: |
Have you tried this on master? There was some work on the argument order to ffmeg recently. |
I had a similar problem myself and figured out that it depends on the used DPI when you save. This is the list of working DPIs (checked range(50, 501, 1))
|
@danielballan does pyav also do writing? |
Yes, see for example how this is implemented in PIMS. |
Does not work on windows 7 using VERSION 1.3.1 of matplotlib. Sample code # -*- coding: utf-8 -*-
"""
Created on Thu Dec 11 11:52:11 2014
@author: amp
http://matplotlib.org/examples/index.html#examples-index
"""
# This example uses a MovieWriter directly to grab individual frames and
# write them to a file. This avoids any event loop integration, but has
# the advantage of working with even the Agg backend. This is not recommended
# for use in an interactive setting.
# -*- noplot -*-
import numpy as np
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import matplotlib.animation as manimation
FFMpegWriter = manimation.writers['ffmpeg']
metadata = dict(title='Movie Test', artist='Matplotlib',
comment='Movie support!')
writer = FFMpegWriter(fps=15, metadata=metadata)
fig = plt.figure()
l, = plt.plot([], [], 'k-o')
plt.xlim(-5, 5)
plt.ylim(-5, 5)
x0,y0 = 0, 0
with writer.saving(fig, "writer_test2.ogv", 100):
for i in range(100):
x0 += 0.1 * np.random.randn()
y0 += 0.1 * np.random.randn()
l.set_data(x0, y0)
writer.grab_frame() |
Can you please provide a traceback? Does it work in 1.4.2? We do not support the 1.3.x series anymore and
|
I do not know what traceback is.
|
I am using python 2.7 that is installed in spyder in both systems. Same version of matplotlib 1.3.1 OK, I will have to find out how to update matplotlib in both ubuntu and windows. Is there any chance that anything will break? |
The posted code from amunzip also fails for matplotlib 1.4.2, Python 3.3, Windows 7, 64-bit. Error trace:
|
I got the same error as amunizp (also on mpl 1.4.2, Python 2.7.9, OS X, using miniconda with everything updated). |
@dopplershift Do any of these tracebacks make sense to you? Something is clearly getting messed up with the pipe. Other things that look troubling is that |
This might not be helpful, but I put an ipdb session right before the call to write_rgba and it looks like the file object is fine:
Actually, it looks like my ffmpeg might be broken... I'll reinstall it. |
Reinstalling ffmpeg (using MacPorts) totally fixed it for me. I noticed it was busted because I tried Sorry about that! |
Glad you got it working. Please re-open if you have more problems. |
I am still seeing this issue (on Linux). As pointed out in #2764 (comment), I think the issue has to do with some DPIs not working (although the acceptable values I get are different). I am using |
Does it work if you change the writer creation line to: writer = FFMpegWriter(fps=15, metadata=metadata, codec='libtheora') ? |
I have had the same error reported. From what I can tell matplotlib starts a ffmpeg process and then writes to it's stdin through a file interface. What it seems like is happening is that ffmpeg sees a frame that is invalid according to the parameters given when it was called. At that time ffmpeg quits. However, the python code dose not seem to know until it tries to write to ffmpeg on the next frame. Thus the crash. This can happen for a large number of reasons, and I would recommend matplotlib include some way to figure out why it happened (if possible). It seems like it was caused (for me) by setting the bitrate too high. If you want to get some more debugging information ffmpeg adding matplotlib.rcParams['animation.ffmpeg_args'] = '-report' which will cause ffmpeg to create a log file each time it is run. I found the maximum bitrate of my source images and setting the param: matplotlib.rcParams['animation.bitrate'] = 2000 I hope this helps. (I am using '1.4.3' on windows with WinPython) |
Fixes issue pydy#216. - Removed the "bloggy" style text. - Specified the dependencies. - Included specific dependencies at the end of the notebook. - Removed the ogv output, as Firefox now supports mp4 and matplotlib seems to fail on ogg: matplotlib/matplotlib#2764 - avconv is required as the writer. - Changed to the linearizer introduced in SymPy 0.7.6.
Using: http://matplotlib.org/1.2.1/examples/animation/double_pendulum_animated.html
With these added lines at the top:
And no
clear_temp
kwarg in the save method call. I get this for trying to make adouble_pendulum.ogv
file.The text was updated successfully, but these errors were encountered: