API Documentation

Click-AP provides a RESTful API for communicating with yakitory clients. The following describes the API.

Videos

Getting information about all videos
Web service URL:
http://your-yakitory-server.edu.tw/api/clients/:id/videos
Arguments:
  • access_key - the clients given access_key, required for authentication.
Example Response:
If authentication is successful, the following JSON is return:
{"videos":["{\"filepath\":\"http://moodle.mcu.edu.tw/yaki_videos/10/銘傳Moodle架構.wmv\",
\"audio_codec\":\"aac\",\"video_bitrate\":\"1736\",\"thumbnail_filename\":\"Movie_1_original_thumb.jpg\",\"audio_sample_rate\":\"44100\",\"client_id\":\"1\",
\"thumbnail_filepath\":\"http://moodle.mcu.edu.tw/yaki_videos/10/銘傳Moodle架構_thumb.jpg\",\"error_msg\":null,
\"container\":\"mov,mp4,m4a,3gp,3g2,mj2\",\"video_codec\":\"mpeg4\",\"width\":\"640\",\"fps\":\"59.75\",\"id\":\"10\",\"state\":\"completed\",
\"height\":\"480\",\"duration\":\"15580\",\"filename\":\"/medias/4/銘傳Moodle架構.wmv\"}"]}

Getting information about a particular video
Web service URL:
http://your-yakitori-server.edu.tw/api/clients/:id/videos/:video_id
Arguments:
  • access_key - the clients given access_key, required for authentication.
Example Response:
If authentication is successful, the following JSON is return:
{"video":"{\"filepath\":\"https://moodle.ntust.edu.tw/yaki_videos/10/Moodle小幫手.mov\",\"audio_codec\":\"aac\",
\"video_bitrate\":\"1736\",\"audio_sample_rate\":\"44100\",\"thumbnail_filename\":\"Moodle小幫手_thumb.jpg\",
\"thumbnail_filepath\":\"https://moodle.ntust.edu.tw/yaki_videos/10/Moodle小幫手_thumb.jpg\",\"client_id\":\"1\",
\"container\":\"mov,mp4,m4a,3gp,3g2,mj2\",\"error_msg\":null,
\"encodings\":[{\"filepath\":\"https://moodle.ntust.edu.tw/yaki_videos/10/Moodle小幫手_HD.flv\",
\"started_encoding_at\":\"Mon Mar 01 21:56:07 -0500 2010\",\"video_id\":\"10\",\"finished_encoding_at\":\"Mon Mar 01 21:56:09 -0500 2010\",
\"client_id\":\"1\",\"profile_id\":\"1\",\"id\":\"10\",\"state\":\"completed\",\"filename\":\"Moodle小幫手_HD.flv\"}],\"video_codec\":\"mpeg4\",
\"width\":\"640\",\"fps\":\"59.75\",\"id\":\"10\",\"filename\":\"/medias/4/Moodle小幫手.mov\",\"duration\":\"15580\",\"height\":\"480\",
\"state\":\"completed\"}"}
tes

Notifications

Yakitori can be configured to notify the client making the encoding request once all encodings for a video are complete. By setting a clients Notification URL, you tell Yakitory that this client should be notified. Once all encodings for a video are complete, Yakitory will send a notification to a URL configured for the client. The notification is a JSON object in the following format:
{
    "video_thumbnail": "https://www.moodle.com.tw/yakitory_videos/34/Movie_1_original_thumb.jpg", 
    "video_id": "34", 
    "encodings": [
        {
            "state": "completed", 
            "id": 34, 
            "filename": "Movie_1_original_HD"
        }
    ], 
    "video_state": "completed"
}

以 PHP(or Moodle) 為例:
<?php
  function var_error_log( $object=null ){
      ob_start();                    // start buffer capture
      var_dump( $object );           // dump the values
      $contents = ob_get_contents(); // put the buffer into a variable
      ob_end_clean();                // end capture
      return $contents;
  }

$videodata = json_decode( file_get_contents('php://input') );
file_put_contents('streamvideo.txt', var_error_log( $videodata));
接收後物件( streamvideo.txt ) 的結果如下:
object(stdClass)[1]
 'video_id' = string '54' (length=2)
 'video_state' = string 'completed' (length=9)
 'video_thumbnail' = string 'data/tmp_videos/54/智慧大師課程移轉5_thumb.jpg' (length=54)
 'encodings' =
 array (size=2)
 0 =
 object(stdClass)[2]
 'id' = int 77
 'container' = string 'flv' (length=3)
 'filename' = string '智慧大師課程移轉5_HD.flv' (length=32)
 'filepath' = string 'data/tmp_videos/54/智慧大師課程移轉5_HD.flv' (length=51)
 'state' = string 'completed' (length=9)
 1 =
 object(stdClass)[3]
 'id' = int 78
 'container' = string 'ts' (length=2)
 'filename' = string '智慧大師課程移轉5_-%d.ts' (length=32)
 'filepath' = string 'data/hls/54/智慧大師課程移轉5.m3u8' (length=42)
 'state' = string 'completed' (length=9)







Comments