百度智能云

All Product Document

          Multimedia Cloud Processing

          Preset

          A preset is a preset set of definitions required for a video resource to perform transcoding calculations. Users can more easily apply a preset to one or more video transcoding jobs, so that these jobs output target video resources of the same specifications.

          MCT provides the users with rich and complete system presets to meet the user's common requirements for format, code rate, resolution, encryption and decryption, watermark and others in terms of target specifications, and it is the best choice for the users who do not want to know too much about the complex technological background of audios and videos. Baidu has abundant accumulated users in AV technology, providing customized transcoding presets to satisfy the transcoding requirements under complicated business conditions of them.

          When you only have to modify the container format of audio and video, Baidu provides Transmux presets to help you quickly convert the container format in a second-level delay, such as converting from MP4 to HLS, while keeping the original audio and video property unchanged.

          Please refer to Preset-API for the meaning of each parameter and value methods for preset interface.

          Query Presets of Current User and All System Presets

          You can query all the Presets via the following code.

          response = client.list_presets() 
          
          for preset in response.presets: 
            print preset 

          Query Assigned Preset Information

          The user can assign certain Preset through the following code:

          preset_name = "your_preset"
          response = client.get_preset(preset_name) 
          print response 

          Create Preset

          If the Preset in the system cannot meet the user's requirements, the user can custom their own Preset. Use different interfaces to create Preset according to different coding requirements.

          Create the preset that only supports container format conversion

          Only the container format conversion Preset is executed for the creation of the following codes:

          preset_name = "your_preset"
          container = "hls" 
          response = client.create_preset(preset_name, container) 
          print response 

          To create the transcoding Preset of audio file, you do not need to make an episode and encryption

          If you create an audio file transcoding Preset without clip interception and encryption, you can refer to the following code:

          preset_name = "your_preset"
          container = "mp3" 
          audio = {'bitRateInBps': 25600, 'sampleRateInHz': 32000, 'channels': 1} 
          response = client.create_preset(preset_name, container, audio=audio) 
          print response 

          Create audio file transcoding Preset, the clip interception attribute and encryption attribute should be set

          If you create a video file transcoding Preset supporting clip interception and encryption, you can refer to the following code:

          preset_name = "your_preset"
          container = "mp4" 
          
          clip = {'startTimeInSecond':0, 'durationInSecond': 50} 
          audio = {'bitRateInBps': 1980, 'sampleRateInHz': 32000, 'channels': 1} 
          encryption = {'aesKey': 'abcdefghij123456','strategy': 'Fixed'} 
          response = client.create_preset(preset_name, container, clip=clip, audio=audio, encryption=encryption) 
          print response 

          Create video file transcoding Preset, the clip interception and encryption are not needed

          If you create an audio file transcoding Preset without clip interception and encryption, you can refer to the following code:

          preset_name = "your_preset"
          container = "mp4" 
          codecOptions = {'profile': 'baseline'} 
          video = { 
              'codec': 'h264', 
              'codecOptions': codecOptions, 
              'bitRateInBps': 32000, 
              'maxFrameRate': 30, 
              'maxWidthInPixel': 4096, 
              'maxHeightInPixel': 96, 
              'sizingPolicy': 'stretch' 
          } 
          audio = {'bitRateInBps': 1980, 'sampleRateInHz': 32000, 'channels': 1} 
          response = client.create_preset(preset_name, container, video=video, audio=audio) 
          print response 

          Create video file transcoding Preset, the clip interception attribute and encryption attribute should be set

          If you create a captured clip and encrypted audio file transcoding Preset, you can refer to the following code:

          preset_name = "your_preset"
          container = "mp4" 
          codecOptions = {'profile': 'baseline'} 
          video = { 
              'codec': 'h264', 
              'codecOptions': codecOptions, 
              'bitRateInBps': 32000, 
              'maxFrameRate': 30, 
              'maxWidthInPixel': 4096, 
              'maxHeightInPixel': 96, 
              'sizingPolicy': 'stretch' 
          } 
          clip = {'startTimeInSecond':0, 'durationInSecond': 50} 
          audio = {'bitRateInBps': 1980, 'sampleRateInHz': 32000, 'channels': 1} 
          encryption = {'aesKey': 'abcdefghij123456','strategy': 'Fixed'} 
          response = client.create_preset(preset_name, container, video=video, clip=clip, audio=audio, encryption=encryption) 
          print response 

          Create Preset and assign all the parameters

          If you need to customize all the configuration parameters, you can refer to the following code:

          preset_name = "your_preset"
          
          container = "mp4" 
          desc = 'My Desc' 
          transmux = True 
          codecOptions = {'profile': 'baseline'} 
          video = { 
              'codec': 'h264', 
              'codecOptions': codecOptions, 
              'bitRateInBps': 32000, 
              'maxFrameRate': 30, 
              'maxWidthInPixel': 4096, 
              'maxHeightInPixel': 96, 
              'sizingPolicy': 'stretch' 
          } 
          clip = {'startTimeInSecond':0, 'durationInSecond': 50} 
          audio = {'bitRateInBps': 1980, 'sampleRateInHz': 32000, 'channels': 1} 
          encryption = {'aesKey': 'abcdefghij123456','strategy': 'Fixed'} 
          response = client.create_preset(preset_name, container, transmux=transmux, description=desc, video=video, clip=clip, audio=audio, encryption=encryption) 
          print response 

          Update Preset

          The user can modify the self-created presets.

          The following code can update the audio target code rate of the assigned preset:

          preset_name = "your_preset"
          preset = self.the_client.get_preset_for_update(preset_name) 
          preset.audio.bitRateInBps = 256000
          response = self.the_client.update_preset(preset_name, preset) 
          print response 

          Similar to updating the other parameters.

          Previous
          Job
          Next
          Mediainfo