我正在处理PHP上的一些视频,使用zencoder对视频进行编码,将它们保存在s3上,然后在完成后通知我的网站。一切正常,直到我必须处理作为json返回的通知,并拉出新的url到保存的视频。
这一点:
$notification = $zencoder->notifications->parseIncoming();
if($notification->job->state == "finished")
{
$encode_id=$notification->job->id;
}工作正常。我只需要一些访问网址的指针。
通知以如下方式发送:
{
"output": {
"frame_rate": 30.0,
"label": "video_id_",
"total_bitrate_in_kbps": 3115,
"md5_checksum": null,
"channels": "2",
"audio_codec": "aac",
"duration_in_ms": 4225,
"video_codec": "h264",
"url": "http://my_url/597bd3592bf4a9d70f04dc676c44de6d.mp4",
"thumbnails": [{
"label": null,
"images": [{
"url": "http://my_url/_key__0000.png",
"format": "PNG",
"dimensions": "640x360",
"file_size_bytes": 482422
}]
}],
"video_bitrate_in_kbps": 3052,
"width": 640,
"format": "mpeg4",
"height": 360,
"audio_sample_rate": 44100,
"state": "finished",
"audio_bitrate_in_kbps": 63,
"id": 41424918,
"file_size_in_bytes": 1625847
},
"input": {
"frame_rate": 30.0,
"total_bitrate_in_kbps": 3867,
"md5_checksum": null,
"channels": "2",
"audio_codec": "aac",
"duration_in_ms": 4167,
"video_codec": "h264",
"video_bitrate_in_kbps": 3764,
"width": 640,
"format": "mpeg4",
"height": 360,
"audio_sample_rate": 44100,
"state": "finished",
"audio_bitrate_in_kbps": 103,
"id": 22371764,
"file_size_in_bytes": 2028809
},
"job": {
"created_at": "2012-07-14T22:25:08Z",
"test": true,
"updated_at": "2012-07-14T22:25:47Z",
"submitted_at": "2012-07-14T22:25:08Z",
"pass_through": null,
"state": "finished",
"id": 22377083
}
}但是像这样的东西:$video_file=$notification->output->url;不需要。我漏掉了什么?
发布于 2012-07-31 07:34:15
如果您不想使用parseIncoming方法...使用:
$notification = json_decode(trim(file_get_contents('php://input')), true);与之相对的:
$notification = $zencoder->notifications->parseIncoming();第二个参数'true‘将结果格式化为一个数组,而不是一个对象。从那里,您可以访问所有值,如下所示:
$notification['output']['file_size_in_bytes'];parseIncoming方法将返回一个stdClass,因此引用其中的值是这样完成的:
$notification->keyhttps://stackoverflow.com/questions/11488460
复制相似问题