Skip to content

Latest commit

 

History

History
200 lines (139 loc) · 53.7 KB

File metadata and controls

200 lines (139 loc) · 53.7 KB

InputVideo

Overview

Available Operations

create_media

This endpoint allows developers or users to create a new video or audio media in FastPix using a publicly accessible URL. FastPix fetches the media from the provided URL, processes it, and stores it on the platform for use.

Public URL requirement:

The provided URL must be publicly accessible and must point to a video stored in one of the following supported formats: .m4v, .ogv, .mpeg, .mov, .3gp, .f4v, .rm, .ts, .wtv, .avi, .mp4, .wmv, .webm, .mts, .vob, .mxf, asf, m2ts

Supported storage types:

The URL can originate from various cloud storage services or content delivery networks (CDNs) such as:

  • Amazon S3: URLs from Amazon's Simple Storage Service.

  • Google Cloud Storage: URLs from Google Cloud's storage solution.

  • Azure Blob Storage: URLs from Microsoft's Azure storage.

  • Public CDNs: URLs from public content delivery networks that host video files.

Upon successful creation, the API returns an id that must be retained for future operations related to this media.

How it works

  1. Send a POST request to this endpoint with the media URL (typically a video or audio file) and optional media settings.

  2. FastPix uploads the video from the provided URL to its storage.

  3. Receive a response containing the unique id for the newly created media item.

  4. Use the id in subsequent API calls, such as checking the status of the media with the Get Media by ID endpoint to determine when the media is ready for playback.

FastPix uses webhooks to tell your application about things that happen in the background, outside of the API regular request flow. For instance, after the media file is created (but not yet processed or encoded), FastPix sends a POST request to your specified webhook URL with the event video.media.created.

After processing completes, monitor the events video.media.ready and video.media.failed to track the status of the media file.

Related guide: Upload videos from URL

Example Usage

import os
import json

from fastpix_python import Fastpix, models

with Fastpix(
    security=models.Security(
        username="your-access-token",
        password="your-secret-key",
    ),
) as fastpix:

    res = fastpix.input_video.create_media(
        inputs=[
            {
                "type": "video",
                "url": "https://static.fastpix.com/fp-sample-video.mp4",
            },
        ],
        access_policy="public",
        metadata={
            "key1": "value1",
        },
        subtitles={
            "language_name": "english",
            "metadata": {
                "key1": "value1",
            },
            "language_code": "en",
        },
        mp4_support="capped_4k",
        source_access=True,
        optimize_audio=True,
        max_resolution="1080p",
        chapters=True,
        named_entities=True,
    )

    # Handle response
    print(json.dumps(res.model_dump(mode="json", by_alias=True, exclude_unset=True), indent=2))

Parameters

Parameter Type Required Description Example
inputs List[models.CreateMediaRequestInput] ✔️ Add one input object at a time. For example, first add a VideoInput object. If you also need a watermark, click Add item again and select WatermarkInput. Repeat this process for AudioInput or SubtitleInput as needed. For a complete explanation of how media uploads from URL and processing work, refer to the
FastPix Video on Demand Overview.
metadata Dict[str, str] ➖ You can search for videos with specific key value pairs using metadata, when you tag a video in "key" : "value" pairs. Dynamic metadata allows you to define a key that allows any value pair. You can have maximum of 255 characters and upto 10 entries are allowed.
{
"key1": "value1"
}
drm_configuration_id Optional[str] ➖ UUID of the DRM configuration to be used your-drm-configuration-id
title Optional[str] ➖ Title of the media file. your-video-title
creator_id Optional[str] ➖ The unique identifier of the user who created this media. your-creator-id
subtitles Optional[models.Subtitles] ➖ Generates subtitle files for audio/video files.
access_policy Optional[models.CreateMediaRequestAccessPolicy] ➖ Determines whether access to the streamed content is kept private or available to all.
public
mp4_support Optional[models.CreateMediaRequestMp4Support] ➖ "capped_4k": Generates an mp4 video file up to 4k resolution "audioOnly": Generates an m4a audio file of the media file "audioOnly,capped_4k": Generates both video and audio media files for offline viewing
capped_4k
source_access Optional[bool] ➖ The sourceAccess parameter determines whether the original media file is accessible. Set to true to enable access or false to restrict it true
optimize_audio Optional[bool] ➖ normalize volume of the audio track. This is available for pre-recorded content only.
true
max_resolution Optional[models.CreateMediaRequestMaxResolution] ➖ The maximum resolution tier defines the highest quality at which your media is available.
1080p
media_quality Optional[models.CreateMediaRequestMediaQuality] ➖ The quality tier applied to the media. standard
summary Optional[models.Summary] ➖ N/A
chapters Optional[bool] ➖ Enable or disable the chapters feature for the media. Set to true to enable chapters or false to disable.
true
named_entities Optional[bool] ➖ Enable or disable named entity extraction. Set to true to enable or false to disable.
true
moderation Optional[models.Moderation] ➖ N/A
access_restrictions Optional[models.CreateMediaRequestAccessRestrictions] ➖ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.CreateMediaResponseResponse

Errors

Error Type Status Code Content Type
errors.FastpixDefaultError 4XX, 5XX */*

direct_upload_video_media

This endpoint enables accelerated uploads of large media files directly from your local device to FastPix for processing and storage.

NOTE

This version now supports uploads with no file size limitations and offers faster uploads. The previous endpoint (which had a 500MB size limit) is now deprecated. You can find details in the changelog.

How it works

  1. Send a POST request to this endpoint with optional media settings.

  2. The response includes an uploadId and a signed url for direct video file upload.

  3. Upload your video file to the provided url by making a PUT request. The API accepts the media file from your device and uploads it to the FastPix platform. (Refer to Step 3: Initiate the upload for complete instructions.)

  4. Once uploaded, the media undergoes processing and is assigned a unique ID for tracking. Retain this uploadId for any future operations related to this upload.

After uploading, you can use the Get Media by ID endpoint to check the status of the uploaded media asset and see if it has transitioned to a Ready status for playback.

To notify your application about the status of this API request check for the webhooks for media related events.

Example

A social media platform allows users to upload video content directly from their phones or computers. This endpoint facilitates the upload process. For example, if you are developing a video-sharing app where users can upload short clips from their mobile devices, this endpoint enables them to select a video, upload it to the platform.

Related guide: Upload videos directly

Example Usage

import os
import json

from fastpix_python import Fastpix, models

with Fastpix(
    security=models.Security(
        username="your-access-token",
        password="your-secret-key",
    ),
) as fastpix:

    res = fastpix.input_video.direct_upload_video_media(request={
        "push_media_settings": {
            "metadata": {
                "key1": "value1",
            },
        },
    })

    # Handle response
    print(json.dumps(res.model_dump(mode="json", by_alias=True, exclude_unset=True), indent=2))

Parameters

Parameter Type Required Description
request models.DirectUploadVideoMediaRequest ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.DirectUploadVideoMediaResponse

Errors

Error Type Status Code Content Type
errors.FastpixDefaultError 4XX, 5XX */*