Class VideoSegmenterServiceImpl

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

public class VideoSegmenterServiceImpl extends org.opencastproject.job.api.AbstractJobProducer implements org.opencastproject.videosegmenter.api.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 Summary

    Fields
    Modifier and Type
    Field
    Description
    protected int
    The absolute maximum for the number of segments whose compliance will be enforced after the optimization
    protected int
    The absolute minimum for the number of segments whose compliance will be enforced after the optimization
    protected String
    Path to the executable
    protected float
    Number of pixels that may change between two frames without considering them different
    static final String
    Resulting collection in the working file repository
    static final int
    Default value for the absolute maximum number of segments
    static final int
    Default value for the absolute minimum number of segments
    static final float
    Default value for the number of pixels that may change between two frames without considering them different
    static final boolean
    Default value for the option whether segments numbers depend on track duration
    static final int
    Default value for the maximum number of cycles
    static final float
    Default value for the maximum tolerance for result
    static final int
    Default value for the preferred number of segments
    static final float
    The load introduced on the system by a segmentation job
    static final int
    The number of seconds that need to resemble until a scene is considered "stable"
    static final boolean
    Default value for the chapter extraction option
    static final List<org.opencastproject.util.MimeType>
     
    protected boolean
    The boolean that defines whether segment numbers are interpreted as absolute or relative to track duration
    static final String
     
    static final String
     
    protected static final org.slf4j.Logger
    The logging facility
    protected int
    The number of cycles after which the optimization of the number of segments is forced to end
    protected float
    The tolerance with which the optimization of the number of segments is considered successful
    protected org.opencastproject.metadata.mpeg7.Mpeg7CatalogService
    The mpeg-7 service
    static final String
    Name of the constant used to retrieve the absolute maximum number of segments
    static final String
    Name of the constant used to retrieve the absolute minimum number of segments
    static final String
    Name of the constant used to retrieve the changes threshold
    static final String
    Name of the constant used to retrieve the option whether segments numbers depend on track duration
    static final String
    Name of the constant used to retrieve the maximum number of cycles
    static final String
    Name of the constant used to retrieve the maximum tolerance for result
    static final String
    Name of the constant used to retrieve the preferred number of segments
    static final String
    Name of the constant used to retrieve the stability threshold
    static final String
    Name of the configuration option deciding whether the chapter extraction is used for segmentation
    static final String
    Name of the configuration option deciding which tracks should have their chapters extracted based on mime type
    protected org.opencastproject.security.api.OrganizationDirectoryService
    The organization directory service
    protected int
    The number of segments that should be generated
    protected org.opencastproject.security.api.SecurityService
    The security service
    static final String
    The key to look for in the service configuration file to override the DEFAULT_CAPTION_JOB_LOAD
    protected org.opencastproject.serviceregistry.api.ServiceRegistry
    Reference to the receipt service
    protected int
    The number of seconds that need to resemble until a scene is considered "stable"
    protected int
    The minimum segment length in seconds for creation of segments from ffmpeg output
    protected org.opencastproject.security.api.UserDirectoryService
    The user directory service
    protected org.opencastproject.workspace.api.Workspace
    The workspace to use when retrieving remote media files

    Fields inherited from class org.opencastproject.job.api.AbstractJobProducer

    ACCEPT_JOB_LOADS_EXCEEDING_PROPERTY, acceptJobLoadsExeedingMaxLoad, DEFAULT_ACCEPT_JOB_LOADS_EXCEEDING, executor, jobType

    Fields inherited from interface org.opencastproject.videosegmenter.api.VideoSegmenterService

    JOB_TYPE
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance of the video segmenter service.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    activate(org.osgi.service.component.ComponentContext cc)
     
    protected org.opencastproject.metadata.mpeg7.Mpeg7Catalog
    filterSegmentation(LinkedList<org.opencastproject.metadata.mpeg7.Segment> segments, org.opencastproject.mediapackage.Track track, LinkedList<org.opencastproject.metadata.mpeg7.Segment> segmentsNew)
    Merges small subsequent segments (with high difference) into a bigger one
    protected org.opencastproject.metadata.mpeg7.Mpeg7Catalog
    filterSegmentation(LinkedList<org.opencastproject.metadata.mpeg7.Segment> segments, org.opencastproject.mediapackage.Track track, LinkedList<org.opencastproject.metadata.mpeg7.Segment> segmentsNew, int mergeThresh)
    Merges small subsequent segments (with high difference) into a bigger one
    protected org.opencastproject.security.api.OrganizationDirectoryService
    protected org.opencastproject.security.api.SecurityService
    protected org.opencastproject.serviceregistry.api.ServiceRegistry
    protected org.opencastproject.security.api.UserDirectoryService
    protected String
    process(org.opencastproject.job.api.Job job)
    protected org.opencastproject.mediapackage.Catalog
    segment(org.opencastproject.job.api.Job job, org.opencastproject.mediapackage.Track track)
    Starts segmentation on the video track identified by mediapackageId and elementId and returns a receipt containing the final result in the form of anMpeg7Catalog.
    org.opencastproject.job.api.Job
    segment(org.opencastproject.mediapackage.Track track)
    protected void
    setMpeg7CatalogService(org.opencastproject.metadata.mpeg7.Mpeg7CatalogService mpeg7CatalogService)
    Sets the mpeg7CatalogService
    void
    setOrganizationDirectoryService(org.opencastproject.security.api.OrganizationDirectoryService organizationDirectory)
    Sets a reference to the organization directory service.
    void
    setSecurityService(org.opencastproject.security.api.SecurityService securityService)
    Callback for setting the security service.
    protected void
    setServiceRegistry(org.opencastproject.serviceregistry.api.ServiceRegistry serviceRegistry)
    Sets the receipt service
    void
    setUserDirectoryService(org.opencastproject.security.api.UserDirectoryService userDirectoryService)
    Callback for setting the user directory service.
    protected void
    setWorkspace(org.opencastproject.workspace.api.Workspace workspace)
    Sets the workspace
    protected org.opencastproject.metadata.mpeg7.Mpeg7Catalog
    uniformSegmentation(org.opencastproject.mediapackage.Track track, LinkedList<org.opencastproject.metadata.mpeg7.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
    void
    updated(Dictionary<String,?> properties)

    Methods inherited from class org.opencastproject.job.api.AbstractJobProducer

    acceptJob, countJobs, finallyUpdateJob, getJobType, incident, isReadyToAccept, isReadyToAcceptJobs

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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<org.opencastproject.util.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 org.opencastproject.serviceregistry.api.ServiceRegistry serviceRegistry
      Reference to the receipt service
    • mpeg7CatalogService

      protected org.opencastproject.metadata.mpeg7.Mpeg7CatalogService mpeg7CatalogService
      The mpeg-7 service
    • workspace

      protected org.opencastproject.workspace.api.Workspace workspace
      The workspace to use when retrieving remote media files
    • securityService

      protected org.opencastproject.security.api.SecurityService securityService
      The security service
    • userDirectoryService

      protected org.opencastproject.security.api.UserDirectoryService userDirectoryService
      The user directory service
    • organizationDirectoryService

      protected org.opencastproject.security.api.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)
      Overrides:
      activate in class org.opencastproject.job.api.AbstractJobProducer
    • 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 org.opencastproject.job.api.Job segment(org.opencastproject.mediapackage.Track track) throws org.opencastproject.videosegmenter.api.VideoSegmenterException, org.opencastproject.mediapackage.MediaPackageException
      Specified by:
      segment in interface org.opencastproject.videosegmenter.api.VideoSegmenterService
      Throws:
      org.opencastproject.videosegmenter.api.VideoSegmenterException
      org.opencastproject.mediapackage.MediaPackageException
      See Also:
      • VideoSegmenterService.segment(org.opencastproject.mediapackage.Track)
    • segment

      protected org.opencastproject.mediapackage.Catalog segment(org.opencastproject.job.api.Job job, org.opencastproject.mediapackage.Track track) throws org.opencastproject.videosegmenter.api.VideoSegmenterException, org.opencastproject.mediapackage.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:
      org.opencastproject.videosegmenter.api.VideoSegmenterException
      org.opencastproject.mediapackage.MediaPackageException
    • process

      protected String process(org.opencastproject.job.api.Job job) throws Exception
      Specified by:
      process in class org.opencastproject.job.api.AbstractJobProducer
      Throws:
      Exception
      See Also:
      • AbstractJobProducer.process(org.opencastproject.job.api.Job)
    • filterSegmentation

      protected org.opencastproject.metadata.mpeg7.Mpeg7Catalog filterSegmentation(LinkedList<org.opencastproject.metadata.mpeg7.Segment> segments, org.opencastproject.mediapackage.Track track, LinkedList<org.opencastproject.metadata.mpeg7.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 org.opencastproject.metadata.mpeg7.Mpeg7Catalog filterSegmentation(LinkedList<org.opencastproject.metadata.mpeg7.Segment> segments, org.opencastproject.mediapackage.Track track, LinkedList<org.opencastproject.metadata.mpeg7.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 org.opencastproject.metadata.mpeg7.Mpeg7Catalog uniformSegmentation(org.opencastproject.mediapackage.Track track, LinkedList<org.opencastproject.metadata.mpeg7.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(org.opencastproject.workspace.api.Workspace workspace)
      Sets the workspace
      Parameters:
      workspace - an instance of the workspace
    • setMpeg7CatalogService

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

      protected void setServiceRegistry(org.opencastproject.serviceregistry.api.ServiceRegistry serviceRegistry)
      Sets the receipt service
      Parameters:
      serviceRegistry - the service registry
    • getServiceRegistry

      protected org.opencastproject.serviceregistry.api.ServiceRegistry getServiceRegistry()
      Specified by:
      getServiceRegistry in class org.opencastproject.job.api.AbstractJobProducer
      See Also:
      • AbstractJobProducer.getServiceRegistry()
    • setSecurityService

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

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

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

      protected org.opencastproject.security.api.SecurityService getSecurityService()
      Specified by:
      getSecurityService in class org.opencastproject.job.api.AbstractJobProducer
      See Also:
      • AbstractJobProducer.getSecurityService()
    • getUserDirectoryService

      protected org.opencastproject.security.api.UserDirectoryService getUserDirectoryService()
      Specified by:
      getUserDirectoryService in class org.opencastproject.job.api.AbstractJobProducer
      See Also:
      • AbstractJobProducer.getUserDirectoryService()
    • getOrganizationDirectoryService

      protected org.opencastproject.security.api.OrganizationDirectoryService getOrganizationDirectoryService()
      Specified by:
      getOrganizationDirectoryService in class org.opencastproject.job.api.AbstractJobProducer
      See Also:
      • AbstractJobProducer.getOrganizationDirectoryService()