Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitecba1d2

Browse files
authored
Merge pull request#19056 from QuLogic/ffmpeg-file-raw
2 parentsd53555b +6e3864a commitecba1d2

File tree

2 files changed

+38
-14
lines changed

2 files changed

+38
-14
lines changed

‎lib/matplotlib/animation.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -628,15 +628,28 @@ class FFMpegFileWriter(FFMpegBase, FileMovieWriter):
628628
Frames are written to temporary files on disk and then stitched
629629
together at the end.
630630
"""
631-
supported_formats= ['png','jpeg','ppm','tiff','sgi','bmp',
632-
'pbm','raw','rgba']
631+
supported_formats= ['png','jpeg','tiff','raw','rgba']
633632

634633
def_args(self):
635634
# Returns the command line parameters for subprocess to use
636635
# ffmpeg to create a movie using a collection of temp images
637-
return [self.bin_path(),'-r',str(self.fps),
638-
'-i',self._base_temp_name(),
639-
'-vframes',str(self._frame_counter)]+self.output_args
636+
args= []
637+
# For raw frames, we need to explicitly tell ffmpeg the metadata.
638+
ifself.frame_formatin {'raw','rgba'}:
639+
args+= [
640+
'-f','image2','-vcodec','rawvideo',
641+
'-video_size','%dx%d'%self.frame_size,
642+
'-pixel_format','rgba',
643+
'-framerate',str(self.fps),
644+
]
645+
args+= ['-r',str(self.fps),'-i',self._base_temp_name(),
646+
'-vframes',str(self._frame_counter)]
647+
# Logging is quieted because subprocess.PIPE has limited buffer size.
648+
# If you have a lot of frames in your animation and set logging to
649+
# DEBUG, you will have a buffer overrun.
650+
if_log.getEffectiveLevel()>logging.DEBUG:
651+
args+= ['-loglevel','error']
652+
return [self.bin_path(),*args,*self.output_args]
640653

641654

642655
# Base class of avconv information. AVConv has identical arguments to FFMpeg.
@@ -745,8 +758,7 @@ class ImageMagickFileWriter(ImageMagickBase, FileMovieWriter):
745758
together at the end.
746759
"""
747760

748-
supported_formats= ['png','jpeg','ppm','tiff','sgi','bmp',
749-
'pbm','raw','rgba']
761+
supported_formats= ['png','jpeg','tiff','raw','rgba']
750762

751763
def_args(self):
752764
# Force format: ImageMagick does not recognize 'raw'.

‎lib/matplotlib/tests/test_animation.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,19 +141,31 @@ def isAvailable(cls):
141141
('html','movie.html'),
142142
('null','movie.null')
143143
]
144-
WRITER_OUTPUT+= [
145-
(writer,Path(output))forwriter,outputinWRITER_OUTPUT]
144+
145+
146+
defgen_writers():
147+
forwriter,outputinWRITER_OUTPUT:
148+
ifnotanimation.writers.is_available(writer):
149+
mark=pytest.mark.skip(
150+
f"writer '{writer}' not available on this system")
151+
yieldpytest.param(writer,None,output,marks=[mark])
152+
yieldpytest.param(writer,None,Path(output),marks=[mark])
153+
continue
154+
155+
writer_class=animation.writers[writer]
156+
forframe_formatingetattr(writer_class,'supported_formats', [None]):
157+
yieldwriter,frame_format,output
158+
yieldwriter,frame_format,Path(output)
146159

147160

148161
# Smoke test for saving animations. In the future, we should probably
149162
# design more sophisticated tests which compare resulting frames a-la
150163
# matplotlib.testing.image_comparison
151-
@pytest.mark.parametrize('writer, output',WRITER_OUTPUT)
164+
@pytest.mark.parametrize('writer,frame_format,output',gen_writers())
152165
@pytest.mark.parametrize('anim', [dict(klass=dict)],indirect=['anim'])
153-
deftest_save_animation_smoketest(tmpdir,writer,output,anim):
154-
ifnotanimation.writers.is_available(writer):
155-
pytest.skip("writer '%s' not available on this system"%writer)
156-
166+
deftest_save_animation_smoketest(tmpdir,writer,frame_format,output,anim):
167+
ifframe_formatisnotNone:
168+
plt.rcParams["animation.frame_format"]=frame_format
157169
anim=animation.FuncAnimation(**anim)
158170
dpi=None
159171
codec=None

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp