[API Advanced Road] It’s too bald, the boss wants me to detect and import 10,000 hours of video within a week

Summary: When I come back to work after the holiday and walk into the elevator, I have a special feeling. The big brother in the hair transplant advertisement of the elevator looks at me differently...

As mentioned last time, the boss rewarded 7 days of paid leave, so I went home and played for a few days. By the way, I also helped my brother to become an "AI God". (Review: "OCR text recognition can be done without an AI engineer" )

When I came back to work after the holiday, I felt a special feeling when I walked into the elevator. The eldest brother in a certain hair transplant advertisement in the elevator looked at me differently from before... The first meeting at the company turned out that his eyes looked like one Herald.

The boss said at the meeting that the video team recently discussed a cooperation and shared content with another short video platform, which can provide nearly 10,000 hours of video content for our video website, and hopes that research and development will support the import of videos.

I thought to myself: "It's easy, isn't it just importing the video? Just write a script." I gave the boss a "hand it to me" look, and the boss returned me with a "look at you" smile. Just like that, this matter fell on me. Thinking about it now, it may be that when I returned to Beijing, I didn't buy a ticket for my mind, and when people came back, my mind was in my hometown...

After the meeting, I asked the boss of the short video operator for the needs, and he gave 3 points:

  • First: All imported videos must be watermarked;
  • Second: The video format to be imported does not match the format required by our current website, and all videos must be converted;
  • Third: It is necessary to check the imported video content to prevent any illegal content from appearing.

Finally, he added: "It's best to complete it within a week. The boss wants to be online as soon as possible."

Are you kidding me? For 10,000 hours of video, if you want to convert the format and add watermark, you still need to check the content security, which is completed in a week? I suddenly understood the meaning of the big brother's eyes in the elevator advertisement...

Batch conversion and watermarking are a good solution, but this safety check...While pursing my hair straight, I habitually visit Huawei Cloud for inspiration.

We have used the image content detection API before , which can be used to detect whether a picture has illegal or disciplinary content, but the video does not seem to be usable. If you can take a screenshot of every frame of the video, can it be detected? Keep looking, and sure enough, there is a " video screenshot API " !

First use the video screenshot API to set up automatic screenshot tasks, and then use the image content detection API to determine whether there is content risk, and use the transcoding template and watermark template provided by the media processing MPC to solve the problem of watermarking and formatting. Perfect solution!

The way to submit a video screenshot task is as follows:

Precondition

  • Get the project ID of the task area where you need to create a screenshot ( get the project ID ).
  • It is clear that you need to create the information of the area where the screenshot task is located, and obtain the Endpoint of the area (obtained by the area and terminal node ).
  • Call the OBS Create Bucket API to create an OBS bucket for storing screenshot files, and then call the OBS Upload Object API to store the video files to be screenshot processed in the OBS bucket.

Steps

Step 1: Obtain user token. When used for MPC interface for authentication and authentication.

Obtain username, password, domainname, projectname on the "My Credentials" page, and call the following interface to obtain Token.

POST https://iam.cn-north-4.myhuaweicloud.com/v3/auth/tokens
Content-Type: application/json
{
  "auth": {
    "identity": {
      "methods": [
        "password"
      ],
      "password": {
        "user": {
          "name": "username", //用户名。
          "password": "password", //用户登录密码。
          "domain": {
            "name": "domainname" //用户所属的账号名称。  
          }
        }
      }
    },
    "scope": {
      "project": {
         "name": "projectname"  //项目名称。
      }
    }
  }
}

As shown in the figure, the information in the red box is to obtain user Token.

Step 2: Create a screenshot task

1. Send a POST request.

POST:https://{endpoint}/v1/{project_id}/thumbnails

2. Add "X-Auth-Token" to the request message header, and set the value to the obtained user token.

3. The parameters passed in the Request Body are as follows:

{
"input": {
           "bucket": "example-bucket",
           "location": "region01",
           "object": "/mpc/input/sample.MP4"
},
"output": {
           "bucket": "example-bucket",
           "location": "region01",
           "object": "/mpc/output/ "},

"tar": 1,
"thumbnail_para": {   
        "type":"DOTS",
        "dots":[2,4,6,8,10],      
        "format":0,    
        "aspect_ratio":1,     
        "max_length":480  
        } 
} 

4. After the request response is successful, feedback the screenshot task ID.

{
    "task_id": "2081"
}

Step 3: Query the execution of video screenshots

1. Send a GET request.

GET:https://{endpoint}/v1/{project_id}/thumbnails?task_id=2081

2. Add "X-Auth-Token" to the request message header, and set the value to the obtained user token. After the request response is successful, the detailed information of the video screenshot is returned.

After the screenshot is completed, the screenshots are transferred to the created OBS bucket, and then the screenshot is reviewed for the content of the image and it is OK!

After writing the program, the video was automatically uploaded. I went downstairs to eat and looked at the big brother who looked at the billboard in the elevator. Now his eyes are normal~

Learn more about HUAWEI CLOUD API: " Free download of the innovation acceleration tool "Huawei Cloud API Selection Manual"

 

Click to follow and learn about Huawei Cloud's fresh technology for the first time~

Guess you like

Origin blog.csdn.net/devcloud/article/details/108824094