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 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 optionprotected 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 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 OrganizationDirectoryServiceThe organization directory serviceprotected intThe number of segments that should be generatedprotected SecurityServiceThe security servicestatic final StringThe key to look for in the service configuration file to override the DEFAULT_CAPTION_JOB_LOADprotected 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 UserDirectoryServiceThe user directory serviceprotected 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) OSGI activate method.protected Mpeg7CatalogfilterSegmentation(LinkedList<Segment> segments, Track track, LinkedList<Segment> segmentsNew) Merges small subsequent segments (with high difference) into a bigger oneprotected Mpeg7CatalogfilterSegmentation(LinkedList<Segment> segments, Track track, LinkedList<Segment> segmentsNew, int mergeThresh) Merges small subsequent segments (with high difference) into a bigger oneprotected OrganizationDirectoryServiceReturns a reference to the organization directory service.protected SecurityServiceReturns a reference to the security serviceprotected ServiceRegistryReturns a reference to the service registry.protected UserDirectoryServiceReturns a reference to the user directory serviceprotected StringAsks the overriding class to process the arguments using the given operation.protected CatalogStarts segmentation on the video track identified bymediapackageIdandelementIdand returns a receipt containing the final result in the form of anMpeg7Catalog.Takes the given track and returns the job that can be used to get the resulting mpeg7 catalog.protected voidsetMpeg7CatalogService(Mpeg7CatalogService mpeg7CatalogService) Sets the mpeg7CatalogServicevoidsetOrganizationDirectoryService(OrganizationDirectoryService organizationDirectory) Sets a reference to the organization directory service.voidsetSecurityService(SecurityService securityService) Callback for setting the security service.protected voidsetServiceRegistry(ServiceRegistry serviceRegistry) Sets the receipt servicevoidsetUserDirectoryService(UserDirectoryService userDirectoryService) Callback for setting the user directory service.protected voidsetWorkspace(Workspace workspace) Sets the workspaceprotected Mpeg7CataloguniformSegmentation(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 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
Reference to the receipt service -
mpeg7CatalogService
The mpeg-7 service -
workspace
The workspace to use when retrieving remote media files -
securityService
The security service -
userDirectoryService
The user directory service -
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:AbstractJobProducerOSGI activate method.- Overrides:
activatein classAbstractJobProducer- Parameters:
cc- OSGI component context
-
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
Takes the given track and returns the job that can be used to get the resulting mpeg7 catalog.- Specified by:
segmentin interfaceVideoSegmenterService- Parameters:
track- track to segment- Returns:
- the job with which we can obtain the extracted metadata
- Throws:
VideoSegmenterException- if the track could not be segmentedMediaPackageException- 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 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:
VideoSegmenterExceptionMediaPackageException
-
process
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:
processin classAbstractJobProducer- 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 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 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 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 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 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
Sets the workspace- Parameters:
workspace- an instance of the workspace
-
setMpeg7CatalogService
Sets the mpeg7CatalogService- Parameters:
mpeg7CatalogService- an instance of the mpeg7 catalog service
-
setServiceRegistry
Sets the receipt service- Parameters:
serviceRegistry- the service registry
-
getServiceRegistry
Returns a reference to the service registry.- Specified by:
getServiceRegistryin classAbstractJobProducer- Returns:
- the service registry
- See Also:
-
setSecurityService
Callback for setting the security service.- Parameters:
securityService- the securityService to set
-
setUserDirectoryService
Callback for setting the user directory service.- Parameters:
userDirectoryService- the userDirectoryService to set
-
setOrganizationDirectoryService
Sets a reference to the organization directory service.- Parameters:
organizationDirectory- the organization directory
-
getSecurityService
Returns a reference to the security service- Specified by:
getSecurityServicein classAbstractJobProducer- Returns:
- the security service
- See Also:
-
getUserDirectoryService
Returns a reference to the user directory service- Specified by:
getUserDirectoryServicein classAbstractJobProducer- Returns:
- the user directory service
- See Also:
-
getOrganizationDirectoryService
Returns a reference to the organization directory service.- Specified by:
getOrganizationDirectoryServicein classAbstractJobProducer- Returns:
- the organization directory service
- See Also:
-