腾讯云接口获取视频基本信息

本文介绍如何使用腾讯云SDK来获取指定视频文件的时长信息。通过Java代码示例展示了配置参数、调用API的方法及依赖项。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

 项目中获取视频时长,需要调用腾讯云SDK

import com.qcloud.Module.Vod;
import com.qcloud.QcloudApiModuleCenter;   

 private String getVideoTime(Integer fileId){
        TreeMap<String, Object> config = new TreeMap<>();
        // 点播服务id
        config.put("SecretId", secretId);
        // 点播服务key
        config.put("SecretKey", secretKey);
        config.put("RequestMethod", "GET");
        config.put("DefaultRegion", "bj");
        QcloudApiModuleCenter module = new QcloudApiModuleCenter(new Vod(), config);
        TreeMap<String, Object> params = new TreeMap<>();
        params.put("fileId",fileId);
        // 只请求基础信息
        params.put("infoFilter.0","basicInfo");
        String result = null;
      //  Integer duration = 0;
        try {
            result = module.call("GetVideoInfo",params);
            //获取视频时长 
           // Map<String,Object> map = JSON.parseObject(result, Map.class);
          //  duration = (Integer) map.get("duration");
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

腾讯云SDK依赖

        <!-- qcloud-java-sdk-->
        <dependency>
            <groupId>com.qcloud</groupId>
            <artifactId>qcloud-java-sdk</artifactId>
            <version>2.0.1</version>
        </dependency>

官方文档地址:https://cloud.tencent.com/document/product/266/8586

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值