How to Generate Video using Stupeflix API

| | 2 min read


Stupeflix API is a web service for developers to generate videos using texts, images and videos. To generate videos using Stupeflix API we need to do the following steps

  1. Signup for developer account using link https://developer.stupeflix.com

    Signup an account using your existing email id. Stupeflix offer a free developer account with balance $10 . If you need, you can also upgrade an account using your credit card.

  2.  

     

    Generate an API key

    Click 'Generate an API' link in the home page(see generate-api.png) it will redirect to an another page with a form. Click Create button, after filling Usage Description and Application/Website url text boxes in the form(see create-api.png). We will get an API key it is the pair of Access key and Secret key. The generated secret key passed as authorization key when we send the request to Stupeflix API.

  3. Downloaded Requests library supported by stuplefix using the link http://requests.ryanmccue.info/

  4. Create an SXML file

    To generate a video from pictures and text we need to create an XML in the format http://stupeflix-sxml.readthedocs.org/en/latest/intro.html#xml-and-full…. Because SXML passed to stuplefix API as an input parameters. The whole xml wrapped inside 'movie' tag. After that add a body tag. With in the body tag we can specify texts, images etc. Stupeflix is also give lot of themes like otline, humble, classic etc.
    In the case of an themes we can specify text and images within in the widget tag, we can specify the theme name as a type like this type = 'director.theme.humble'. For the more information about the SXML Please look on to the link format http://stupeflix-sxml.readthedocs.org/en/latest/intro.html#xml-and-full….

  5. Write a function to generate video using Stupeflix API

    After creating SXML we need to create function to send request to stupeflix and return response from stupeflix. Stupeflix provide code to generate video in link https://developer.stupeflix.com/documentation/ in different language like php, python, java etc.Please see find the code for generate video in php.

            require_once "pathto_Requests_library/Requests.php";
            Requests::register_autoloader();
            $headers = array("Authorization" => "Secret VG25JPSMLVBSFEHQ2SBFVTEYBQ");
            $data = array(
            "tasks" => array(
              "task_name" => "video.create",
              "definition" => "sampleSXML.xml"
            )
           );
          $response = Requests::post("https://dragon.stupeflix.com/v2/create", $headers, json_encode($data));
          $taskCreation = json_decode($response->body);
          $response = Requests::get("https://dragon.stupeflix.com/v2/status?tasks=" . $taskCreation[0]->key, $headers);
          $taskStatusAndResult = json_decode($response->body);
        

    First we need to include the Requests.php file from request library. Input parameters to the stupeflix API is SXML file and $headers, $headers has the secret key in an API key. Response from stupeflix is an array which has the status, result etc. The status of the response could be either "queued", "executing", "success" or "error". When the status is "success" we can downloaded generated video using the url of the video. $task_status_and_result[0]['result']['export'] is the url of the video in the $task_status_and_result array.