Class TimelinePreviewsServiceImpl

java.lang.Object
org.opencastproject.job.api.AbstractJobProducer
org.opencastproject.timelinepreviews.ffmpeg.TimelinePreviewsServiceImpl
All Implemented Interfaces:
JobProducer, TimelinePreviewsService, org.osgi.service.cm.ManagedService

public class TimelinePreviewsServiceImpl extends AbstractJobProducer implements TimelinePreviewsService, org.osgi.service.cm.ManagedService
Media analysis plugin that takes a video stream and generates preview images that can be shown on the timeline. This will be done using FFmpeg.
  • 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
      The key to look for in the service configuration file to override the DEFAULT_FFMPEG_BINARY
      See Also:
    • FFMPEG_BINARY_DEFAULT

      public static final String FFMPEG_BINARY_DEFAULT
      The default path to the FFmpeg binary
      See Also:
    • OPT_RESOLUTION_X

      public static final String OPT_RESOLUTION_X
      Name of the constant used to retrieve the horizontal resolution
      See Also:
    • DEFAULT_RESOLUTION_X

      public static final int DEFAULT_RESOLUTION_X
      Default value for the horizontal resolution
      See Also:
    • OPT_RESOLUTION_Y

      public static final String OPT_RESOLUTION_Y
      Name of the constant used to retrieve the vertical resolution
      See Also:
    • DEFAULT_RESOLUTION_Y

      public static final int DEFAULT_RESOLUTION_Y
      Default value for the vertical resolution
      See Also:
    • OPT_OUTPUT_FORMAT

      public static final String OPT_OUTPUT_FORMAT
      Name of the constant used to retrieve the output file format
      See Also:
    • DEFAULT_OUTPUT_FORMAT

      public static final String DEFAULT_OUTPUT_FORMAT
      Default value for the format of the output image file
      See Also:
    • OPT_MIMETYPE

      public static final String OPT_MIMETYPE
      Name of the constant used to retrieve the mimetype
      See Also:
    • DEFAULT_MIMETYPE

      public static final String DEFAULT_MIMETYPE
      Default value for the mimetype of the generated image
      See Also:
    • DEFAULT_TIMELINEPREVIEWS_JOB_LOAD

      public static final float DEFAULT_TIMELINEPREVIEWS_JOB_LOAD
      The default job load of a timeline previews job
      See Also:
    • TIMELINEPREVIEWS_JOB_LOAD_KEY

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

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

      protected int resolutionX
      The horizontal resolution of a single preview image
    • resolutionY

      protected int resolutionY
      The vertical resolution of a single preview image
    • outputFormat

      protected String outputFormat
      The file format of the generated preview images file
    • mimetype

      protected String mimetype
      The mimetype that will be set for the generated Attachment containing the timeline previews image
    • serviceRegistry

      protected ServiceRegistry serviceRegistry
      Reference to the receipt 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

    • TimelinePreviewsServiceImpl

      public TimelinePreviewsServiceImpl()
      Creates a new instance of the timeline previews 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)
    • createTimelinePreviewImages

      public Job createTimelinePreviewImages(Track track, int imageCount) throws TimelinePreviewsException, MediaPackageException
      Description copied from interface: TimelinePreviewsService
      Takes the given track and returns the job that can be used to generate timeline preview images.
      Specified by:
      createTimelinePreviewImages in interface TimelinePreviewsService
      Parameters:
      track - track to generate preview images for
      imageCount - number of preview images that will be generated
      Returns:
      the job that can generate the preview images
      Throws:
      TimelinePreviewsException - if the timeline preview images could not be generated
      MediaPackageException - if the track is invalid
    • generatePreviewImages

      protected Attachment generatePreviewImages(Job job, Track track, int imageCount) throws TimelinePreviewsException, MediaPackageException
      Starts generation of timeline preview images for the given video track and returns an attachment containing one image that contains all the timeline preview images.
      Parameters:
      job -
      track - the element to analyze
      imageCount - number of preview images that will be generated
      Returns:
      an attachment containing the resulting timeline previews image
      Throws:
      TimelinePreviewsException
      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:
    • createPreviewsFFmpeg

      protected Attachment createPreviewsFFmpeg(Track track, double seconds, int width, int height, int tileX, int tileY, double duration) throws TimelinePreviewsException
      Executes the FFmpeg command to generate a timeline previews image
      Parameters:
      track - the track to generate the timeline previews image for
      seconds - the length of a segment that one preview image should represent
      width - the width of a single preview image
      height - the height of a single preview image
      tileX - the horizontal number of preview images that are stored in the timeline previews image
      tileY - the vertical number of preview images that are stored in the timeline previews image
      duration - the duration for which preview images should be generated
      Returns:
      an attachment containing the timeline previews image
      Throws:
      TimelinePreviewsException
    • setWorkspace

      protected void setWorkspace(Workspace workspace)
      Sets the workspace
      Parameters:
      workspace - an instance of the workspace
    • 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: