点播服务接口

接口目录

创建视频

POST /video/api/create

需要先调用存储微服务的接口,如 /storage/api/upload 等,上传视频,获取到 storage_id

JSON 参数

参数 描述 取值
storage_id 文件 ID string
source_type 来源类型(调用方自己定义,如 streaming, upload, etc.) string
source_id 来源 ID(不知道该值可不填) string
video_name (可选)视频文件名(默认为存储服务上的文件名) string
skip_auto_trans (可选)创建的视频无视该用户配置的自动转码规则,不进行自动转码(为 true 时生效) bool

返回字段

参数 描述 取值
errcode 错误码,1000 为正常 int
msg "OK" 或错误信息 string
id 视频 ID string

返回示例:

{
    "errcode": 1000,
    "id": "17lok52y",
    "msg": "OK"
}

获取视频列表

GET /video/api/list

视频状态表:

意义
0 初始状态
1 上传成功(这是最终状态)
2 上传中
3 上传失败
4 已删除

转码视频状态表:

意义
0 初始状态(过程状态)
1 上传成功(这是最终状态)
2 转码中(过程状态)
3 转码成功(过程状态)
4 转码失败
5 上传中(过程状态)
6 上传失败
7 已删除

URL 参数

参数 描述 取值
page 页数,默认 1 int
page_size 每页个数,默认 15 int

返回字段

参数 描述 取值
errcode 错误码,1000 为正常 int
msg "OK" 或错误信息 string
videos 视频列表 object array
videos.id 视频 ID string
videos.created_at 创建时间 string
videos.updated_at 更新时间 string
videos.source_type 上传来源类型 string
videos.source_id 来源 ID string
videos.status 视频状态(见视频状态表) int
videos.storage_id 文件 ID string
videos.origin_url 原片 URL(初始为空) string
videos.thumb_url 视频封面 URL(初始为空) string
videos.file_size 视频文件大小 int
videos.video_name 视频名称 string
videos.video_width 视频宽 int
videos.video_height 视频高 int
videos.video_duration 视频时长(毫秒) int
videos.shared_state 分享状态(0-私有,1-需要密码,2-不需要密码) int
videos.share_password 分享密码 string
videos.play_set 视频转码数据 object array
videos.play_set.created_at 创建时间 string
videos.play_set.updated_at 更新时间 string
videos.play_set.storage_id 文件 ID string
videos.play_set.status 转码视频状态(定义见转码视频状态表) int
videos.play_set.trans_progress 转码进度(0.0~1.0) float
videos.play_set.trans_task_config_temp_id 转码模板 ID int
videos.play_set.url 文件 URL string
videos.play_set.file_size 视频文件大小 int
videos.play_set.video_width 视频宽 int
videos.play_set.video_height 视频高 int
videos.play_set.video_duration 视频时长(毫秒) int
videos.play_set.resolution 清晰度(360P, 480P, 720P, 1080P, Origin) string
count 视频总个数 int

返回示例:

{
    "count": 33,
    "errcode": 1000,
    "msg": "OK",
    "videos": [
        {
            "id": "17lok52y",
            "created_at": "2010-11-22T15:16:17+08:00",
            "updated_at": "2010-11-22T15:16:17+08:00",
            "source_type": "1",
            "source_id": "1",
            "status": 1,
            "storage_id": "1",
            "origin_url": "1",
            "thumb_url": "1",
            "file_size": 1,
            "video_name": "1",
            "video_width": 1,
            "video_height": 1,
            "video_duration": 1,
            "shared_state": 1,
            "share_password": "5zpr0kpzo",
            "play_set": [
                {
                    "created_at": "2010-11-22T15:16:17+08:00",
                    "updated_at": "2010-11-22T15:16:17+08:00",
                    "storage_id": "1",
                    "status": 1,
                    "trans_progress": 1,
                    "trans_task_config_temp_id": 1,
                    "url": "1",
                    "file_size": 1,
                    "video_width": 1,
                    "video_height": 1,
                    "video_duration": 1,
                    "resolution": "360P"
                }
            ]
        }
    ]
}

获取单个视频

GET /video/api/get

URL 参数

参数 描述 取值
id 视频 ID string

返回字段

参数 描述 取值
errcode 错误码,1000 为正常 int
msg "OK" 或错误信息 string
video 视频信息 object
video.id 视频 ID string
video.created_at 创建时间 string
video.updated_at 更新时间 string
video.source_type 上传来源类型 string
video.source_id 来源 ID string
video.status 视频状态(见视频状态表) int
video.storage_id 文件 ID string
video.origin_url 原片 URL(初始为空) string
video.thumb_url 视频封面 URL(初始为空) string
video.file_size 视频文件大小 int
video.video_name 视频名称 string
video.video_width 视频宽 int
video.video_height 视频高 int
video.video_duration 视频时长(毫秒) int
video.shared_state 分享状态(0-私有,1-需要密码,2-不需要密码) int
video.share_password 分享密码 string
video.play_set 视频转码数据 object array
video.play_set.created_at 创建时间 string
video.play_set.updated_at 更新时间 string
video.play_set.storage_id 文件 ID string
video.play_set.status 转码视频状态(定义见转码视频状态表) int
video.play_set.trans_progress 转码进度(0.0~1.0) float
video.play_set.trans_task_config_temp_id 转码模板 ID int
video.play_set.url 文件 URL string
video.play_set.file_size 视频文件大小 int
video.play_set.video_width 视频宽 int
video.play_set.video_height 视频高 int
video.play_set.video_duration 视频时长(毫秒) int
video.play_set.resolution 清晰度(360P, 480P, 720P, 1080P, Origin) string

返回示例:

{
    "errcode": 1000,
    "msg": "OK",
    "video": {
        "id": "17lok52y",
        "created_at": "2010-11-22T15:16:17+08:00",
        "updated_at": "2010-11-22T15:16:17+08:00",
        "source_type": "1",
        "source_id": "1",
        "status": 1,
        "storage_id": "1",
        "origin_url": "1",
        "thumb_url": "1",
        "file_size": 1,
        "video_name": "1",
        "video_width": 1,
        "video_height": 1,
        "video_duration": 1,
        "shared_state": 1,
        "share_password": "5zpr0kpzo",
        "play_set": [
            {
                "created_at": "2010-11-22T15:16:17+08:00",
                "updated_at": "2010-11-22T15:16:17+08:00",
                "storage_id": "1",
                "status": 1,
                "trans_progress": 1,
                "trans_task_config_temp_id": 1,
                "url": "1",
                "file_size": 1,
                "video_width": 1,
                "video_height": 1,
                "video_duration": 1,
                "resolution": "360P"
            }
        ]
    }
}

获取分享视频

GET /video/api/get_shared_video

若访问该视频需要密码,当密码一致时才能获取该视频

URL 参数

参数 描述 取值
id 视频 ID string
password 视频密码 string

返回内容同获取单个视频

搜索视频

GET /video/api/search

  • 根据视频 ID 搜索
  • 根据视频名称模糊搜索
  • 根据视频来源搜索

URL 参数

参数 描述 取值
search 搜索内容(ID 或视频名称) string
source_type 视频来源 int
page 页数,默认 1 int
page_size 每页个数,默认 15 int

返回字段和示例同获取视频列表

更新视频名称、视频封面等视频信息

POST /video/api/update

(更新封面时,原封面会被删除)

URL 参数

参数 描述 取值
id 视频 ID string

JSON 参数

参数 描述 取值
video_name (可选)视频名称 string
thumb_storage_id (可选)要替换的封面的文件 ID string

返回字段

参数 描述 取值
errcode 错误码,1000 为正常 int
msg "OK" 或错误信息 string

返回示例:

{
    "errcode": 1000,
    "msg": "OK"
}

设置视频分享密码

POST /video/api/set_video_password

URL 参数

参数 描述 取值
id 视频 ID string

JSON 参数

参数 描述 取值
shared_state 分享状态(0-私有,1-需要密码,2-不需要密码) int
password 视频分享密码(0-16位字符) string

返回字段

参数 描述 取值
errcode 错误码,1000 为正常 int
msg "OK" 或错误信息 string

返回示例:

{
    "errcode": 1000,
    "msg": "OK"
}

查询该用户所有视频的已用空间

GET /video/api/get_video_size_sum

返回字段

参数 描述 取值
errcode 错误码,1000 为正常 int
msg "OK" 或错误信息 string
size_sum 该用户所有视频的已用空间(字节) int

返回示例:

{
    "errcode": 1000,
    "msg": "OK",
    "size_sum": 4813741023
}

转码视频

POST /video/api/trans

说明:若调用转码时存储的原始文件还没准备好,是无法转码的,可以在创建点播并成功收到 video_ready 回调之后,再去调用转码

URL 参数

参数 描述 取值
id 视频 ID string

JSON 参数

参数 描述 取值
task_config_temp_id 转码模板 ID(参见转码微服务) int
redo 重新转码,该操作会删除原有的转码任务 bool

返回字段

参数 描述 取值
errcode 错误码,1000 为正常 int
msg "OK" 或错误信息 string

返回示例:

{
    "errcode": 1000,
    "msg": "OK"
}

删除视频

POST /video/api/delete

视频、视频的转码、视频封面也会被删除

URL 参数

参数 描述 取值
id 视频 ID string

返回字段

参数 描述 取值
errcode 错误码,1000 为正常 int
msg "OK" 或错误信息 string

返回示例:

{
    "errcode": 1000,
    "msg": "OK"
}

批量删除视频

POST /video/api/delete_videos

视频、视频的转码、视频封面也会被删除

URL 参数

参数 描述 取值
ids 一组视频 ID,用逗号隔开 string

返回字段

参数 描述 取值
errcode 错误码,1000 为正常 int
msg "OK" 或错误信息 string

返回示例:

{
    "errcode": 1000,
    "msg": "OK"
}

查询单个视频的每分钟流量

GET /video/api/list_video_statistic

可以查询跨度在90天内的该视频的流量数据,即查询该视频的 [start, end] 时间范围内的每分钟流量,且 end-start<=90天

URL 参数

参数 描述 取值
id 视频 ID string
start 时间戳 int
end 时间戳 int

返回字段

参数 描述 取值
errcode 错误码,1000 为正常 int
msg "OK" 或错误信息 string
video_statistic 结果列表 object array
video_statistic.time 时间 string
video_statistic.bytes 该分钟的流量(字节数) int

查询视频总流量,分页

GET /video/api/list_video_total_summary

可以选择如下查询方式:

  • 按视频 ID 查询
  • 按视频名称查询
  • 按视频创建时间查询,即 start<=视频创建时间<=end,且 end-start<=90天

URL 参数

参数 描述 取值
search 视频 ID 或 视频名称 string
start 时间戳 int
end 时间戳 int
page 页数,默认 1 int
page_size 每页个数,默认 20 int

返回字段

参数 描述 取值
errcode 错误码,1000 为正常 int
msg "OK" 或错误信息 string
count 满足查询条件的视频总数 int
video_total_summary_list 结果列表 object array
video_total_summary_list.video_id 视频 ID string
video_total_summary_list.video_name 视频名称 string
video_total_summary_list.video_created_at 上传时间 string
video_total_summary_list.total_bytes 使用流量(字节) int

导出视频总流量,分页

GET /video/api/export_video_total_summary

可以选择如下查询方式:

  • 按视频 ID 查询
  • 按视频名称查询
  • 按视频创建时间查询,即 start<=视频创建时间<=end,且 end-start<=90天

URL 参数

参数 描述 取值
search 视频 ID 或 视频名称 string
start 时间戳 int
end 时间戳 int

返回一个 CSV 文件

查询该用户上传的所有视频的每日流量之和

GET /video/api/list_user_video_day_summary

可以查询跨度在90天内的每日流量之和,即 [start, end] 时间范围内的每日流量之和,且 end-start<=90天

URL 参数

参数 描述 取值
start 北京时区的零点时间戳,如 1471881600(2016-08-23 00:00:00) int
end 北京时区的零点时间戳 int

返回字段

参数 描述 取值
errcode 错误码,1000 为正常 int
msg "OK" 或错误信息 string
user_video_day_summary_list 结果列表 object array
user_video_day_summary_list.date 日期 string
user_video_day_summary_list.total_bytes 使用流量(字节) int

导出该用户上传的所有视频的每日流量之和,一天一条数据

GET /video/api/export_user_video_day_summary

可以查询跨度在90天内的每日流量之和,即 [start, end] 时间范围内的每日流量之和,且 end-start<=90天

URL 参数

参数 描述 取值
start 北京时区的零点时间戳,如 1471881600(2016-08-23 00:00:00) int
end 北京时区的零点时间戳 int

返回一个 CSV 文件

获取该用户上传的所有视频的总流量之和

GET /video/api/get_user_video_total_summary

返回字段

参数 描述 取值
errcode 错误码,1000 为正常 int
msg "OK" 或错误信息 string
user_video_total_summary 结果对象 object
user_video_total_summary.total_bytes 使用流量(字节) int

错误码

错误代码 使用模块 错误描述
3101 点播 参数不合法
3102 点播 找不到该文件
3103 点播 视频正在上传
3104 点播 视频上传失败
3105 点播 视频已有正在进行的或已完成的转码
3106 点播 媒体库已存在该视频,请勿重复上传
3107 点播 该文件上传失败,请重新上传
3108 点播 访问拒绝
3111 点播 内部错误:无法创建转码任务
3112 点播 内部错误:无法删除转码任务
3113 点播 内部错误:从 URL 上传文件失败
3114 点播 内部错误:创建临时文件失败
3121 点播 插入视频失败
3122 点播 查询单个视频失败
3123 点播 修改视频失败
3124 点播 删除视频失败
3125 点播 查询视频列表失败
3126 点播 检查 storage ID 是否存在失败
3127 点播 获取视频大小之和失败
3131 点播 插入视频具体数据失败
3132 点播 查询单个视频具体数据失败
3133 点播 修改视频具体数据失败
3134 点播 删除视频具体数据失败
3135 点播 查询视频具体数据列表失败
3141 点播 add video key description failed
3142 点播 modify video key description failed
3143 点播 get video key description failed
3144 点播 delete video key description failed
3151 点播 保存转码配置失败
3152 点播 删除转码配置失败
3153 点播 获取转码配置列表失败
3161 点播 数据库错误:获取点播总流量失败
3162 点播 数据库错误:列出点播总流量失败
3163 点播 数据库错误:列出用户每日流量失败
3164 点播 数据库错误:获取用户点播总流量失败

消息通知

0.在 svc_notify.user_event_config 中配置要回调的用户和回调地址,例如

36 video http://bugu.198dev.myun.tv:10080/videos/api/video_callback http 36 transcoding http://bugu.198dev.myun.tv:10080/videos/api/transcode_callback http

1.视频和转码的视频准备好(即其 Status 为 1)后,会调用消息通知微服务,发送视频数据

2.视频准备好后发送:

参数|描述|类型| |-------|--------|--------| |event_type|事件类型,值为 "video_ready" |string| |video_id|视频 ID|string| |storage_id|存储 ID|string| |source_type|上传来源类型|string| |source_id|来源 hash ID|string| |url_origin|原片 URL|string| |thumb_url|视频封面 URL|string| |file_size|视频文件大小|int| |video_name|视频名称|string| |video_width|视频宽|int| |video_height|视频高|int| |video_duration|视频时长|int| |play_set|视频转码的数据(定义见下表)|object array|

其中 play_set 是一个对象数组,对象描述:

参数 描述 类型
play_set_id PlaySet ID string
trans_task_config_temp_id 转码模板 ID int
resolution 清晰度("360P", "480P", "720P", "1080P", "Origin") string
url 文件 URL string
file_size 视频文件大小 int
video_width 视频宽 int
video_height 视频高 int
video_duration 视频时长 int

若用户有转码配置,play_set 会包含一个转码数据;否则 play_set 为空

3.转码视频准备好后发送:

参数 描述 类型
event_type 事件类型,值为 "video_play_set_ready" string
play_set_id PlaySet ID string
video_id 视频 ID string
status 转码视频状态(定义见"获取视频列表") int
trans_task_config_temp_id 转码模板 ID int
resolution 清晰度("360P", "480P", "720P", "1080P", "Origin") string
url 文件 URL string
file_size 视频文件大小 int
video_width 视频宽 int
video_height 视频高 int
video_duration 视频时长 int

判断视频能否合并

POST /video/api/can_videos_be_merged

仅限 M3U8 链接

JSON 参数

参数 描述 取值
video_urls M3U8 链接数组 string array

返回字段

参数 描述 取值
errcode 错误码,1000 为正常 int
msg "OK" 或错误信息 string
can_be_merged 能否合并 bool

返回示例:

{
    "errcode": 1000,
    "msg": "OK",
    "can_be_merged": true
}

results matching ""

    No results matching ""