pySW4.plotting.png2mp4 module

Convert a sequencial set of .png images to a .mp4 movies.

author:Shahar Shani-Kadmiel (s.shanikadmiel@tudelft.nl)
copyright:Shahar Shani-Kadmiel (s.shanikadmiel@tudelft.nl)
license:This code is distributed under the terms of the GNU Lesser General Public License, Version 3 (https://www.gnu.org/copyleft/lesser.html)
png2mp4(outfile, inpath='./', crf=23, pts=1, fps=30, verbose=True)[source]

Python module for creating mp4 annimations from a set of sequential png images.

Parameters:

outfile : str

Name of the final .mp4 file.

inpath : str

Path to where the sequential .png images are. Default is ‘./’.

crf : int

Constant Rate Factor, ranges from 0 to 51: A lower value is a higher quality and vise versa. The range is exponential, so increasing the CRF value +6 is roughly half the bitrate while -6 is roughly twice the bitrate. General usage is to choose the highest CRF value that still provides an acceptable quality. If the output looks good, then try a higher value and if it looks bad then choose a lower value. A subjectively sane range is 18 to 28. Default is 23.

pts : int

Presentation TimeStamp, pts < 1 to speedup the video, pts > 1 to slow down the video. For example, 0.5 will double the speed and cut the video duration in half whereas 2 will slow the video down and double its duration. Default is 1.

fps : int

Frames Per Second of the output video. If you speed a video up frames get dropped as ffmpeg is trying to fit more frames in less time. Try increasing the frame rate by the same factor used for pts. If you slow a video down, increasing the frame rate results in smoother video for some reason. Default is 30.

verbose : bool

Print information about the process if True. Set to False to suppress any output.