Class VideoSegmenterServiceImpl

java.lang.Object
org.opencastproject.job.api.AbstractJobProducer
org.opencastproject.videosegmenter.ffmpeg.VideoSegmenterServiceImpl
All Implemented Interfaces:
JobProducer, VideoSegmenterService, org.osgi.service.cm.ManagedService

public class VideoSegmenterServiceImpl extends AbstractJobProducer implements VideoSegmenterService, org.osgi.service.cm.ManagedService
Media analysis plugin that takes a video stream and extracts video segments by trying to detect slide and/or scene changes. This plugin runs
 ffmpeg -nostats -i in.mp4 -filter:v 'select=gt(scene\,0.04),showinfo' -f null - 2>&1 | grep Parsed_showinfo_1
 
  • Field Details

    • COLLECTION_ID

      public static final String COLLECTION_ID
      Resulting collection in the working file repository
      See Also:
    • binary

      protected String binary
      Path to the executable
    • FFMPEG_BINARY_CONFIG

      public static final String FFMPEG_BINARY_CONFIG
      See Also:
    • FFMPEG_BINARY_DEFAULT

      public static final String FFMPEG_BINARY_DEFAULT
      See Also:
    • OPT_STABILITY_THRESHOLD

      public static final String OPT_STABILITY_THRESHOLD
      Name of the constant used to retrieve the stability threshold
      See Also:
    • DEFAULT_STABILITY_THRESHOLD

      public static final int DEFAULT_STABILITY_THRESHOLD
      The number of seconds that need to resemble until a scene is considered "stable"
      See Also:
    • OPT_CHANGES_THRESHOLD

      public static final String OPT_CHANGES_THRESHOLD
      Name of the constant used to retrieve the changes threshold
      See Also:
    • DEFAULT_CHANGES_THRESHOLD

      public static final float DEFAULT_CHANGES_THRESHOLD
      Default value for the number of pixels that may change between two frames without considering them different
      See Also:
    • OPT_PREF_NUMBER

      public static final String OPT_PREF_NUMBER
      Name of the constant used to retrieve the preferred number of segments
      See Also:
    • DEFAULT_PREF_NUMBER

      public static final int DEFAULT_PREF_NUMBER
      Default value for the preferred number of segments
      See Also:
    • OPT_MAX_CYCLES

      public static final String OPT_MAX_CYCLES
      Name of the constant used to retrieve the maximum number of cycles
      See Also:
    • DEFAULT_MAX_CYCLES

      public static final int DEFAULT_MAX_CYCLES
      Default value for the maximum number of cycles
      See Also:
    • OPT_MAX_ERROR

      public static final String OPT_MAX_ERROR
      Name of the constant used to retrieve the maximum tolerance for result
      See Also:
    • DEFAULT_MAX_ERROR

      public static final float DEFAULT_MAX_ERROR
      Default value for the maximum tolerance for result
      See Also:
    • OPT_ABSOLUTE_MAX

      public static final String OPT_ABSOLUTE_MAX
      Name of the constant used to retrieve the absolute maximum number of segments
      See Also:
    • DEFAULT_ABSOLUTE_MAX

      public static final int DEFAULT_ABSOLUTE_MAX
      Default value for the absolute maximum number of segments
      See Also:
    • OPT_ABSOLUTE_MIN

      public static final String OPT_ABSOLUTE_MIN
      Name of the constant used to retrieve the absolute minimum number of segments
      See Also:
    • DEFAULT_ABSOLUTE_MIN

      public static final int DEFAULT_ABSOLUTE_MIN
      Default value for the absolute minimum number of segments
      See Also:
    • OPT_DURATION_DEPENDENT

      public static final String OPT_DURATION_DEPENDENT
      Name of the constant used to retrieve the option whether segments numbers depend on track duration
      See Also:
    • DEFAULT_DURATION_DEPENDENT

      public static final boolean DEFAULT_DURATION_DEPENDENT
      Default value for the option whether segments numbers depend on track duration
      See Also:
    • OPT_USE_CHAPTER_IF_AVAILABLE

      public static final String OPT_USE_CHAPTER_IF_AVAILABLE
      Name of the configuration option deciding whether the chapter extraction is used for segmentation
      See Also:
    • DEFAULT_USE_CHAPTER_IF_AVAILABLE

      public static final boolean DEFAULT_USE_CHAPTER_IF_AVAILABLE
      Default value for the chapter extraction option
      See Also:
    • OPT_USE_CHAPTER_MIME_TYPES

      public static final String OPT_USE_CHAPTER_MIME_TYPES
      Name of the configuration option deciding which tracks should have their chapters extracted based on mime type
      See Also:
    • DEFAULT_USE_CHAPTER_MIME_TYPES

      public static final List<MimeType> DEFAULT_USE_CHAPTER_MIME_TYPES
    • DEFAULT_SEGMENTER_JOB_LOAD

      public static final float DEFAULT_SEGMENTER_JOB_LOAD
      The load introduced on the system by a segmentation job
      See Also:
    • SEGMENTER_JOB_LOAD_KEY

      public static final String SEGMENTER_JOB_LOAD_KEY
      The key to look for in the service configuration file to override the DEFAULT_CAPTION_JOB_LOAD
      See Also:
    • logger

      protected static final org.slf4j.Logger logger
      The logging facility
    • changesThreshold

      protected float changesThreshold
      Number of pixels that may change between two frames without considering them different
    • stabilityThreshold

      protected int stabilityThreshold
      The number of seconds that need to resemble until a scene is considered "stable"
    • stabilityThresholdPrefilter

      protected int stabilityThresholdPrefilter
      The minimum segment length in seconds for creation of segments from ffmpeg output
    • prefNumber

      protected int prefNumber
      The number of segments that should be generated
    • maxCycles

      protected int maxCycles
      The number of cycles after which the optimization of the number of segments is forced to end
    • maxError

      protected float maxError
      The tolerance with which the optimization of the number of segments is considered successful
    • absoluteMax

      protected int absoluteMax
      The absolute maximum for the number of segments whose compliance will be enforced after the optimization
    • absoluteMin

      protected int absoluteMin
      The absolute minimum for the number of segments whose compliance will be enforced after the optimization
    • durationDependent

      protected boolean durationDependent
      The boolean that defines whether segment numbers are interpreted as absolute or relative to track duration
    • serviceRegistry

      protected ServiceRegistry serviceRegistry
      Reference to the receipt service
    • mpeg7CatalogService

      protected Mpeg7CatalogService mpeg7CatalogService
      The mpeg-7 service
    • workspace

      protected Workspace workspace
      The workspace to use when retrieving remote media files
    • securityService

      protected SecurityService securityService
      The security service
    • userDirectoryService

      protected UserDirectoryService userDirectoryService
      The user directory service
    • organizationDirectoryService

      protected OrganizationDirectoryService organizationDirectoryService
      The organization directory service
  • Constructor Details

    • VideoSegmenterServiceImpl

      public VideoSegmenterServiceImpl()
      Creates a new instance of the video segmenter service.
  • Method Details

    • activate

      public void activate(org.osgi.service.component.ComponentContext cc)
      Description copied from class: AbstractJobProducer
      OSGI activate method.
      Overrides:
      activate in class AbstractJobProducer
      Parameters:
      cc - OSGI component context
    • updated

      public void updated(Dictionary<String,?> properties) throws org.osgi.service.cm.ConfigurationException
      Specified by:
      updated in interface org.osgi.service.cm.ManagedService
      Throws:
      org.osgi.service.cm.ConfigurationException
      See Also:
      • ManagedService.updated(java.util.Dictionary)
    • segment

      public Job segment(Track track) throws VideoSegmenterException, MediaPackageException
      Takes the given track and returns the job that can be used to get the resulting mpeg7 catalog.
      Specified by:
      segment in interface VideoSegmenterService
      Parameters:
      track - track to segment
      Returns:
      the job with which we can obtain the extracted metadata
      Throws:
      VideoSegmenterException - if the track could not be segmented
      MediaPackageException - if the track is invalid
      See Also:
    • segment

      protected Catalog segment(Job job, Track track) throws VideoSegmenterException, MediaPackageException
      Starts segmentation on the video track identified by mediapackageId and elementId and returns a receipt containing the final result in the form of anMpeg7Catalog.
      Parameters:
      track - the element to analyze
      Returns:
      a receipt containing the resulting mpeg-7 catalog
      Throws:
      VideoSegmenterException
      MediaPackageException
    • process

      protected String process(Job job) throws Exception
      Asks the overriding class to process the arguments using the given operation. The result will be added to the associated job as the payload.
      Specified by:
      process in class AbstractJobProducer
      Parameters:
      job - the job to process
      Returns:
      the operation result
      Throws:
      Exception
      See Also:
    • filterSegmentation

      protected Mpeg7Catalog filterSegmentation(LinkedList<Segment> segments, Track track, LinkedList<Segment> segmentsNew)
      Merges small subsequent segments (with high difference) into a bigger one
      Parameters:
      segments - list of segments to be filtered
      track - the track that is segmented
      segmentsNew - will be set to list of new segments (pass null if not required)
      Returns:
      Mpeg7Catalog that can later be saved in a Catalog as endresult
    • filterSegmentation

      protected Mpeg7Catalog filterSegmentation(LinkedList<Segment> segments, Track track, LinkedList<Segment> segmentsNew, int mergeThresh)
      Merges small subsequent segments (with high difference) into a bigger one
      Parameters:
      segments - list of segments to be filtered
      track - the track that is segmented
      segmentsNew - will be set to list of new segments (pass null if not required)
      mergeThresh - minimum duration for a segment in milliseconds
      Returns:
      Mpeg7Catalog that can later be saved in a Catalog as endresult
    • uniformSegmentation

      protected Mpeg7Catalog uniformSegmentation(Track track, LinkedList<Segment> segmentsNew, int prefNumber)
      Creates a uniform segmentation for a given track, with prefNumber as the number of segments which will all have the same length
      Parameters:
      track - the track that is segmented
      segmentsNew - will be set to list of new segments (pass null if not required)
      prefNumber - number of generated segments
      Returns:
      Mpeg7Catalog that can later be saved in a Catalog as endresult
    • setWorkspace

      protected void setWorkspace(Workspace workspace)
      Sets the workspace
      Parameters:
      workspace - an instance of the workspace
    • setMpeg7CatalogService

      protected void setMpeg7CatalogService(Mpeg7CatalogService mpeg7CatalogService)
      Sets the mpeg7CatalogService
      Parameters:
      mpeg7CatalogService - an instance of the mpeg7 catalog service
    • setServiceRegistry

      protected void setServiceRegistry(ServiceRegistry serviceRegistry)
      Sets the receipt service
      Parameters:
      serviceRegistry - the service registry
    • getServiceRegistry

      protected ServiceRegistry getServiceRegistry()
      Returns a reference to the service registry.
      Specified by:
      getServiceRegistry in class AbstractJobProducer
      Returns:
      the service registry
      See Also:
    • setSecurityService

      public void setSecurityService(SecurityService securityService)
      Callback for setting the security service.
      Parameters:
      securityService - the securityService to set
    • setUserDirectoryService

      public void setUserDirectoryService(UserDirectoryService userDirectoryService)
      Callback for setting the user directory service.
      Parameters:
      userDirectoryService - the userDirectoryService to set
    • setOrganizationDirectoryService

      public void setOrganizationDirectoryService(OrganizationDirectoryService organizationDirectory)
      Sets a reference to the organization directory service.
      Parameters:
      organizationDirectory - the organization directory
    • getSecurityService

      protected SecurityService getSecurityService()
      Returns a reference to the security service
      Specified by:
      getSecurityService in class AbstractJobProducer
      Returns:
      the security service
      See Also:
    • getUserDirectoryService

      protected UserDirectoryService getUserDirectoryService()
      Returns a reference to the user directory service
      Specified by:
      getUserDirectoryService in class AbstractJobProducer
      Returns:
      the user directory service
      See Also:
    • getOrganizationDirectoryService

      protected OrganizationDirectoryService getOrganizationDirectoryService()
      Returns a reference to the organization directory service.
      Specified by:
      getOrganizationDirectoryService in class AbstractJobProducer
      Returns:
      the organization directory service
      See Also: