Class ComposerServiceImpl
java.lang.Object
org.opencastproject.job.api.AbstractJobProducer
org.opencastproject.composer.impl.ComposerServiceImpl
- All Implemented Interfaces:
ComposerService,JobProducer,org.osgi.service.cm.ManagedService
public class ComposerServiceImpl
extends AbstractJobProducer
implements ComposerService, org.osgi.service.cm.ManagedService
FFMPEG based implementation of the composer service api.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final floatThe maximum job load allowed for operations that use multiple profile (ProcessSmil, MultiEncode)static final intstatic final floatstatic final intstatic final floatdefault transition duration for process_smil in secondsstatic final floatThe default factor used to multiply the sum of encoding profiles load job for ProcessSmilstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringConfiguration for process-smil transition durationFields 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.composer.api.ComposerService
AUDIO_ONLY, BOTH, JOB_TYPE, LOWER, UPPER, VIDEO_ONLY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate(org.osgi.service.component.ComponentContext cc) OSGi callback on component activation.composite(Dimension compositeTrackSize, Option<LaidOutElement<Track>> upperTrack, LaidOutElement<Track> lowerTrack, Option<LaidOutElement<Attachment>> watermark, String profileId, String background, String sourceAudioName) Compose two videos into one with an optional watermark.Concat multiple tracks to a single track.concat(String profileId, Dimension outputDimension, float outputFrameRate, boolean sameCodec, Track... tracks) Concat multiple tracks to a single track.convertImage(Attachment image, String... profileIds) Converts the given image to a different image format using the specified image profiles.convertImageSync(Attachment image, String... profileIds) Synchronously converts the given image to different image formats using the specified encoding profiles.voidOSGi callback on component deactivation.Demux a multi-track source into 2 media as defined by the encoding profile, the results are flavored and tagged positionally. eg: One ffmpeg operation to produce presenter/work and presentation/workEncode one track, using that track's audio and video streams.protected OrganizationDirectoryServiceReturns a reference to the organization directory service.getProfile(String profileId) Gets a profile by its IDprotected SecurityServiceReturns a reference to the security serviceprotected ServiceRegistryReturns a reference to the service registry.protected UserDirectoryServiceReturns a reference to the user directory serviceprotected voidhlsFixReference(long id, List<File> outputs) protected voidhlsSetReference(Track track) Extracts an image from the media package element identified bysourceVideoTrackId.Extracts an image from the media package element identified bysourceTrack.Synchronously extracts images from the source track.imageToVideo(Attachment sourceImageAttachment, String profileId, double time) Transforms an image attachment to a video trackprotected TrackvoidOSGI callback when the configuration is updated.multiEncode(Job job, Track track, List<String> profileIds) A single encoding process that produces multiple outputs from a single track(s) using a list of encoding profiles.multiEncode(Track sourceTrack, List<String> profileIds) Encodes a track to set of media targets as defined by a list of encoding profilesMux multiple tracks into a new Track.Encode the video stream from one track and the audio stream from another, into a new Track.parallelEncode(Track sourceTrack, String profileId) Encode one track to multiple other tracks in one encoding operation, using that track's audio and video streams.protected StringAsks the overriding class to process the arguments using the given operation.processSmil(Job job, Smil smil, String trackParamGroupId, String mediaType, List<String> encodingProfiles) Splice segments given by smil document for the given track to the new one.ProcessSmil processes editing of one source group (which may contain multiple source tracks) to one set of outputs (to one or more encoding profiles).voidprotected voidsetMediaInspectionService(MediaInspectionService mediaInspectionService) Sets the media inspection servicevoidsetOrganizationDirectoryService(OrganizationDirectoryService organizationDirectory) Sets a reference to the organization directory service.protected voidsetProfileScanner(EncodingProfileScanner scanner) Sets the profile scanner.voidsetSecurityService(SecurityService securityService) Callback for setting the security service.protected voidsetServiceRegistry(ServiceRegistry serviceRegistry) Sets the service registryvoidsetSmilService(SmilService smilService) voidsetUserDirectoryService(UserDirectoryService userDirectoryService) Callback for setting the user directory service.protected voidsetWorkspace(Workspace workspace) Sets the workspaceTrims the given track to the given start time and duration.voidupdated(Dictionary<String, ?> properties) Methods inherited from class org.opencastproject.job.api.AbstractJobProducer
acceptJob, countJobs, finallyUpdateJob, getJobType, incident, isReadyToAccept, isReadyToAcceptJobs
-
Field Details
-
PROCESS_SMIL_CLIP_TRANSITION_DURATION
Configuration for process-smil transition duration- See Also:
-
DEFAULT_PROCESS_SMIL_CLIP_TRANSITION_DURATION
public static final float DEFAULT_PROCESS_SMIL_CLIP_TRANSITION_DURATIONdefault transition duration for process_smil in seconds- See Also:
-
DEFAULT_JOB_LOAD_MAX_MULTIPLE_PROFILES
public static final float DEFAULT_JOB_LOAD_MAX_MULTIPLE_PROFILESThe maximum job load allowed for operations that use multiple profile (ProcessSmil, MultiEncode)- See Also:
-
DEFAULT_PROCESS_SMIL_JOB_LOAD_FACTOR
public static final float DEFAULT_PROCESS_SMIL_JOB_LOAD_FACTORThe default factor used to multiply the sum of encoding profiles load job for ProcessSmil- See Also:
-
DEFAULT_MULTI_ENCODE_JOB_LOAD_FACTOR
public static final float DEFAULT_MULTI_ENCODE_JOB_LOAD_FACTOR- See Also:
-
JOB_LOAD_MAX_MULTIPLE_PROFILES
- See Also:
-
JOB_LOAD_FACTOR_PROCESS_SMIL
- See Also:
-
JOB_LOAD_FACTOR_MULTI_ENCODE
- See Also:
-
DEFAULT_MULTI_ENCODE_TRIM_MILLISECONDS
public static final int DEFAULT_MULTI_ENCODE_TRIM_MILLISECONDS- See Also:
-
MULTI_ENCODE_TRIM_MILLISECONDS
- See Also:
-
DEFAULT_MULTI_ENCODE_FADE_MILLISECONDS
public static final int DEFAULT_MULTI_ENCODE_FADE_MILLISECONDS- See Also:
-
MULTI_ENCODE_FADE_MILLISECONDS
- See Also:
-
-
Constructor Details
-
ComposerServiceImpl
public ComposerServiceImpl()Creates a new composer service instance.
-
-
Method Details
-
activate
public void activate(org.osgi.service.component.ComponentContext cc) OSGi callback on component activation.- Overrides:
activatein classAbstractJobProducer- Parameters:
cc- the component context
-
deactivate
public void deactivate()OSGi callback on component deactivation. -
encode
public Job encode(Track sourceTrack, String profileId) throws EncoderException, MediaPackageException Encode one track, using that track's audio and video streams.- Specified by:
encodein interfaceComposerService- Parameters:
sourceTrack- The source trackprofileId- The profile to use for encoding- Returns:
- The receipt for this encoding job. The receipt can be used with ComposerService#getJob to obtain the status of an encoding job.
- Throws:
EncoderExceptionMediaPackageException- See Also:
-
parallelEncode
public Job parallelEncode(Track sourceTrack, String profileId) throws EncoderException, MediaPackageException Encode one track to multiple other tracks in one encoding operation, using that track's audio and video streams.- Specified by:
parallelEncodein interfaceComposerService- Parameters:
sourceTrack- The source trackprofileId- The profile to use for encoding- Throws:
EncoderExceptionMediaPackageException- See Also:
-
trim
public Job trim(Track sourceTrack, String profileId, long start, long duration) throws EncoderException, MediaPackageException Trims the given track to the given start time and duration.- Specified by:
trimin interfaceComposerService- Parameters:
sourceTrack- The source trackprofileId- The profile to use for trimmingstart- start time in milisecondsduration- duration in miliseconds- Returns:
- The receipt for this encoding job. The receipt can be used with ComposerService#getJob to obtain the status of an encoding job.
- Throws:
EncoderException- if trimming failsMediaPackageException- if the mediapackage is invalid- See Also:
-
mux
public Job mux(Track videoTrack, Track audioTrack, String profileId) throws EncoderException, MediaPackageException Encode the video stream from one track and the audio stream from another, into a new Track.- Specified by:
muxin interfaceComposerService- Parameters:
videoTrack- The source video trackaudioTrack- The source audio trackprofileId- The profile to use for encoding- Returns:
- The receipt for this encoding job
- Throws:
EncoderException- if encoding failsMediaPackageException- if the mediapackage is invalid- See Also:
-
mux
public Job mux(Map<String, Track> sourceTracks, String profileId) throws EncoderException, MediaPackageExceptionMux multiple tracks into a new Track.- Specified by:
muxin interfaceComposerService- Parameters:
sourceTracks- The source tracksprofileId- The profile to use for encoding- Returns:
- The receipt for this encoding job
- Throws:
EncoderException- if encoding failsMediaPackageException- if the mediapackage is invalid- See Also:
-
composite
public Job composite(Dimension compositeTrackSize, Option<LaidOutElement<Track>> upperTrack, LaidOutElement<Track> lowerTrack, Option<LaidOutElement<Attachment>> watermark, String profileId, String background, String sourceAudioName) throws EncoderException, MediaPackageException Compose two videos into one with an optional watermark.- Specified by:
compositein interfaceComposerService- Parameters:
compositeTrackSize- The composite track dimensionupperTrack- upper track element from mediapackage (optional)lowerTrack- lower track element from mediapackagewatermark- watermark element (optional)profileId- Encoding profile namebackground- The background colorsourceAudioName- Use audio from only lower or upper track or both, use both when available if omitted- Returns:
- The receipt for this composite job
- Throws:
EncoderException- if encoding failsMediaPackageException- if the mediapackage is invalid
-
concat
public Job concat(String profileId, Dimension outputDimension, boolean sameCodec, Track... tracks) throws EncoderException, MediaPackageException Description copied from interface:ComposerServiceConcat multiple tracks to a single track.- Specified by:
concatin interfaceComposerService- Parameters:
profileId- The encoding profile to useoutputDimension- The output dimensionssameCodec- Defines if lossless concat should be usedtracks- an array of track to concat in order of the array- Returns:
- The receipt for this concat job
- Throws:
EncoderException- if encoding failsMediaPackageException- if the mediapackage is invalid
-
concat
public Job concat(String profileId, Dimension outputDimension, float outputFrameRate, boolean sameCodec, Track... tracks) throws EncoderException, MediaPackageException Description copied from interface:ComposerServiceConcat multiple tracks to a single track. Required ffmpeg version 1.1- Specified by:
concatin interfaceComposerService- Parameters:
profileId- The encoding profile to useoutputDimension- The output dimensionsoutputFrameRate- The output frame ratesameCodec- Defines if lossless concat should be usedtracks- an array of track to concat in order of the array- Returns:
- The receipt for this concat job
- Throws:
EncoderException- if encoding failsMediaPackageException- if the mediapackage is invalid
-
imageToVideo
public Job imageToVideo(Attachment sourceImageAttachment, String profileId, double time) throws EncoderException, MediaPackageException Description copied from interface:ComposerServiceTransforms an image attachment to a video track- Specified by:
imageToVideoin interfaceComposerService- Parameters:
sourceImageAttachment- The source image attachmentprofileId- The profile to use for encodingtime- the length of the resulting video track in seconds- Returns:
- The receipt for this image to video job
- Throws:
EncoderException- if encoding failsMediaPackageException- if the mediapackage is invalid
-
image
public Job image(Track sourceTrack, String profileId, double... times) throws EncoderException, MediaPackageException Extracts an image from the media package element identified bysourceVideoTrackId. The image is taken at the timepointtimeseconds into the movie.- Specified by:
imagein interfaceComposerService- Parameters:
sourceTrack- the source video trackprofileId- identifier of the encoding profiletimes- number of seconds into the video- Returns:
- the extracted image as an attachment
- Throws:
EncoderException- if image extraction failsMediaPackageException- if the mediapackage is invalid- See Also:
-
imageSync
public List<Attachment> imageSync(Track sourceTrack, String profileId, double... time) throws EncoderException, MediaPackageException Description copied from interface:ComposerServiceSynchronously extracts images from the source track. The images are taken at the given timepoints (seconds into the movie). Please note that synchronously doing this means, that the workload cannot be distributed amongst all nodes. This should be used rarely.- Specified by:
imageSyncin interfaceComposerService- Parameters:
sourceTrack- the source video trackprofileId- identifier of the encoding profiletime- number of seconds into the video- Returns:
- the extracted images as attachments
- Throws:
EncoderException- if image extraction failsMediaPackageException- if the mediapackage is invalid
-
image
public Job image(Track sourceTrack, String profileId, Map<String, String> properties) throws EncoderException, MediaPackageExceptionDescription copied from interface:ComposerServiceExtracts an image from the media package element identified bysourceTrack. The image is taken by the given properties and the corresponding encoding profile.- Specified by:
imagein interfaceComposerService- Parameters:
sourceTrack- the source video trackprofileId- identifier of the encoding profileproperties- the properties applied to the encoding profile- Returns:
- the extracted image as an attachment
- Throws:
EncoderException- if image extraction failsMediaPackageException- if the mediapackage is invalid
-
convertImage
public Job convertImage(Attachment image, String... profileIds) throws EncoderException, MediaPackageException Converts the given image to a different image format using the specified image profiles.- Specified by:
convertImagein interfaceComposerService- Parameters:
image- the imageprofileIds- the profiles to use for conversion- Returns:
- the job for the image conversion
- Throws:
EncoderException- if image conversion failsMediaPackageException- if the mediapackage is invalid- See Also:
-
convertImageSync
public List<Attachment> convertImageSync(Attachment image, String... profileIds) throws EncoderException, MediaPackageException Synchronously converts the given image to different image formats using the specified encoding profiles. Please note that synchronously doing this means that the workload cannot be distributed amongst all nodes.- Specified by:
convertImageSyncin interfaceComposerService- Parameters:
image- the imageprofileIds- the profiles to use for conversion- Returns:
- the converted images
- Throws:
EncoderException- if image conversion failsMediaPackageException- if the mediapackage is invalid- See Also:
-
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:
ServiceRegistryException- See Also:
-
listProfiles
- Specified by:
listProfilesin interfaceComposerService- Returns:
- All registered
EncodingProfiles. - See Also:
-
getProfile
Gets a profile by its ID- Specified by:
getProfilein interfaceComposerService- Parameters:
profileId- The profile ID- Returns:
- The encoding profile, or null if no profile is registered with that ID
- See Also:
-
inspect
protected List<Track> inspect(Job job, List<URI> uris, List<List<String>> tags) throws EncoderException - Throws:
EncoderException
-
inspect
- Throws:
EncoderException
-
inspect
- Throws:
EncoderException
-
hlsFixReference
- Throws:
IOException
-
hlsSetReference
- Throws:
IOException
-
setMediaInspectionService
Sets the media inspection service- Parameters:
mediaInspectionService- an instance of the media inspection service
-
setWorkspace
Sets the workspace- Parameters:
workspace- an instance of the workspace
-
setServiceRegistry
Sets the service registry- Parameters:
serviceRegistry- the service registry
-
getServiceRegistry
Returns a reference to the service registry.- Specified by:
getServiceRegistryin classAbstractJobProducer- Returns:
- the service registry
- See Also:
-
setProfileScanner
Sets the profile scanner.- Parameters:
scanner- the profile scanner
-
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:
-
setSmilService
-
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:
-
setEncodingProfileReadinessIndicator
-
demux
public Job demux(Track sourceTrack, String profileId) throws EncoderException, MediaPackageException Description copied from interface:ComposerServiceDemux a multi-track source into 2 media as defined by the encoding profile, the results are flavored and tagged positionally. eg: One ffmpeg operation to produce presenter/work and presentation/work- Specified by:
demuxin interfaceComposerService- Parameters:
sourceTrack-profileId-- Returns:
- Receipt for this demux based on the profile
- Throws:
EncoderExceptionMediaPackageException
-
modified
OSGI callback when the configuration is updated. This method is only here to prevent the configuration admin service from calling the service deactivate and activate methods for a config update. It does not have to do anything as the updates are handled by updated().- Throws:
org.osgi.service.cm.ConfigurationException
-
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
-
processSmil
public Job processSmil(Smil smil, String trackparamId, String mediaType, List<String> profileIds) throws EncoderException, MediaPackageException ProcessSmil processes editing of one source group (which may contain multiple source tracks) to one set of outputs (to one or more encoding profiles). Note that the source tracks are expected to have the same dimensions.- Specified by:
processSmilin interfaceComposerService- Parameters:
smil- - smil containing with video names and clip sections from themtrackparamId- - group idmediaType- - VIDEO_ONLY, AUDIO_ONLY, or "" if neither is trueprofileIds- - list of encoding profile Ids- Returns:
- Compose Job
- Throws:
EncoderException- - if encoding failsMediaPackageException- - if missing files or bad mp
-
processSmil
protected List<Track> processSmil(Job job, Smil smil, String trackParamGroupId, String mediaType, List<String> encodingProfiles) throws EncoderException, MediaPackageException, URISyntaxException Splice segments given by smil document for the given track to the new one. This function reads the smil file and reduce them to arguments to send to the encoder- Parameters:
job- processing jobsmil- smil document with media segments descriptiontrackParamGroupId- source track groupmediaType- VIDEO_ONLY or AUDIO_ONLY or "" if it has bothencodingProfiles- - profiles- Returns:
- serialized array of processed tracks
- Throws:
EncoderException- if an error occurredMediaPackageException- - bad MediapackageURISyntaxException
-
multiEncode
public Job multiEncode(Track sourceTrack, List<String> profileIds) throws EncoderException, MediaPackageException Description copied from interface:ComposerServiceEncodes a track to set of media targets as defined by a list of encoding profiles- Specified by:
multiEncodein interfaceComposerService- Parameters:
sourceTrack- - video or audio trackprofileIds- - a list of encoding profiles by name- Returns:
- Receipt for this processing based on the inputs
- Throws:
EncoderException- if it failsMediaPackageException- if adding files to a mediapackage produces errors
-
multiEncode
protected List<Track> multiEncode(Job job, Track track, List<String> profileIds) throws EncoderException, IllegalArgumentException A single encoding process that produces multiple outputs from a single track(s) using a list of encoding profiles. Each output can be tagged by the profile name. This supports adaptive bitrate outputs.- Parameters:
job- - encoding jobtrack- - source trackprofileIds- - list of encoding profile Ids, can include one adaptive profile- Returns:
- encoded files
- Throws:
EncoderException- - if can't encodeIllegalArgumentException- - if missing arguments
-