FFMpeg To Thumbnails

This module defines the FFMpeg job that transforms a video file into a sequence of thumbnail images.

Those thumbnails are more suitable for analysis.

FFMpegThumbnailsJob(*args, **kwargs) Job for extracting thumbnails from a video.
NumberOfFilesJob(*args, **kwargs) Indicates how many thumbnails were generated by the FFMpegThumbnailsJob.
class livius.video.processing.jobs.ffmpeg_to_thumbnails.FFMpegThumbnailsJob(*args, **kwargs)

Job for extracting thumbnails from a video. This job may be the root of a workflow as it does not expect any workflow input.

Runtime parameters

Workflow output

  • A list of absolute filenames that specify the generated thumbnails. This list is sorted.

Note

The Job is designed to have relocatable set of files. The input files are governed by the video_location parameter, which is not cached (but the video filename is). The generated files are also relative to the

__init__(*args, **kwargs)

The class instanciation accepts the following arguments.

Parameters:
  • video_filename (str) – the name of the video file to process without the folder. This parameter is mandatory.
  • video_location (str) – the location of the video file. This parameter is mandatory, but is not cached.
  • thumbnail_root (str) – absolute location of the root folder containing the thumbnails. This is not cached and default to get_thumbnail_root().
  • thumbnails_location (str) – location of the generated thumbnails relative to the thumbnail_root. Default given by get_thumbnail_location().
  • video_width (int) – the width of the generated thumbnails. Defaults to 640.
  • video_fps (int) – how many frames per second to extract. Default to 1.
attributes_to_serialize = ['video_filename', 'video_fps', 'video_width', 'thumbnails_location']

Cached inputs:

  • video_filename base name of the video file
  • video_width width of the generated thumbnails
  • video_fps framerate of the thumbnails
  • thumbnails_location location of the thumbnails relative to the thumbnail root.
get_outputs()

Returns the list of thumbnail files (absolute paths)

get_thumbnail_location()

Returns the location where the thumbnails will/are stored, relative to the thumbnail root directory.

get_thumbnail_root()

Indicates the root where files are stored. Currently in the parent folder of the json files

outputs_to_cache = ['thumbnail_files']

Cached outputs:

  • thumbnail_files list of generated files, relative to the thumbnail root
class livius.video.processing.jobs.ffmpeg_to_thumbnails.NumberOfFilesJob(*args, **kwargs)

Indicates how many thumbnails were generated by the FFMpegThumbnailsJob.

This job is dependent on FFMpegThumbnailsJob.

Workflow input

The output of FFMpegThumbnailsJob

Workflow output

One unique number indicating the number of thumbnails.

livius.video.processing.jobs.ffmpeg_to_thumbnails.extract_thumbnails(video_file_name, output_width, output_folder)

Extract the thumbnails using FFMpeg.

Parameters:
  • video_file_name – name of the video file to process
  • output_width – width of the resized images
  • output_folder – folder where the thumbnails are stored