This topic introduces the basic concepts related to jobs and ApsaraVideo Media Processing (MPS) queues and their associations to help you better understand and use MPS.

Processing logic

  1. Submit jobs in synchronous mode: A user submits jobs to be processed in synchronous mode.
  2. Submit jobs in asynchronous mode: Jobs are scheduled in an MPS queue based on the job priorities and the sequence in which the jobs are submitted.
  3. Send notifications: If a Message Service (MNS) topic or queue is bound to the MPS queue, a notification is sent to the user after each job is run.

Concepts

  • Job

    MPS supports multiple types of jobs, such as transcoding jobs, video snapshot jobs, and media information analysis jobs.

    A job contains three key types of information: input files, output files, and parameters. The input files are uploaded for processing, and the output files are generated after the job is run. The parameters are used to set the configurations for implementing specific features.

  • MPS queue
    After a user submits jobs in the MPS console or by calling API operations, the jobs wait to be run in an MPS queue based on the job priorities and the sequence in which the jobs are submitted.
    Note You can set different priorities for jobs in an MPS queue. If you submit jobs by calling API operations, you can set priorities that range from 1 to 10 for the jobs. If you submit jobs in the MPS console, the priority for all jobs is automatically set to 6 and cannot be modified. For jobs with the same priority, those that are submitted earlier are run before those that are submitted later. For jobs with different priorities, MPS runs jobs with higher priorities at first.
  • Parameter
    • Template parameter

      Different transcoding jobs share some configurations. To reduce the workload of setting duplicate parameters each time you submit a transcoding job, MPS provides you with transcoding templates that combine common parameters required for running transcoding jobs. This simplifies the code required to submit transcoding jobs. Transcoding templates can be shared by different jobs.

    • API parameter

      If you create templates for each combination of parameters, the increased number of templates brings difficulties to template management. Therefore, you can set parameters when you call an API operation in addition to using a template with parameters. The API parameters that you set for a job take effect only for that job.

    • Overwriting rule

      If you specify a transcoding template and set API parameters when you call an API operation to submit a transcoding job, the API parameters have a higher priority and overwrite the corresponding parameters in the transcoding template.

      For example, a video file can be transcoded to videos with different definitions, such as the standard definition (SD) and high definition (HD). Videos with different definitions all use the MP4 format and the H.264 video encoding standard. The frame rate for these videos is 25 frames per second. The difference among the videos lies only in the bitrate and resolution. In this case, you can create a template with default parameters that specify the MP4 video format, the H.264 video encoding standard, the frame rate of 25 frames per second, the bitrate of 2 Mbit/s, and the resolution of 1,280 × 720 pixels. If you call an API operation to submit a transcoding job and do not set API parameters, the configurations of the bitrate and resolution specified in the template take effect. If you set the bitrate to 4 Mbit/s and the resolution to 1,920 × 1,080 pixels by setting API parameters, the API parameters take effect.

  • Job execution and result query

    The time required for running different types of jobs varies. Some jobs are immediately complete after they are submitted while others are not. In other words, jobs are run in synchronous and asynchronous modes.

    • Synchronous mode

      The results of a job such as a video snapshot job are immediately returned after the job is run.

    • Asynchronous mode
      The results of a job such as a transcoding job can be queried by using periodic polling or notifications.
      • Periodic polling

        Each job is identified by a unique ID, which is immediately returned after the job is submitted in the MPS console or by calling an API operation. You can view the ID of the job in the data that is returned by the MPS console or the API operation. After that, you can query the results of the job by using the job ID. However, you may not obtain the results at the earliest opportunity by using this method.

      • Notification
        If you bind an MNS topic or queue to the MPS queue, you can obtain the results of a job in a timely manner. A notification contains the ID of the job, user data, and results.
        • Job ID

          You can record the ID of each job when you submit the job. Then, you can trace the results of the job based on the job ID sent in a notification.

        • User data

          If you set custom parameters of user data, such as the ID of a commodity, when you submit a job, the custom parameters are returned in a notification. This way, you can associate the user data with your business based on the custom parameters without the need to record the job ID.