All Products
Search
Document Center

:Server-side integration

Last Updated:Jun 20, 2026

The ApsaraVideo for Short Video server handles data exchange with the client app and ApsaraVideo VOD, processes business logic, and manages operational data. This topic explains the server-side integration process.

Prerequisites

Procedure

Upload the source code

  1. Download the source code for the AppServer and management console of ApsaraVideo for Short Video. For the download link, see ApsaraVideo for Short Video.

  2. On the server where the source file is stored, run the following command to upload the source code package to the ECS instance.

    scp <source_code_file> user@<ECS_instance_IP>:<destination_path>

    scp ApsaraVideo_QuVideo_v1.4.0_Server_20191226.zip user@10.0.0.0:/home/user/workspace/

    ApsaraVideo_QuVideo_v1.4.0_Server_20191226.zip is the source code file, user is the ECS instance username, 10.0.0.0 is the ECS instance IP address, and /home/user/workspace/ is the upload path.

    Note

    The source code file, ECS username, ECS instance IP address, and upload path are examples. Replace the sample values with your actual information.

  3. Log on to the ECS instance and unzip the source code package.

    cd /home/user/workspace

    unzip ApsaraVideo_QuVideo_v1.4.0_Server_20191226.zip

    Note

    If unzip is not installed, run sudo apt install unzip.

Initialize and configure the database

Note

You can build a self-managed music library.

  • The data structure returned by your service must match the one from the Alibaba Cloud service for music list retrieval; otherwise, the retrieval will fail.

  • If you use a custom data structure, adjust the code logic in the demo layer.

  1. Create a database named voddemo.

    cd /home/user/workspace/ApsaraVideo_QuVideo_v1.4.0_Server_20191226/sql

    mysqladmin -u root -p create voddemo

  2. Create a table and an administrator account.

    mysql -u root -p voddemo < ./appserver_create_table.sql

    Note

    In addition to creating the table, the appserver_create_table.sql script uses an INSERT statement to create a console administrator account with the username admin and password 123456. You can use this account to log on to the demo console as an administrator once the console is integrated.

  3. Modify the case sensitivity rule of the database.

    1. Edit the database configuration file.

      sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf

    2. Press the I key and add lower_case_table_names=1 to the end of the file.

    3. Press Esc, then enter :wq! to save and exit.

    4. Restart the database for the change to take effect.

      sudo service mysql restart

  4. Configure the database address.

    1. Edit the source code configuration file.

      vim /home/user/workspace/ApsaraVideo_QuVideo_v1.4.0_Server_20191226/src/main/resources/application.properties

    2. Press I and modify the following parameters.

      spring.datasource.url = jdbc:mysql://<Database_IP_address (e.g., 127.0.0.1)>:3306/<Database_name (e.g., voddemo)>?useSSL=false&useUnicode=true&characterEncoding=UTF-8
      spring.datasource.username = <Database_username, e.g., admin>
      spring.datasource.password = <Database_password>
      Note
      • If both the database and the server run on the same ECS instance, you can set the database IP address to 127.0.0.1. Otherwise, use the IP address of the machine where the database is located.

      • The database created during initialization is named voddemo.

    3. Press Esc, then enter :wq! to save and exit.

Configure a RAM role

  1. Follow the steps in Create a role. After selecting permissions in Step 6, proceed with the steps below. You can define a custom role name. This topic uses alivc-demo-role as an example.

  2. On the Roles page, click the name of the RAM role you created, for example, alivc-demo-role, to find its ARN. Record the RAM role name and ARN for later use.

  3. On the Roles page, click the name of the RAM role you created, for example, alivc-demo-role. Click the Trust Policy tab, then click Edit Trust Policy and modify the trust policy as follows:

    {
        "Statement": [
            {
                "Action": "sts:AssumeRole", 
                "Effect": "Allow", 
                "Principal": {
                    "Service": [
                        "ecs.aliyuncs.com"
                    ]
                }
            }
        ], 
        "Version": "1"
    }

    This policy defines the role as a service role, which allows the trusted cloud service (ECS) to assume it. If the trust policy is not modified, the RAM role cannot be attached to an ECS instance.

    The Instance ID parameter must be set to ["Instance ID"].

  4. Attach the RAM role to the ECS instance.

    Use the AttachInstanceRamRole API of ECS in the OpenAPI Explorer. For more information, see OpenAPI Explorer.

    Note
    • RegionId: The ID of the region where your ECS instance is located, for example, China (Shanghai). You can find this in the ECS console.

    • RamRoleName: The name of the RAM role. This example uses alivc-demo-role.

    • InstanceIds: The ID of the server-side ECS instance to which you want to attach the RAM role. You can find this in the ECS console. The ID must be in array format, for example: ["i-bp135jrddxxf9tgo****"].

    Click Initiate Call. A successful call returns a success message in the debugging results on the right.

  5. Run the following command in the ECS terminal to verify that the RAM role is associated with the ECS instance.

    curl http://100.100.100.200/latest/meta-data/ram/security-credentials/alivc-demo-role

    The following response indicates that the STS temporary authorization was successful, and the RAM role is associated with the ECS instance.

    {
    "AccessKeyId" : "STS.XXXXXXXXXXXX",
    "AccessKeySecret" : "XXXXXXXXXXXXXXXX",
    "Expiration" : "2020-11-20T14:33:31Z",
    "SecurityToken" : "XXXXXXXXXXXXXXXXXXXXXX",
    "LastUpdated" : "2020-11-20T08:33:31Z",
    "Code" : "Success"
    }
    Note

    Each ECS instance can be attached to only one RAM role. To change the attached RAM role, first call DetachInstanceRamRole in the OpenAPI Explorer to detach the current role from the ECS instance, and then use AttachInstanceRamRole to attach the new RAM role.

  6. Configure RAM-related information.

    1. Edit the source code configuration file.

      vim /home/user/workspace/ApsaraVideo_QuVideo_v1.4.0_Server_20191226/src/main/resources/application.properties

    2. Press I and modify the file according to the example below.

      roleArn = acs:ram::xxx:role/alivc-demo-role
      roleSessionName = vod-session
      roleName = alivc-demo-role
      # The following block contains outdated examples and should be ignored.
      Note
      • The REGION_CN_HANGZHOU parameter is deprecated. Use VOD_REGIONID instead, as specified in the ApsaraVideo VOD configuration section.

      • roleArn specifies the ARN obtained from the RAM console.

      • roleSessionName specifies the session name for the temporary token. You can customize this name.

      • roleName specifies the name of the RAM role obtained from the RAM console. In this example, the name is alivc-demo-role.

    3. Press Esc, then enter :wq! to save and exit.

  7. Configure ApsaraVideo VOD.

    1. Edit the source code configuration file.

      vim /home/user/workspace/ApsaraVideo_QuVideo_v1.4.0_Server_20191226/src/main/resources/application.properties

    2. Press I and modify the parameters as needed.

      # Transcoding template ID
      TEMPLATEGROUP_ID = xxx
      LONGVIDEO_TRANSCODE_TEMPLATEGROUP_ID = xxxxxxxx
      TAB_TEMPLATEGROUP_ID = xxxxxxxx
      # Domain name
      DOMAIN_NAME = http://xxx:8080/
      AVATAR_DOMAIN_NAME = http://xxx:8080/resource/
      AVATAR_URL = 1.png,2.png
      VOD_REGIONID = cn-hangzhou
      # Policy for ApsaraVideo VOD services
      policy = {"Version": "1", "Statement": [ {"Action": ["vod:*"], "Resource": ["*"  ],"Effect": "Allow"}]}
      # Taihe Music appkey
      OPEN_API_URL = https://xxxxxxxx.xxxxxxxx.com
      Q_SOURCE = xxxxxxxx
      CALLBACK_PRIVETEKEY = VodTest01
      CALLBACK_NAME = http://xxx:8080/vodcallback/callback
      APP_ID = app-1000000
      AUDIT_SETTINGS_FLAG = on
      auth_key = xxxxx
      live_domain = http://xxxxx.aliyuncs.com
      package_name = IOS,ANDROID,TEST,com.aliyun.apsara.svideo,com.aliyun.apsaravideo,com.aliyun.solution.longvideo

      Parameter

      Required

      Description

      TEMPLATEGROUP_ID

      Yes

      The ID of the transcoding template group. For more information, see Transcoding template groups.

      LONGVIDEO_TRANSCODE_TEMPLATEGROUP_ID

      No

      The transcoding template group used for long videos in a publish-before-review workflow.

      TAB_TEMPLATEGROUP_ID

      No

      The ID of the Narrowband HD transcoding template group. After configuration, you can recommend Narrowband HD videos in the console. If this ID is not set, attempts to recommend Narrowband HD videos will fail.

      DOMAIN_NAME

      Yes

      The address of the ECS instance. Example: http://10.10.10.101:8080/.

      AVATAR_DOMAIN_NAME

      No

      The address for avatar resources, which is the static resource address of the ECS instance. Example: http://10.10.10.101:8080/resource/.

      AVATAR_URL

      No

      A comma-separated list of avatar image filenames, such as 1.png,2.png.

      Note

      Place the corresponding avatar image files, 1.png and 2.png, in the /home/user/workspace/ApsaraVideo_QuVideo_v1.4.0_Server_20191226/src/main/webapp/resource directory. If the avatar service is not configured, mobile users will not have avatars, but other functions will not be affected.

      VOD_REGIONID

      Yes

      The region where the ApsaraVideo VOD service is located. Example: cn-shanghai.

      policy

      Yes

      A policy that further restricts permissions when the role is assumed. For more information, see Use RAM policies for custom authorization.

      CALLBACK_PRIVETEKEY

      Yes

      The private key for callback authentication. For more information, see Callback Settings.

      CALLBACK_NAME

      Yes

      The callback URL. Example: http://<Public_IP_of_ECS_instance>:8080/vodcallback/callback. This example uses http://10.10.10.101:8080/vodcallback/callback.

      AUDIT_SETTINGS_FLAG

      Yes

      Specifies the content review mode. Default value: on. Valid values:

      • on: review-before-publish.

      • off: publish-before-review.

      package_name

      Yes

      The valid package names for the interceptor. Separate multiple package names with commas. The default value is IOS,ANDROID,TEST,com.aliyun.apsara.svideo,com.aliyun.apsaravideo,com.aliyun.solution.longvideo.

      Note
      • com.aliyun.apsara.svideo is the package name for the Android client in this example.

      • If the Bundle Identifier for your iOS client is already registered, the client cannot run. You must use a custom Bundle Identifier, such as com.<Company_name>.<Project_name>, for the iOS client signature and add it to the package_name parameter to ensure valid access.

      • The interceptor allows only mobile apps with valid package names to access the server. Otherwise, requests from the mobile client will be denied with a 403 Forbidden error.

    3. Press Esc, then enter :wq! to save and exit.

  8. Run the service.

    1. Compile and package the code.

      cd /home/user/workspace/ApsaraVideo_QuVideo_v1.4.0_Server_20191226

      mvn clean package -Dmaven.test.skip=true

      Note
      • If Maven is not installed, run apt install maven to install it.

      • The packaging time depends on instance bandwidth and performance. In this example, the initial packaging takes about 30 minutes.

      After packaging is complete, the sdk-api-0.0.1-SNAPSHOT.jar file is generated in the /home/user/workspace/ApsaraVideo_QuVideo_v1.4.0_Server_20191226/target/ directory.

    2. Deploy the JAR file and start the service.

      cd /home/user/workspace/ApsaraVideo_QuVideo_v1.4.0_Server_20191226/target

      nohup java -jar sdk-api-0.0.1-SNAPSHOT.jar &

      Note
      • When the command is run, a nohup prompt appears. Press Enter to run the program in the background.

      • After the command is executed, a log file named nohup.out is generated in the current directory. Run the cat nohup.out command to view the log. If the log contains the start success message, the service has started successfully.

      • If your ECS instance has a small amount of memory and you need to repackage and deploy the server source code, you can run the jps command to view the process ID of the currently running JAR program, and then run the kill -9 <JAR_process_ID> command to terminate the process before you repackage and deploy again. Otherwise, the packaging process will fail due to insufficient memory.