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
FieldsModifier and TypeFieldDescriptionprotected intThe absolute maximum for the number of segments whose compliance will be enforced after the optimizationprotected intThe absolute minimum for the number of segments whose compliance will be enforced after the optimizationprotected StringPath to the executableprotected floatNumber of pixels that may change between two frames without considering them differentstatic final StringResulting collection in the working file repositorystatic final intDefault value for the absolute maximum number of segmentsstatic final intDefault value for the absolute minimum number of segmentsstatic final floatDefault value for the number of pixels that may change between two frames without considering them differentstatic final booleanDefault value for the option whether segments numbers depend on track durationstatic final intDefault value for the maximum number of cyclesstatic final floatDefault value for the maximum tolerance for resultstatic final intDefault value for the preferred number of segmentsstatic final floatThe load introduced on the system by a segmentation jobstatic final intThe number of seconds that need to resemble until a scene is considered "stable"static final booleanDefault value for the chapter extraction optionstatic final List<org.opencastproject.util.MimeType> protected booleanThe boolean that defines whether segment numbers are interpreted as absolute or relative to track durationstatic final Stringstatic final Stringprotected static final org.slf4j.LoggerThe logging facilityprotected intThe number of cycles after which the optimization of the number of segments is forced to endprotected floatThe tolerance with which the optimization of the number of segments is considered successfulprotected org.opencastproject.metadata.mpeg7.Mpeg7CatalogServiceThe mpeg-7 servicestatic final StringName of the constant used to retrieve the absolute maximum number of segmentsstatic final StringName of the constant used to retrieve the absolute minimum number of segmentsstatic final StringName of the constant used to retrieve the changes thresholdstatic final StringName of the constant used to retrieve the option whether segments numbers depend on track durationstatic final StringName of the constant used to retrieve the maximum number of cyclesstatic final StringName of the constant used to retrieve the maximum tolerance for resultstatic final StringName of the constant used to retrieve the preferred number of segmentsstatic final StringName of the constant used to retrieve the stability thresholdstatic final StringName of the configuration option deciding whether the chapter extraction is used for segmentationstatic final StringName of the configuration option deciding which tracks should have their chapters extracted based on mime typeprotected org.opencastproject.security.api.OrganizationDirectoryServiceThe organization directory serviceprotected intThe number of segments that should be generatedprotected org.opencastproject.security.api.SecurityServiceThe security servicestatic final StringThe key to look for in the service configuration file to override the DEFAULT_CAPTION_JOB_LOADprotected org.opencastproject.serviceregistry.api.ServiceRegistryReference to the receipt serviceprotected intThe number of seconds that need to resemble until a scene is considered "stable"protected intThe minimum segment length in seconds for creation of segments from ffmpeg outputprotected org.opencastproject.security.api.UserDirectoryServiceThe user directory serviceprotected org.opencastproject.workspace.api.WorkspaceThe workspace to use when retrieving remote media filesFields inherited from class org.opencastproject.job.api.AbstractJobProducer
ACCEPT_JOB_LOADS_EXCEEDING_PROPERTY, acceptJobLoadsExeedingMaxLoad, DEFAULT_ACCEPT_JOB_LOADS_EXCEEDING, executor, jobTypeFields inherited from interface org.opencastproject.videosegmenter.api.VideoSegmenterService
JOB_TYPE -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of the video segmenter service. -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate(org.osgi.service.component.ComponentContext cc) protected org.opencastproject.metadata.mpeg7.Mpeg7CatalogfilterSegmentation(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 oneprotected org.opencastproject.metadata.mpeg7.Mpeg7CatalogfilterSegmentation(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 oneprotected org.opencastproject.security.api.OrganizationDirectoryServiceprotected org.opencastproject.security.api.SecurityServiceprotected org.opencastproject.serviceregistry.api.ServiceRegistryprotected org.opencastproject.security.api.UserDirectoryServiceprotected Stringprocess(org.opencastproject.job.api.Job job) protected org.opencastproject.mediapackage.Catalogsegment(org.opencastproject.job.api.Job job, org.opencastproject.mediapackage.Track track) Starts segmentation on the video track identified bymediapackageIdandelementIdand returns a receipt containing the final result in the form of anMpeg7Catalog.org.opencastproject.job.api.Jobsegment(org.opencastproject.mediapackage.Track track) protected voidsetMpeg7CatalogService(org.opencastproject.metadata.mpeg7.Mpeg7CatalogService mpeg7CatalogService) Sets the mpeg7CatalogServicevoidsetOrganizationDirectoryService(org.opencastproject.security.api.OrganizationDirectoryService organizationDirectory) Sets a reference to the organization directory service.voidsetSecurityService(org.opencastproject.security.api.SecurityService securityService) Callback for setting the security service.protected voidsetServiceRegistry(org.opencastproject.serviceregistry.api.ServiceRegistry serviceRegistry) Sets the receipt servicevoidsetUserDirectoryService(org.opencastproject.security.api.UserDirectoryService userDirectoryService) Callback for setting the user directory service.protected voidsetWorkspace(org.opencastproject.workspace.api.Workspace workspace) Sets the workspaceprotected org.opencastproject.metadata.mpeg7.Mpeg7CataloguniformSegmentation(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 lengthvoidupdated(Dictionary<String, ?> properties) Methods inherited from class org.opencastproject.job.api.AbstractJobProducer
acceptJob, countJobs, finallyUpdateJob, getJobType, incident, isReadyToAccept, isReadyToAcceptJobs
-
Field Details
-
COLLECTION_ID
Resulting collection in the working file repository- See Also:
-
binary
Path to the executable -
FFMPEG_BINARY_CONFIG
- See Also:
-
FFMPEG_BINARY_DEFAULT
- See Also:
-
OPT_STABILITY_THRESHOLD
Name of the constant used to retrieve the stability threshold- See Also:
-
DEFAULT_STABILITY_THRESHOLD
public static final int DEFAULT_STABILITY_THRESHOLDThe number of seconds that need to resemble until a scene is considered "stable"- See Also:
-
OPT_CHANGES_THRESHOLD
Name of the constant used to retrieve the changes threshold- See Also:
-
DEFAULT_CHANGES_THRESHOLD
public static final float DEFAULT_CHANGES_THRESHOLDDefault value for the number of pixels that may change between two frames without considering them different- See Also:
-
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_NUMBERDefault value for the preferred number of segments- See Also:
-
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_CYCLESDefault value for the maximum number of cycles- See Also:
-
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_ERRORDefault value for the maximum tolerance for result- See Also:
-
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_MAXDefault value for the absolute maximum number of segments- See Also:
-
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_MINDefault value for the absolute minimum number of segments- See Also:
-
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_DEPENDENTDefault value for the option whether segments numbers depend on track duration- See Also:
-
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_AVAILABLEDefault value for the chapter extraction option- See Also:
-
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
-
DEFAULT_SEGMENTER_JOB_LOAD
public static final float DEFAULT_SEGMENTER_JOB_LOADThe load introduced on the system by a segmentation job- See Also:
-
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 loggerThe logging facility -
changesThreshold
protected float changesThresholdNumber of pixels that may change between two frames without considering them different -
stabilityThreshold
protected int stabilityThresholdThe number of seconds that need to resemble until a scene is considered "stable" -
stabilityThresholdPrefilter
protected int stabilityThresholdPrefilterThe minimum segment length in seconds for creation of segments from ffmpeg output -
prefNumber
protected int prefNumberThe number of segments that should be generated -
maxCycles
protected int maxCyclesThe number of cycles after which the optimization of the number of segments is forced to end -
maxError
protected float maxErrorThe tolerance with which the optimization of the number of segments is considered successful -
absoluteMax
protected int absoluteMaxThe absolute maximum for the number of segments whose compliance will be enforced after the optimization -
absoluteMin
protected int absoluteMinThe absolute minimum for the number of segments whose compliance will be enforced after the optimization -
durationDependent
protected boolean durationDependentThe boolean that defines whether segment numbers are interpreted as absolute or relative to track duration -
serviceRegistry
protected org.opencastproject.serviceregistry.api.ServiceRegistry serviceRegistryReference to the receipt service -
mpeg7CatalogService
protected org.opencastproject.metadata.mpeg7.Mpeg7CatalogService mpeg7CatalogServiceThe mpeg-7 service -
workspace
protected org.opencastproject.workspace.api.Workspace workspaceThe workspace to use when retrieving remote media files -
securityService
protected org.opencastproject.security.api.SecurityService securityServiceThe security service -
userDirectoryService
protected org.opencastproject.security.api.UserDirectoryService userDirectoryServiceThe user directory service -
organizationDirectoryService
protected org.opencastproject.security.api.OrganizationDirectoryService organizationDirectoryServiceThe 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:
activatein classorg.opencastproject.job.api.AbstractJobProducer
-
updated
public void updated(Dictionary<String, ?> properties) throws org.osgi.service.cm.ConfigurationException- Specified by:
updatedin interfaceorg.osgi.service.cm.ManagedService- Throws:
org.osgi.service.cm.ConfigurationException- See Also:
-
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:
segmentin interfaceorg.opencastproject.videosegmenter.api.VideoSegmenterService- Throws:
org.opencastproject.videosegmenter.api.VideoSegmenterExceptionorg.opencastproject.mediapackage.MediaPackageException- See Also:
-
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 bymediapackageIdandelementIdand 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.VideoSegmenterExceptionorg.opencastproject.mediapackage.MediaPackageException
-
process
- Specified by:
processin classorg.opencastproject.job.api.AbstractJobProducer- Throws:
Exception- See Also:
-
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 filteredtrack- the track that is segmentedsegmentsNew- 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 filteredtrack- the track that is segmentedsegmentsNew- 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 segmentedsegmentsNew- 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:
getServiceRegistryin classorg.opencastproject.job.api.AbstractJobProducer- See Also:
-
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:
getSecurityServicein classorg.opencastproject.job.api.AbstractJobProducer- See Also:
-
getUserDirectoryService
protected org.opencastproject.security.api.UserDirectoryService getUserDirectoryService()- Specified by:
getUserDirectoryServicein classorg.opencastproject.job.api.AbstractJobProducer- See Also:
-
getOrganizationDirectoryService
protected org.opencastproject.security.api.OrganizationDirectoryService getOrganizationDirectoryService()- Specified by:
getOrganizationDirectoryServicein classorg.opencastproject.job.api.AbstractJobProducer- See Also:
-