jbusecke / xmovie

A simple way of creating movies from xarray objects
https://xmovie.readthedocs.io/
MIT License
251 stars 38 forks source link

Showing the ffmpeg command #29

Open tomchor opened 4 years ago

tomchor commented 4 years ago

I think it would be nice to have the option of printing the resulting ffmpeg command that xmovie issues. I just went through a situation where all the images were generated but ffmpeg failed. The figures were still there (and they took a long time to generate), but I still had to re-do them all on my second try. Having the ffmpeg command would have saved me the trouble. I could have just issued the command in the terminal.

Thanks!

jbusecke commented 4 years ago

Thats a great idea. We should definitely do that.

jbusecke commented 4 years ago

Actually could you try running the movie creation with verbose=True. I think that already does a similar thing.

tomchor commented 4 years ago

That's a good point. I missed that option. However, I get an error when that option is activated:

TypeError                                 Traceback (most recent call last)
~/ML6mov.py in <module>
     41     gif_palette=False,
     42     gif_resolution_factor=0.5,
---> 43     gif_framerate=10,
     44 )
     45 

~/miniconda3/envs/p37/lib/python3.7/site-packages/xmovie/core.py in save(self, filename, remove_frames, remove_movie, progress, verbose, overwrite_existing, framerate, ffmpeg_options, gif_palette, gif_resolution_factor, gif_framerate)
    462             verbose=verbose,
    463             framerate=framerate,
--> 464             ffmpeg_options=ffmpeg_options,
    465         )
    466 

~/miniconda3/envs/p37/lib/python3.7/site-packages/xmovie/core.py in write_movie(sourcefolder, moviename, frame_pattern, remove_frames, verbose, ffmpeg_options, framerate)
    209         sourcefolder, moviename, framerate, frame_pattern, ffmpeg_options
    210     )
--> 211     p = _check_ffmpeg_execute(command, verbose=verbose)
    212 
    213     print("Movie created at %s" % (moviename))

~/miniconda3/envs/p37/lib/python3.7/site-packages/xmovie/core.py in _check_ffmpeg_execute(command, verbose)
    134     else:
    135         try:
--> 136             p = _execute_command(command, verbose=verbose)
    137             return p
    138         except RuntimeError:

~/miniconda3/envs/p37/lib/python3.7/site-packages/xmovie/core.py in _execute_command(command, verbose, error)
    116             if out_check != "":
    117                 # only display 10 lines, this cant be that hard?
--> 118                 sys.stdout.write(out)
    119                 sys.stdout.flush()
    120     else:

TypeError: write() argument must be str, not bytes
brianmapes commented 3 years ago

I had the same issue -- lots of frames created, but ffmpeg was not installed, so had to run it again (slow). Could ffmpeg be made a conda dependency so it is installed automatically?
Anyway, it works: so mainly, thanks!

jbusecke commented 3 years ago

Hi @brianmapes, sorry for the long response time. I think a conda-forge feedstock would be a great addition. I opened a separate issue for this (#37), since it is technically not related to the original topic?

I was just looking through the codebase and it might also be helpful to check for an existing ffmpeg version before saving out all those frames?

I think this should be a rather easy fix (moving these lines into the class setup?)