https://sppas.org/

SPPAS 4.16

Module sppas.src.videodata

Class sppasImageVideoWriter

Description

Write a video from a folder with images.

  • author: Brigitte Bigi
  • contact: contact@sppas.org

Constructor

Create an instance of sppasImageVideoWriter.

Parameters

  • folder: (str) Input directory with images.
def __init__(self, folder):
    """Create an instance of sppasImageVideoWriter.

    :param folder: (str) Input directory with images.

    """
    super(sppasImageVideoWriter, self).__init__()
    self.__mul = 1
    self.__repeat = 1
    logging.debug('Search for images in folder {}'.format(folder))
    self.__all_images = list()
    for img_ext in image_extensions:
        img_files = sppasDirUtils.dir_entries(folder, extension=img_ext, subdir=True)
        if len(img_files) > 0:
            logging.debug('... found {} {} images in folder'.format(len(img_files), img_ext))
            self.__all_images.extend(img_files)
        else:
            logging.debug(' .. no image found with extension {}'.format(img_ext))

Public functions

img_mul

Set the number of times to write each image.

Parameters

  • value: (int) At least 1.
def img_mul(self, value):
    """Set the number of times to write each image.

        :param value: (int) At least 1.

        """
    value = int(value)
    if value < 1:
        value = 1
    self.__mul = value
repeat

Set the number of times to repeat the sequence of images.

Parameters

  • value: (int) At least 1.
def repeat(self, value):
    """Set the number of times to repeat the sequence of images.

        :param value: (int) At least 1.

        """
    value = int(value)
    if value < 1:
        value = 1
    self.__repeat = value
export

Parameters
  • video_name
def export(self, video_name):
    """

        """
    self.open(video_name)
    for r in range(self.__repeat):
        for i, img_name in enumerate(sorted(self.__all_images)):
            img = sppasImage(filename=img_name)
            for x in range(self.__mul):
                self.write(img)
            if i > 0 and i % 100 == 0:
                logging.debug('{:d} images added to the video'.format(i))
    self.close()