百度智能云

All Product Document

          Multimedia Cloud Processing

          Watermark

          The digital watermark is to add some figure information to data multimedia (such as, image, audio, video signal and others) to identify the true or false documents, protect the copyright, etc. The embedded watermark information is hidden in the host file, without affecting the observability and integrity of the original file.

          Users can create one Object in BOS into watermark, and get corresponding watermarkId. And then, add the watermark into the target multi-media file during the transcoding job.

          Create Watermark

          If you need to create a watermark, assign the watermark position and get the unique ID, you can refer to the following code:

          public void createWaterMark(MediaClient client, String bucket, String key) { 
              CreateWaterMarkResponse watermark = mediaClient.createWaterMark(bucket, key, "left", “top”); 
              System.out.println("new watermarkId: " + watermark.getWatermarkId()); 
          } 

          If you need to create a watermark, assign the watermark position, display timeline, duplication display times (dynamic watermark) and auto-shrinking, and get the unique watermark ID, you can refer to the following code:

          public void createWaterMark(MediaClient client, String bucket, String key, 
                      String horizontalAlignment, String verticalAlignment, 
                      int horizontalOffsetInPixel, int verticalOffsetInPixel, 
                      Timeline timeline, Integer repeated, Boolean allowScaling) { 
              CreateWaterMarkResponse watermark = mediaClient.createWaterMark(bucket, key, horizontalAlignment, 
                  verticalAlignment, timeline, repeated, allowScaling); 
              System.out.println("new watermarkId: " + watermark.getWatermarkId()); 
          } 

          The interface returns an object containing watermarkId

          Create Watermark Transcoding Job

          To add watermark to target multimedia file, create a transcoding Preset with watermark, and then create transcoding jobs by use of the Preset. You can set Preset.watermarkId or Preset.watermarks. It takes setting Preset.watermarkId as an example here.

          public void createPreset(MediaClient client, String presetName, String description, String container, 
                      Clip clip,Audio audio, Video video, Encryption encryption, String watermarkId) { 
          
              client.createPreset(presetName, description, container, clip, audio, video, encryption, watermarkId); 
          
              String jobId = client.createJob(pipelineName, sourceKey, targetKey, presetName).getJobId(); 
          } 

          Please refer to Create Transcoding Configurations for Video Files for codes and Create Video File Transcoding Job.

          Query Assigned Watermark

          If you need to query the created watermark, you can refer to the following code:

          public void getWaterMark(MediaClient client, String watermarkId) { 
              GetWaterMarkResponse watermark = mediaClient.getWaterMark(watermarkId); 
              System.out.println("watermarkId: " + watermark.getWatermarkId()); 
              System.out.println("createTime: " + watermark.getCreateTime()); 
              System.out.println("bucket: " + watermark.getBucket()); 
              System.out.println("key: " + watermark.getKey()); 
              System.out.println("horizontalOffsetInPixel: " + watermark.getHorizontalOffsetInPixel()); 
              System.out.println("verticalOffsetInPixel: " + watermark.getVerticalOffsetInPixel()); 
          } 

          Query the Watermark of the Current User

          If you need to query all the watermarks created by the current user, you can refer to the following code:

          public void getWaterMark(MediaClient client) { 
              List<WaterMark> watermarks = mediaClient.listWaterMark().getWatermarks(); 
              for (WaterMark watermark : watermarks) { 
                  System.out.println("watermarkId = " + watermark.getWatermarkId()); 
                  System.out.println("bucket = " + watermark.getBucket()); 
                  System.out.println("key = " + watermark.getKey()); 
                  System.out.println("createTime = " + watermark.getCreateTime()); 
                  System.out.println("horizontalOffsetInPixel = " + watermark.getHorizontalOffsetInPixel()); 
                  System.out.println("VerticalOffsetInPixel = " + watermark.getVerticalOffsetInPixel()); 
                  System.out.println(); 
              } 
          } 

          Delete Watermark

          If you need to delete a watermark with a given watermarkId, you can refer to the following code:

          public void getWaterMark(MediaClient client, String watermarkId) { 
              client.deleteWaterMark(watermarkId); 
          } 
          Previous
          Thumbnail-Job
          Next
          Notification