创建任务

一个任务由一个JSON对象表示,包含输入文件路径或URL、输出文件路径,可选项包含MediaCoder XML配置文件路径(preset)以及要修改的设置(prefs)。当state设为"encoding"时,任务在创建后立即开始处理。

请求 (POST)

URL: http://server/mc/transcoder/[worker ID]

请求内容

{
        "worker": 0,
        "preset": "settings.xml",
        "input": "input.avi",
        "output": "output.mp4",
        "begin": 0,
        "end": 0,
        "state": "encoding",
        "prefs": {
            "overall": {
                "video": {
                    "enabled": true,
                    "bitrate": 500,
                },
                "audio": {
                    "enabled": true,
                }
            }
}

回复(成功)

{"result":"done","worker":0}

回复(失败)

{"result":"failed","worker":0,"error":"..."}
 

修改配置

配置可以键/值的形式进行微调。键/值以JSON格式表示。

请求格式 (PUT)

URL: http://server/<SERVER KEY>/prefs

请求内容

{
"overall":{
    "video":{
        "format":"H.265",
        "bitrate":1000,
        "mode":"Average Bitrate",
        "autoEncoder":true,
         ...
    },
    "audio":{
        "format":"LC-AAC",
        "bitrate":128,
        "mode":"ABR",
        ...
    },
    ...
},
"videoenc":{
    "x264":{
        "profile":"Main",
        "bframes":2,
    },
    ...
},
...
}

回复

{"success":<成功应用的选项>,"failure":<错误的选项>}

任务控制

请求(POST)

URL: http://server/mc/transcoder/[worker ID]

请求内容(开始/恢复任务)

{"worker":0,"state":"encoding"}

请求内容(停止任务)

{"worker":0,"state":"stopping"}

请求内容(暂停任务)

{"worker":0,"state":"paused"}

回复 (成功)

{"result":"done","worker":0}

回复 (错误)

{"result":"failed","error":"Invalid state","worker":0}

获取转码状态

请求 (GET)

URL: http://server/mc/stats/[worker ID]

Response

{
"worker":0,
"state":"encoding",
"percent":38,
"remainTime":21,
"elapsedTime":21,
"throughput":47,
"speed":"5.26",
"audioBitrate":66,
"audioData":19,
"duration":282148,
"estimatedSize":19820,
"fps":"193.59",
"frames":2867,
"pos":114,
"videoBitrate":496,
"videoData":346
}
state表示任务状态,可以是以下几个:
  • ready - 就绪
  • encoding - 正在转码
  • paused - 暂停
  • stopping - 停止
  • done - 完成
 

获取文件信息

请求 (GET)

URL: http://server/mc/job

Response

{[
{
  "worker":0,
  "input":{
    "path","D:\\Video\\Test\\Universal.vob",
    "size":66156544,
    "duration":66033,
    "bitrate":8015000,
    "video":{
      "codec":"MPEG Video",
      "bitrate":7407000,
      "width":720,
      "height":480,
      "fps":"2997/100"
    },
    "audio":{
      "codec":"AC-3",
      "bitrate":448000,
      "rateMode":1,"channels":6
    }
  },
 "output":{
    "path","m:\\out.mp4",
    "size":9033326",
    "duration":65898,
    "bitrate":1097000,
    "video":{
      "codec":"AVC",
      "bitrate":1000000,
      "width":720,
      "height":480,
      "fps":"2997/100"
    },
    "audio":{
      "codec":"AAC",
      "bitrate":132000,
      "rateMode":2,
      "channels":2}
    }
},
{
  "worker":1,
  "input":{
    "path","D:\\Video\\Test\\Universal.vob",
    "size":66156544,"duration":66033,
    "bitrate":8015000,
    "video":{
      "codec":"MPEG Video",
      "bitrate":7407000,
      "width":720,
      "height":480,
      "fps":"2997/100"
    },
    "audio":{
      "codec":"AC-3",
      "bitrate":448000,
      "rateMode":1,"channels":6
    }
  },
  "output":{
    "path","m:\\out2.mp4",
  }
},
{"worker":2},
{"worker":3}
]}