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

using animation.save with ffmpeg writer after compiling with py2exe opens command prompt #4021

Closed
kjgregory opened this issue Jan 21, 2015 · 10 comments

Comments

@kjgregory
Copy link

I'm using animation.save with ffmpeg as my writer in a wxPython widget and it works great when I run it with python. However, when I compile it into an executable for windows using py2exe, it still works but it opens a command prompt everytime. It still encodes my video correctly and everything works fine, but I'd like to suppress the command prompt. I'm not really sure why this is happening, so not sure how to suppress it. Here is a snippet of my code:

    Writer = animation.writers['ffmpeg']
    writer = Writer(fps=40,metadata=metadata)
    ims = []
        .... #loop ~120 times generating images using imshow
        ims.append([im1, im2, axtxt])
    anim = animation.ArtistAnimation(self.fig, ims, interval=33)
    anim.save(fname, writer=writer, extra_args=['-c:v', 'libx264', '-preset', 'ultrafast', '-tune', 'stillimage'])

FWIW, I had a similar problem with running ffplay using subprocess.Popen() and I solved it by setting 'creationflags=subprocess.CREATE_NO_WINDOW' (0x08000000).

@tacaswell tacaswell added this to the v1.5.x milestone Jan 21, 2015
@tacaswell
Copy link
Member

@jbmohler Any ideas?

@tacaswell
Copy link
Member

@dopplershift
Copy link
Contributor

I wonder what happens if we add that creationflags argument to our subprocess call... Unfortunately, no windows machines here.

@kjgregory
Copy link
Author

I'll be happy to test it

@dopplershift
Copy link
Contributor

Are you able to just modify the source for matplotlib to test? If so, just change lib/matplotlib/animation.py line 190-192 from:

self._proc = subprocess.Popen(command, shell=False,                                        
                               stdout=output, stderr=output,                                
                               stdin=subprocess.PIPE)                                       

to

self._proc = subprocess.Popen(command, shell=False,                                        
                              stdout=output, stderr=output,                                
                              stdin=subprocess.PIPE, creationflags=0x08000000)                                       

Or would it be easier for me to just make a PR--could you test that?

@kjgregory
Copy link
Author

I'm pretty sure I can edit it. I tried to do so very briefly, but didn't know where to look -- now I have that piece (thanks!). I don't have git setup for matplotlib, so I think it will be easier for me to just make the change manually and report back.

@dopplershift dopplershift self-assigned this Jan 22, 2015
@kjgregory
Copy link
Author

that seems to have fixed it, @dopplershift thanks!

@dopplershift
Copy link
Contributor

Alright, then I'll open up a PR to do so in our code.

dopplershift added a commit to dopplershift/matplotlib that referenced this issue Jan 26, 2015
This tells Windows not to create a new window when using Subprocess to
save an animation.
@dopplershift
Copy link
Contributor

Alright, PR is up for anyone who wants to give it a test.

@kjgregory can you confirm that this mimics what worked for you?

@dopplershift
Copy link
Contributor

Should be closed by #4041. Re-open if that's not the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants