文件操作

获取文件详情

接口

GET https://cloud.minapp.com/oserve/v2.2/file/:file_id/

其中 :file_id 需替换为你的文件 ID

代码示例

{% tabs getFileDetailCurl=”Curl”, getFileDetailNode=”Node”, getFileDetailPHP=”PHP” %}

{% content “getFileDetailCurl” %}

  1. curl -X GET \
  2. -H "Authorization: Bearer 58f6cd9f84b1b0c04941fbd4d87bc5f14a785107" \
  3. -H "Content-Type: application/json" \
  4. https://cloud.minapp.com/oserve/v2.2/file/5a1ba9c1fff1d651135e5ff1/

{% content “getFileDetailNode” %}

  1. var request = require('request');
  2. var opt = {
  3. uri: 'https://cloud.minapp.com/oserve/v2.2/file/5a2fe93308443e313a428cxx/', // 5a6ad3cffff1d675b9e2cexx 对应 uri :file_id
  4. method: 'GET',
  5. headers: {
  6. Authorization: `Bearer ${token}`
  7. }
  8. }
  9. request(opt, function(err, res, body) {
  10. console.log(body)
  11. })

{% content “getFileDetailPHP” %}

  1. <?php
  2. $file_id = '5a2fe93308443e313a428cxx'; // 文件 ID
  3. $url = "https://cloud.minapp.com/oserve/v2.2/file/{$file_id}/";
  4. $ch = curl_init();
  5. $header = array(
  6. "Authorization: Bearer {$token}",
  7. 'Content-Type: application/json; charset=utf-8'
  8. );
  9. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  10. curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  11. curl_setopt($ch, CURLOPT_URL, $url);
  12. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
  13. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  14. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
  15. $res = curl_exec($ch);
  16. curl_close($ch);

{% endtabs %}

返回示例

  1. {
  2. "categories": [
  3. {
  4. "id": "5a1ba7b708443e7fc5f2fb18",
  5. "name": "Category",
  6. }
  7. ],
  8. "cdn_path": "1eJCS1MFGdvaaBoV.png",
  9. "created_at": 1511762369,
  10. "id": "5a1ba9c1fff1d651135e5ff1",
  11. "media_type": "image",
  12. "mime_type": "image/png",
  13. "name": "box_close.png",
  14. "path": "https://cloud-minapp-287.cloud.ifanrusercontent.com/1eJCS1MFGdvaaBoV.png",
  15. "size": 3652,
  16. "status": "success"
  17. }

获取文件列表

接口

GET https://cloud.minapp.com/oserve/v2.2/file/

info 该接口支持通过参数 return_total_count 指定是否返回查询对象总数,以协助不关心对象总数只关心查询结果列表的开发者提升接口响应速度。 同时,从 v2.2 版本开始该接口默认不返回查询对象总数,欲获取总数的开发者需要显式指定 return_total_count 参数。

参数说明

Content-Type: application/json

参数 类型 必填 说明
order_by String Y 排序(支持 created_at 进行排序)
limit Number N 限制返回资源的个数,默认为 20 条,最大可设置为 1000
offset Number N 设置返回资源的起始偏移值,默认为 0
return_total_count Number N 返回结果 meta 中是否返回 total_count,1 为返回,0 为不返回,默认不返回

若开发者只需要获取对象总数,则可以通过设置 limit=1 以及 return_total_count=1 来达到该效果,total_count 可从返回的 meta 中获取

请求示例:

  1. https://cloud.minapp.com/oserve/v2.2/file/?limit=1&return_total_count=1

代码示例

{% tabs getFileListCurl=”Curl”, getFileListNode=”Node”, getFileListPHP=”PHP” %}

{% content “getFileListCurl” %}

  1. curl -X GET \
  2. -H "Authorization: Bearer 58f6cd9f84b1b0c04941fbd4d87bc5f14a785107" \
  3. -H "Content-Type: application/json" \
  4. -G \
  5. -d order_by=-created_at \
  6. -d category=5a1ba7b708443e7fc5f2fb18 \
  7. https://cloud.minapp.com/oserve/v2.2/file/

{% content “getFileListNode” %}

  1. var request = require('request');
  2. var opt = {
  3. uri: 'https://cloud.minapp.com/oserve/v2.2/file/',
  4. method: 'GET',
  5. headers: {
  6. Authorization: `Bearer ${token}`
  7. },
  8. qs: { // query string, 被附加到uri的参数
  9. offset: 0, // 可选
  10. limit: 20, // 可选
  11. order_by: 'created_at' // 按照创建时间来排序,可选
  12. }
  13. }
  14. request(opt, function(err, res, body) {
  15. console.log(body)
  16. })

{% content “getFileListPHP” %}

  1. <?php
  2. $url = "https://cloud.minapp.com/oserve/v2.2/file/";
  3. $ch = curl_init();
  4. $header = array(
  5. "Authorization: Bearer {$token}",
  6. 'Content-Type: application/json; charset=utf-8'
  7. );
  8. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  9. curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  10. curl_setopt($ch, CURLOPT_URL, $url);
  11. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
  12. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  13. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
  14. $res = curl_exec($ch);
  15. curl_close($ch);

{% endtabs %}

删除文件

接口

DELETE https://cloud.minapp.com/oserve/v2.2/file/:file_id/

其中 :file_id 需替换为你的文件 ID

代码示例

{% tabs deleteFileCurl=”Curl”, deleteFileNode=”Node”, deleteFilePHP=”PHP” %}

{% content “deleteFileCurl” %}

  1. curl -X DELETE \
  2. -H "Authorization: Bearer 58f6cd9f84b1b0c04941fbd4d87bc5f14a785107" \
  3. -H "Content-Type: application/json" \
  4. https://cloud.minapp.com/oserve/v2.2/file/5a1ba9c1fff1d651135e5ff1/

{% content “deleteFileNode” %}

  1. var request = require('request');
  2. var opt = {
  3. uri: 'https://cloud.minapp.com/oserve/v2.2/file/5a45f22bfff1d659681c87xx/', // 5a6ad3cffff1d675b9e2cexx 对应 uri :file_id
  4. method: 'DELETE',
  5. headers: {
  6. Authorization: `Bearer ${token}`
  7. }
  8. }
  9. request(opt, function(err, res, body) {
  10. console.log(res.statusCode)
  11. })

{% content “deleteFilePHP” %}

  1. <?php
  2. $file_id = '5a45f22bfff1d659681c87xx'; // 文件 ID
  3. $url = "https://cloud.minapp.com/oserve/v2.2/file/{$file_id}/";
  4. $ch = curl_init();
  5. $header = array(
  6. "Authorization: Bearer {$token}",
  7. 'Content-Type: application/json; charset=utf-8'
  8. );
  9. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  10. curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  11. curl_setopt($ch, CURLOPT_URL, $url);
  12. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
  13. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  14. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
  15. $res['response'] = curl_exec($ch); // 反馈结果
  16. $res['status_code'] = curl_getinfo($ch, CURLINFO_HTTP_CODE); // 请求状态码
  17. curl_close($ch);

{% endtabs %}

状态码说明

204 删除成功

批量删除文件

接口

DELETE https://cloud.minapp.com/oserve/v2.2/file/?id__in=:file1_id,:file2_id

代码示例

{% tabs patchDeleteCurl=”Curl”, patchDeleteNode=”Node”, patchDeletePHP=”PHP” %}

{% content “patchDeleteCurl” %}

  1. curl -X DELETE \
  2. -H "Authorization: Bearer 58f6cd9f84b1b0c04941fbd4d87bc5f14a785107" \
  3. -H "Content-Type: application/json" \
  4. https://cloud.minapp.com/oserve/v2.2/file/?id__in=5a1ba9c1fff1d651135e5ff1,59ca3d275f281f58523fc47a

{% content “patchDeleteNode” %}

  1. var request = require('request');
  2. var opt = {
  3. uri: 'https://cloud.minapp.com/oserve/v2.2/file/?id__in=5a3b8e8908443e06aa6f0a99,5a3b673308443e643f1b0c47',
  4. method: 'DELETE',
  5. headers: {
  6. Authorization: `Bearer ${token}`
  7. }
  8. }
  9. request(opt, function(err, res, body) {
  10. console.log(res.statusCode)
  11. })

{% content “patchDeletePHP” %}

  1. <?php
  2. $file_id[] = '5a45f22bfff1d659681cxxxx'; // 文件 ID
  3. $file_id[] = '5a3b673308443e643f1bxxxx'; // 文件 ID
  4. $url = "https://cloud.minapp.com/oserve/v2.2/file/?id__in=".implode(',',$file_id);
  5. $ch = curl_init();
  6. $header = array(
  7. "Authorization: Bearer {$token}",
  8. 'Content-Type: application/json; charset=utf-8'
  9. );
  10. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  11. curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  12. curl_setopt($ch, CURLOPT_URL, $url);
  13. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
  14. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  15. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
  16. $res['response'] = curl_exec($ch); // 反馈结果
  17. $res['status_code'] = curl_getinfo($ch, CURLINFO_HTTP_CODE); // 请求状态码
  18. curl_close($ch);

{% endtabs %}

状态码说明

204 删除成功

视频截图

接口

POST https://cloud.minapp.com/oserve/v1/media/video-snapshot/

请求参数说明

参数 类型 必填 说明
source String Y 视频文件的 id
save_as String Y 截图保存的文件名
point String Y 截图时间格式,格式:HH:MM:SS
category_id String N 文件所属类别 ID
random_file_link Boolean N 是否使用随机字符串作为文件的下载地址,不随机可能会覆盖之前的文件,默认为 true
size String N 截图尺寸,格式为 宽 x 高,默认是视频尺寸
format String N 截图格式,可选值为 jpg,png, webp, 默认根据 save_as 的后缀生成

返回参数

参数 类型 说明
created_at Integer 创建时间 (格式为 unix 时间戳)
path String 上传成功后的访问地址 URL
created_by Integer 创建者 id
mime_type String mime_type 类型
media_type String 媒体类型
size Integer 文件大小
name String 文件名
status String 文件状态
reference Object 引用
cdn_path String 文件在 CDN 中的相对路径
updated_at Integer 更新时间 (格式为 unix 时间戳)
categories String 文件所属类别
id String 本条记录 ID

代码示例

{% tabs videoSnapshotCurl=”Curl”, videoSnapshotNode=”Node”, videoSnapshotPHP=”PHP” %}

{% content “videoSnapshotCurl” %}

  1. curl --request POST \
  2. --url https://cloud.minapp.com/oserve/v1/media/video-snapshot/ \
  3. --header 'Authorization: Bearer 050c5121242eda175e8d0ee1cbe6950dadc77' \
  4. --header 'Content-Type: application/json' \
  5. --data '{\n "source": "5c4a6db320fa9c2e054c6c36",\n "save_as": "1-25-test.png",\n "point": "00:00:50",\n "category_id": "5a377bb009a8054139faafed"\n}'

{% content “videoSnapshotNode” %}

  1. var request = require("request");
  2. var options = {
  3. method: 'POST',
  4. url: 'https://cloud.minapp.com/oserve/v1/media/video-snapshot/',
  5. headers:
  6. {
  7. 'Content-Type': 'application/json',
  8. Authorization: 'Bearer 2323d124881bd3d63c9bb78458252454f80a676b'
  9. },
  10. body:
  11. {
  12. source: "5c453c7cfe10833f3178479e",
  13. save_as: "1-25-test.png",
  14. point: "00:00:50",
  15. category_id: "5a377bcb09a8054139faaff1"
  16. },
  17. json: true
  18. };
  19. request(options, function (error, response, body) {
  20. if (error) throw new Error(error);
  21. console.log(body);
  22. });

{% content “videoSnapshotPHP” %}

  1. <?php
  2. $curl = curl_init();
  3. curl_setopt_array($curl, array(
  4. CURLOPT_URL => "https://cloud.minapp.com/oserve/v1/media/video-snapshot/",
  5. CURLOPT_RETURNTRANSFER => true,
  6. CURLOPT_ENCODING => "",
  7. CURLOPT_MAXREDIRS => 10,
  8. CURLOPT_TIMEOUT => 30,
  9. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  10. CURLOPT_CUSTOMREQUEST => "POST",
  11. CURLOPT_POSTFIELDS => "{\n\t\"source\": \"5c4a6db320fa9c2e054c6c36\",\n\t\"save_as\": \"1-25-test.png\",\n\t\"point\": \"00:00:50\",\n\t\"category_id\": \"5a377bb009a8054139faafed\"\n}",
  12. CURLOPT_HTTPHEADER => array(
  13. "Authorization: Bearer 050c5121242eda175e8d0ee1cbe6950dadc777db",
  14. "Content-Type: application/json",
  15. ),
  16. ));
  17. $response = curl_exec($curl);
  18. $err = curl_error($curl);
  19. curl_close($curl);
  20. if ($err) {
  21. echo "cURL Error #:" . $err;
  22. } else {
  23. echo $response;
  24. }

{% endtabs %}

返回示例

  1. {
  2. "status": "success",
  3. "id": "5c4a6dcc20fa9c2e054c6c3b",
  4. "created_at": 1548381644,
  5. "updated_at": 1548381644,
  6. "media_type": "image",
  7. "mime_type": "image/png",
  8. "size": 1122460,
  9. "reference": {},
  10. "name": "1-25-test.png",
  11. "path": "https://cloud-minapp-7894.cloud.ifanrusercontent.com/1gmqnUzZx1gNpp78.png",
  12. "cdn_path": "1gmqnUzZx1gNpp78.png",
  13. "categories": [
  14. {
  15. "id": "5a377bb009a8054139faafed",
  16. "parent": null,
  17. "name": "图片"
  18. }
  19. ],
  20. "created_by": 2176
  21. }

状态码说明

200 截图成功

400 参数错误

404 文件不存在

M3U8 视频拼接

接口

POST https://cloud.minapp.com/oserve/v1/media/m3u8-concat/

请求参数说明

参数 类型 必填 说明
m3u8s Array Y 视频文件的 id 列表,按提交的顺序进行拼接
save_as String Y 截图保存的文件名
category_id String N 文件所属类别 ID
random_file_link Boolean N 是否使用随机字符串作为文件的下载地址,不随机可能会覆盖之前的文件,默认为 true

返回参数

参数 类型 说明
created_at Integer 创建时间 (格式为 unix 时间戳)
path String 上传成功后的访问地址 URL
created_by Integer 创建者 id
mime_type String mime_type 类型
media_type String 媒体类型
size Integer 文件大小
name String 文件名
status String 文件状态
reference Object 引用
cdn_path String 文件在 CDN 中的相对路径
updated_at Integer 更新时间 (格式为 unix 时间戳)
categories String 文件所属类别
id String 本条记录 ID

代码示例

{% tabs m3u8ConcatCurl=”Curl”, m3u8ConcatNode=”Node”, m3u8ConcatPHP=”PHP” %}

{% content “m3u8ConcatCurl” %}

  1. curl --request POST \
  2. --url https://cloud.minapp.com/oserve/v1/media/m3u8-concat/ \
  3. --header 'Authorization: Bearer 050c5121242eda175e8d0ee1cbe6950dadc777db' \
  4. --header 'Content-Type: application/json' \
  5. --data '{\n "m3u8s": ["5c453c7cfe10833f3178479e", "5c452bebfe10832bf97846c9"],\n "save_as": "1-25-test.m3u8",\n "category_id": "5a377bcb09a8054139faaff1"\n}'

{% content “m3u8ConcatNode” %}

  1. var request = require("request");
  2. var options = {
  3. method: 'POST',
  4. url: 'https://cloud.minapp.com/oserve/v1/media/m3u8-concat/',
  5. headers:
  6. {
  7. 'Content-Type': 'application/json',
  8. Authorization: 'Bearer 2323d124881bd3d63c9bb78458252454f80a676b'
  9. },
  10. body:
  11. {
  12. m3u8s: ["5c453c7cfe10833f3178479e", "5c452bebfe10832bf97846c9"],
  13. save_as: "1-25-test.m3u8",
  14. category_id: "5a377bcb09a8054139faaff1"
  15. },
  16. json: true
  17. };
  18. request(options, function (error, response, body) {
  19. if (error) throw new Error(error);
  20. console.log(body);
  21. });

{% content “m3u8ConcatPHP” %}

  1. <?php
  2. $curl = curl_init();
  3. curl_setopt_array($curl, array(
  4. CURLOPT_URL => "https://cloud.minapp.com/oserve/v1/media/m3u8-concat/",
  5. CURLOPT_RETURNTRANSFER => true,
  6. CURLOPT_ENCODING => "",
  7. CURLOPT_MAXREDIRS => 10,
  8. CURLOPT_TIMEOUT => 30,
  9. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  10. CURLOPT_CUSTOMREQUEST => "POST",
  11. CURLOPT_POSTFIELDS => "{\n\t\"m3u8s\": [\"5c453c7cfe10833f3178479e\", \"5c452bebfe10832bf97846c9\"],\n\t\"save_as\": \"1-25-test.m3u8\",\n\t\"category_id\": \"5a377bcb09a8054139faaff1\"\n}",
  12. CURLOPT_HTTPHEADER => array(
  13. "Authorization: Bearer 050c5121242eda175e8d0ee1cbe6950dadc777db",
  14. "Content-Type: application/json",
  15. ),
  16. ));
  17. $response = curl_exec($curl);
  18. $err = curl_error($curl);
  19. curl_close($curl);
  20. if ($err) {
  21. echo "cURL Error #:" . $err;
  22. } else {
  23. echo $response;
  24. }

{% endtabs %}

返回示例

  1. {
  2. "status": "pending",
  3. "id": "5c4a699820fa9c27f14c6ddd",
  4. "created_at": 1548380568,
  5. "updated_at": 1548380568,
  6. "media_type": "other",
  7. "mime_type": null,
  8. "size": 0,
  9. "reference": {},
  10. "name": "1-25-test.m3u8",
  11. "path": "https://cloud-minapp-7894.cloud.ifanrusercontent.com/1gmqW8egmWLqY4Q1.m3u8",
  12. "cdn_path": "1gmqW8egmWLqY4Q1.m3u8",
  13. "categories": [
  14. {
  15. "id": "5a377bcb09a8054139faaff1",
  16. "parent": null,
  17. "name": "视频"
  18. }
  19. ],
  20. "created_by": 2176
  21. }

状态码说明

200 成功

400 参数错误

404 文件不存在

M3U8 视频剪辑

接口

POST https://cloud.minapp.com/oserve/v1/media/video-clip/

请求参数说明

参数 类型 必填 说明
m3u8 String Y 视频文件的 id
save_as String Y 截图保存的文件名
category_id String N 文件所属类别 ID
random_file_link Boolean N 是否使用随机字符串作为文件的下载地址,不随机可能会覆盖之前的文件,默认为 true
include Array N 包含某段内容的开始结束时间,单位是秒。当 index 为 false 时,为开始结束分片序号
exclude Array N 不包含某段内容的开始结束时间,单位是秒。当 index 为 false 时,为开始结束分片序号
index Boolean N include 或者 exclude 中的值是否为 ts 分片序号,默认为 false

返回参数

参数 类型 说明
created_at Integer 创建时间 (格式为 unix 时间戳)
path String 上传成功后的访问地址 URL
created_by Integer 创建者 id
mime_type String mime_type 类型
media_type String 媒体类型
size Integer 文件大小
name String 文件名
status String 文件状态
reference Object 引用
cdn_path String 文件在 CDN 中的相对路径
updated_at Integer 更新时间 (格式为 unix 时间戳)
categories String 文件所属类别
id String 本条记录 ID

代码示例

{% tabs m3u8ClipCurl=”Curl”, m3u8ClipNode=”Node”, m3u8ClipPHP=”PHP” %}

{% content “m3u8ClipCurl” %}

  1. curl --request POST \
  2. --url https://cloud.minapp.com/oserve/v1/media/m3u8-clip/ \
  3. --header 'Authorization: Bearer 050c5121242eda175e8d0ee1cbe6950dadc777db' \
  4. --header 'Content-Type: application/json' \
  5. --data '{\n "m3u8": "5c452bebfe10832bf97846c9",\n "save_as": "1-25-test.m3u8",\n "include": [0, 5],\n "category_id": "5a377bcb09a8054139faaff1"\n}'

{% content “m3u8ClipNode” %}

  1. var request = require("request");
  2. var options = {
  3. method: 'POST',
  4. url: 'https://cloud.minapp.com/oserve/v1/media/m3u8-clip/',
  5. headers:
  6. {
  7. 'Content-Type': 'application/json',
  8. Authorization: 'Bearer 2323d124881bd3d63c9bb78458252454f80a676b'
  9. },
  10. body:
  11. {
  12. m3u8: "5c3421788318ed7f50e5ea8b",
  13. save_as: "1-25-test.m3u8",
  14. include: [0, 5],
  15. category_id: "5a377bcb09a8054139faaff1"
  16. },
  17. json: true
  18. };
  19. request(options, function (error, response, body) {
  20. if (error) throw new Error(error);
  21. console.log(body);
  22. });

{% content “m3u8ClipPHP” %}

  1. <?php
  2. $curl = curl_init();
  3. curl_setopt_array($curl, array(
  4. CURLOPT_URL => "https://cloud.minapp.com/oserve/v1/media/m3u8-clip/",
  5. CURLOPT_RETURNTRANSFER => true,
  6. CURLOPT_ENCODING => "",
  7. CURLOPT_MAXREDIRS => 10,
  8. CURLOPT_TIMEOUT => 30,
  9. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  10. CURLOPT_CUSTOMREQUEST => "POST",
  11. CURLOPT_POSTFIELDS => "{\n\t\"m3u8\": \"5c452bebfe10832bf97846c9\",\n\t\"save_as\": \"1-25-test.m3u8\",\n\t\"include\": [0, 5],\n\t\"category_id\": \"5a377bcb09a8054139faaff1\"\n}",
  12. CURLOPT_HTTPHEADER => array(
  13. "Authorization: Bearer 050c5121242eda175e8d0ee1cbe6950dadc777db",
  14. "Content-Type: application/json",
  15. ),
  16. ));
  17. $response = curl_exec($curl);
  18. $err = curl_error($curl);
  19. curl_close($curl);
  20. if ($err) {
  21. echo "cURL Error #:" . $err;
  22. } else {
  23. echo $response;
  24. }

{% endtabs %}

返回示例

  1. {
  2. "status": "pending",
  3. "id": "5c4a685520fa9c27f14c6d48",
  4. "created_at": 1548380245,
  5. "updated_at": 1548380245,
  6. "media_type": "other",
  7. "mime_type": null,
  8. "size": 0,
  9. "reference": {},
  10. "name": "1-25-test.m3u8",
  11. "path": "https://cloud-minapp-7894.cloud.ifanrusercontent.com/1gmqQuVchCjctKhe.m3u8",
  12. "cdn_path": "1gmqQuVchCjctKhe.m3u8",
  13. "categories": [
  14. {
  15. "id": "5a377bcb09a8054139faaff1",
  16. "parent": null,
  17. "name": "视频"
  18. }
  19. ],
  20. "created_by": 2176
  21. }

状态码说明

200 成功

400 参数错误

404 文件不存在

M3U8 时长和分片信息

接口

POST https://cloud.minapp.com/oserve/v1/media/m3u8-meta/

请求参数说明

参数 类型 必填 说明
m3u8 String Y 视频文件的 id

返回参数

res:

参数 类型 说明
status_code Integer 状态码
message String 返回信息
meta Object 详见以下

meta 参数说明:

参数 类型 说明
duartion Number m3u8 时长
points Array 时间点

代码示例

{% tabs m3u8MetaCurl=”Curl”, m3u8MetaNode=”Node”, m3u8MetaPHP=”PHP” %}

{% content “m3u8MetaCurl” %}

  1. curl --request POST \
  2. --url https://cloud.minapp.com/oserve/v1/media/m3u8-meta/ \
  3. --header 'Authorization: Bearer 050c5121242eda175e8d0ee1cbe6950dadc777db' \
  4. --header 'Content-Type: application/json' \
  5. --data '{\n "m3u8": "5c452bebfe10832bf97846c9"\n}'

{% content “m3u8MetaNode” %}

  1. var request = require("request");
  2. var options = {
  3. method: 'POST',
  4. url: 'https://cloud.minapp.com/oserve/v1/media/m3u8-meta/',
  5. headers:
  6. {
  7. 'Content-Type': 'application/json',
  8. Authorization: 'Bearer 2323d124881bd3d63c9bb78458252454f80a676b'
  9. },
  10. body:
  11. {
  12. m3u8: "5c3421788318ed7f50e5ea8b"
  13. },
  14. json: true
  15. };
  16. request(options, function (error, response, body) {
  17. if (error) throw new Error(error);
  18. console.log(body);
  19. });

{% content “m3u8MetaPHP” %}

  1. <?php
  2. $curl = curl_init();
  3. curl_setopt_array($curl, array(
  4. CURLOPT_URL => "https://cloud.minapp.com/oserve/v1/media/m3u8-meta/",
  5. CURLOPT_RETURNTRANSFER => true,
  6. CURLOPT_ENCODING => "",
  7. CURLOPT_MAXREDIRS => 10,
  8. CURLOPT_TIMEOUT => 30,
  9. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  10. CURLOPT_CUSTOMREQUEST => "POST",
  11. CURLOPT_POSTFIELDS => "{\n\t\"m3u8\": \"5c452bebfe10832bf97846c9\"\n}",
  12. CURLOPT_HTTPHEADER => array(
  13. "Authorization: Bearer 050c5121242eda175e8d0ee1cbe6950dadc777db",
  14. "Content-Type: application/json",
  15. ),
  16. ));
  17. $response = curl_exec($curl);
  18. $err = curl_error($curl);
  19. curl_close($curl);
  20. if ($err) {
  21. echo "cURL Error #:" . $err;
  22. } else {
  23. echo $response;
  24. }

{% endtabs %}

返回示例

  1. {
  2. "message": "ok",
  3. "status_code": 200,
  4. "meta": {
  5. "duration": 1769.2619999999997,
  6. "points": [
  7. 20.44,
  8. 40,
  9. 60.92,
  10. 80.68,
  11. 100.16000000000001,
  12. 120.08000000000001,
  13. 1581.5839999999998,
  14. 1600.9429999999998,
  15. 1620.9429999999998,
  16. 1640.9429999999998,
  17. 1660.6629999999998,
  18. 1680.6629999999998,
  19. 1700.6629999999998,
  20. 1720.6629999999998,
  21. 1740.6629999999998,
  22. 1760.6629999999998,
  23. 1769.2619999999997
  24. ]
  25. }
  26. }

状态码说明

200 成功

400 参数错误

404 文件不存在

音视频原信息

接口

POST https://cloud.minapp.com/oserve/v1/media/audio-video-meta/

请求参数说明

参数 类型 必填 说明
source String Y 文件的 id

返回参数

res:

参数 类型 说明
format Object 音视频格式信息,详见以下
streams Array stream 列表,详见以下

format 参数说明:

参数 类型 说明
bitrate Integer 比特率
duration Number 时长
format String 容器格式
fullname String 容器格式全称

streams 参数说明:

参数 类型 说明
index Integer 表示第几路流
type String 一般情况下, video 或 audio
bitrate Integer 流码率
codec String 流编码
codec_desc String 流编码说明
duration Number 流时长
video_fps Number (视频流)视频帧数
video_height Integer (视频流)视频高度
video_width Integer (视频流)视频宽度
audio_channels Integer (音频流)音频通道数
audio_samplerate Integer (音频流)音频采样率

代码示例

{% tabs audioVideoMetaCurl=”Curl”, audioVideoMetaNode=”Node”, audioVideoMetaPHP=”PHP” %}

{% content “audioVideoMetaCurl” %}

  1. curl --request POST \
  2. --url https://cloud.minapp.com/oserve/v1/media/audio-video-meta/ \
  3. --header 'Authorization: Bearer 050c5121242eda175e8d0ee1cbe6950dadc777db' \
  4. --header 'Content-Type: application/json' \
  5. --data '{\n "source": "5c3421788318ed7f50e5ea8b"\n}'

{% content “audioVideoMetaNode” %}

  1. var request = require("request");
  2. var options = {
  3. method: 'POST',
  4. url: 'https://cloud.minapp.com/oserve/v1/media/audio-video-meta/',
  5. headers:
  6. {
  7. 'Content-Type': 'application/json',
  8. Authorization: 'Bearer 2323d124881bd3d63c9bb78458252454f80a676b'
  9. },
  10. body:
  11. {
  12. source: "5c3421788318ed7f50e5ea8b"
  13. },
  14. json: true
  15. };
  16. request(options, function (error, response, body) {
  17. if (error) throw new Error(error);
  18. console.log(body);
  19. });

{% content “audioVideoMetaPHP” %}

  1. <?php
  2. $curl = curl_init();
  3. curl_setopt_array($curl, array(
  4. CURLOPT_URL => "https://cloud.minapp.com/oserve/v1/media/audio-video-meta/",
  5. CURLOPT_RETURNTRANSFER => true,
  6. CURLOPT_ENCODING => "",
  7. CURLOPT_MAXREDIRS => 10,
  8. CURLOPT_TIMEOUT => 30,
  9. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  10. CURLOPT_CUSTOMREQUEST => "POST",
  11. CURLOPT_POSTFIELDS => "{\n\t\"source\": \"5c3421788318ed7f50e5ea8b\"\n}",
  12. CURLOPT_HTTPHEADER => array(
  13. "Authorization: Bearer 050c5121242eda175e8d0ee1cbe6950dadc777db",
  14. "Content-Type: application/json",
  15. ),
  16. ));
  17. $response = curl_exec($curl);
  18. $err = curl_error($curl);
  19. curl_close($curl);
  20. if ($err) {
  21. echo "cURL Error #:" . $err;
  22. } else {
  23. echo $response;
  24. }

{% endtabs %}

返回示例

  1. {
  2. "format": {
  3. "format": "mov,mp4,m4a,3gp,3g2,mj2",
  4. "filesize": 91427419,
  5. "duration": 43.451667,
  6. "fullname": "QuickTime / MOV",
  7. "bitrate": 16832941
  8. },
  9. "streams": [
  10. {
  11. "index": 0,
  12. "duration": 43.451667,
  13. "bitrate": 16762715,
  14. "video_fps": 24,
  15. "codec_desc": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
  16. "metadata": {
  17. "creation_time": "2016-01-17T02:58:26.000000Z",
  18. "encoder": "H.264",
  19. "language": "und",
  20. "rotate": "90",
  21. "handler_name": "Core Media Data Handler"
  22. },
  23. "video_height": 1080,
  24. "video_width": 1920,
  25. "type": "video",
  26. "codec": "h264"
  27. },
  28. {
  29. "index": 1,
  30. "duration": 43.451678,
  31. "bitrate": 62934,
  32. "codec_desc": "AAC (Advanced Audio Coding)",
  33. "metadata": {
  34. "creation_time": "2016-01-17T02:58:26.000000Z",
  35. "language": "und",
  36. "handler_name": "Core Media Data Handler"
  37. },
  38. "audio_samplerate": 44100,
  39. "audio_channels": 1,
  40. "type": "audio",
  41. "codec": "aac"
  42. }
  43. ]
  44. }

状态码说明

200 成功

400 参数错误

404 文件不存在