Skip to main content

Image-to-Video


Image-to-Video

Base URLs:

  • https://api.novita.ai

POST Image-to-Video

POST /v3/async/img2video

This API helps generate video with images.

Request header parameters

  • Content-TypestringRequired

    Only application/json supported

  • AuthorizationstringRequired

    In Bearer {{Key}} format.

Request Body parameters

  • model_namestringRequired

    Model name

    Enum: SVD-XT, SVD

  • image_filestringRequired

    The base64 of input image, with a maximum resolution <= 2048 * 2048 and a max file size of 30 Mb.

  • frames_numintegerRequired

    Total video frames. When parameter model_name=SVD_XT then frames_num = 25, When parameter model_name=SVD, then frames_num = 14

  • frames_per_secondintegerRequired

    Frames per second, the larger the frame rate, the smoother the video, currenlty only support number 6.

  • seedintegerRequired

    Seed for video generation.

  • image_file_resize_modestringRequired

    The image file resize mode, when set to ORIGINAL_RESOLUTION, it represent keeping original image size, but resolution < 576x1024, when set to CROP_TO_ASPECT_RATIO, it represent keeping the original proportions of the image and crop it to within 576x1024 resolution.

    Enum: ORIGINAL_RESOLUTION, CROP_TO_ASPECT_RATIO

  • stepsintegerRequired

    Steps for generation, Range [1, 50].

  • motion_bucket_idinteger

    Motion Bucket to use for the img2vid, Range [1, 255].

  • cond_augnumber

    The amount of noise added to the conditioning image. The higher the values the less the video resembles the conditioning image. Increasing this value also increases the motion of the generated video, Range [0, 1].

  • enable_frame_interpolationboolean

    interpolate video to 24 fps.

  • extraobject

    Show properties

Responses

  • task_idstring

Example

This API helps to generate video with image. The returned video can be access by API /v3/async/task-result with task_id.

Please set the Content-Type header to application/json in your HTTP request to indicate that you are sending JSON data. Currently, only JSON format is supported.

Try it in playgroundopen in new window.

Request:

curl --location --request GET 'https://api.novita.ai/v3/async/img2video' \
--header 'Authorization: Bearer {{key}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "model_name": "SVD-XT",
    "image_file": "{{Base64 encoded image}}",
    "frames_num": 25,
    "frames_per_second": 6,
    "seed": 20231127,
    "image_file_resize_mode": "CROP_TO_ASPECT_RATIO",
    "steps": 20
}'

Response:

{
    "task_id": "fa20dff3-18cb-4417-a7f8-269456a35154"
}

Use task_id to get images

HTTP status codes in the 2xx range indicate that the request has been successfully accepted, while status codes in the 5xx range indicate internal server errors.

You can get videos url in videos of response.

Request:

curl --location --request GET 'https://api.novita.ai/v3/async/task-result?task_id=fa20dff3-18cb-4417-a7f8-269456a35154' \
--header 'Authorization: Bearer {{key}}'

Response:

{
    "task": {
        "task_id": "fa20dff3-18cb-4417-a7f8-269456a35154",
        "task_type": "IMG_TO_VIDEO",
        "status": "TASK_STATUS_SUCCEED",
        "reason": ""
    },
    "images": [],
    "videos": [
        {
            "video_url": "https://faas-output-video.s3.ap-southeast-1.amazonaws.com/test/fa20dff3-18cb-4417-a7f8-269456a35154/e40de30e115947a0be2dfc78925e587d.mp4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIASVPYCN6LRCW3SOUV%2F20231127%2Fap-southeast-1%2Fs3%2Faws4_request&X-Amz-Date=20231127T151757Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&x-id=GetObject&X-Amz-Signature=14faf7df34c2c2ff68fed102095af593844db7c5c5cd2d80e80beec0613192c7",
            "video_url_ttl": "3600",
            "video_type": "mp4"
        }
    ]
}