百度智能云

All Product Document

          Multimedia Cloud Processing

          Thumbnail-Job

          The thumbnail is a small picture of photos and video processed by compression. Due to its small size and fast loading speed, it is used for quick browsing. The thumbnail job can be used to create thumbnails for multimedia resources in BOS.

          Create Thumbnail Job

          Generate thumbnails for the assigned media through pipeline, BOS Key and other configuration information, and access the returned thumbnail job. Users can refer to the following codes:

          public void createThumbnailJob(MediaClient client, String pipelineName, String sourceKey) { 
              ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg").withSizingPolicy("keep"); 
          
              ThumbnailCapture capture = 
                      new ThumbnailCapture().withMode("manual").withStartTimeInSecond(0) 
                      .withEndTimeInSecond(5).withIntervalInSecond(1); 
          
              String jobId = 
                      mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); 
          
          } 

          To create a thumbnail with watermark and black edge removed, you can refer to the following codes:

          public void createThumbnailJob(MediaClient client, String pipelineName, String sourceKey, Area delogoArea, 
                      Area crop) { 
              ThumbnailTarget target = new ThumbnailTarget().withFormat("gif").withSizingPolicy("keep"); 
          
              ThumbnailCapture capture = 
                      new ThumbnailCapture().withMode("split").withFrameNumber(10); 
              String jobId = 
                      mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture, delogoArea, crop).getJobId(); 
          } 

          Query Assigned Thumbnail Job

          If you need to get a created thumbnail job information, you can refer to the following code:

          public void getThumbnailJob(MediaClient client, String jobId) { 
              GetThumbnailJobResponse resp = mediaClient.getThumbnailJob(jobId); 
          
              System.out.println("  jobId = " + resp.getJobId()); 
              System.out.println("  pipelineName = " + resp.getPipelineName()); 
              System.out.println("  jobStatus = " + resp.getJobStatus()); 
              System.out.println("  source.key = " + resp.getSource().getKey()); 
              System.out.println("  target.keyPrefix = " + resp.getTarget().getKeyPrefix()); 
              System.out.println("  target.format = " + resp.getTarget().getFormat()); 
              System.out.println("  target.sizingPolicy = " + resp.getTarget().getSizingPolicy()); 
              System.out.println("  target.heightInPixel = " + resp.getTarget().getHeightInPixel()); 
              System.out.println("  target.widthInPixel = " + resp.getTarget().getWidthInPixel()); 
              System.out.println("  target.keys = " + resp.getTarget().getKeys()); 
              System.out.println("  capture.mode = " + resp.getCapture().getMode()); 
              System.out.println("  capture.startTimeInSecond = " + resp.getCapture().getStartTimeInSecond()); 
              System.out.println("  capture.endTimeInSecond = " + resp.getCapture().getEndTimeInSecond()); 
              System.out.println("  capture.intervalInSecond = " + resp.getCapture().getIntervalInSecond()); 
              System.out.println("  capture.frameNumber = " + resp.getCapture().getFrameNumber()); 
          } 

          Query the Thumbnail Jobs of Assigned Pipeline

          To get the information about all thumbnail jobs in a pipeline, you can see the following code:

          public void listThumbnailJobs(MediaClient client, String pipelineName) { 
              ListThumbnailJobsResponse resp = mediaClient.listThumbnailJobs(pipelineName); 
          
              for (ThumbnailJobStatus job : resp.getThumbnails()) { 
                  System.out.println("  jobId = " + job.getJobId()); 
                  System.out.println("  pipelineName = " + job.getPipelineName()); 
                  System.out.println("  jobStatus = " + job.getJobStatus()); 
                  System.out.println("  source.key = " + job.getSource().getKey()); 
                  System.out.println("  target.keyPrefix = " + job.getTarget().getKeyPrefix()); 
                  System.out.println("  target.format = " + job.getTarget().getFormat()); 
                  System.out.println("  target.sizingPolicy = " + job.getTarget().getSizingPolicy()); 
                  System.out.println("  target.heightInPixel = " + job.getTarget().getHeightInPixel()); 
                  System.out.println("  target.widthInPixel = " + job.getTarget().getWidthInPixel()); 
                  System.out.println("  target.keys = " + job.getTarget().getKeys()); 
                  System.out.println("  capture.mode = " + job.getCapture().getMode()); 
                  System.out.println("  capture.startTimeInSecond = " + job.getCapture().getStartTimeInSecond()); 
                  System.out.println("  capture.endTimeInSecond = " + job.getCapture().getEndTimeInSecond()); 
                  System.out.println("  capture.IntervalInSecond = " + job.getCapture().getIntervalInSecond()); 
                  System.out.println(); 
              } 
          
          } 
          Previous
          Mediainfo
          Next
          Watermark