nws_tools.
img2vid
(imgpth, imgfmt, outfile, fps, filesize=None, ext='mp4', preset='veryslow')[source]¶Convert a sequence of image files to a video using ffmpeg
Parameters: | imgpth : str
imgfmt : str
outfile : str
fps : int
filesize : float
ext : str
preset : str
|
---|---|
Returns: | Nothing : None |
Examples
Suppose the 600 sequentially numbered tiff files image_001.tiff, image_002.tiff, ..., image_600.tiff located in the directory `/path/to/images/ ` have to be converted to Quicktime movie (mov file) of no more than 25MB size. We want the video to show 6 consecutive images per second (i.e., a framerate of 6 frames per second). This can be done using the following command
>>> img2vid('/path/to/images','image_%03d.tiff','image_1_600',6,filesize=25,ext='mov',preset='veryslow')
Alternatively,
>>> img2vid('/path/to/images','image_%03d.tiff','image_1_600_loq.mov',6,filesize=25,ext='mkv',preset='ultrafast')
also generates an mov video of 25MB. The encoding will be faster but the image quality of image_1_600_loq.mov will be lower compared to image_1_600.mov generated by the first call. Note that the optional keyword argument ext=’mkv’ is ignored since the provided output filename ‘image_1_600_loq.mov’ already contains an extension.