Transform 2D Videos into 3D SBS with lucataco/depth-anything-video-sbs Actions

24 Apr 2025
Transform 2D Videos into 3D SBS with lucataco/depth-anything-video-sbs Actions

The lucataco/depth-anything-video-sbs API offers powerful Cognitive Actions that enable developers to enhance video content by converting standard 2D videos into immersive 3D Side-By-Side (SBS) formats. This transformation is particularly beneficial for creating content compatible with advanced viewing devices, such as the Apple Vision Pro. By leveraging these pre-built actions, developers can easily integrate sophisticated video processing capabilities into their applications, enhancing user experience with minimal effort.

Prerequisites

Before you start using the Cognitive Actions from the lucataco/depth-anything-video-sbs API, ensure you have the following:

  • An API key to authenticate your requests. This key should be included in the headers of your requests.
  • The input video must be accessible via a valid URI.

Authentication typically involves passing the API key in the request headers, allowing you to securely access the Cognitive Actions.

Cognitive Actions Overview

Generate 3D SBS Video from 2D Using Depth-Anything

Description: This action converts a 2D video into a 3D Side-By-Side (SBS) video using Depth-anything for depth frame creation. This enhancement allows for a richer viewing experience on compatible devices.

Category: Video Processing

Input

The input schema for this action includes the following fields:

  • inputVideo (required): The URI of the input video to be processed. The video must be accessible via a valid URI.
    • Example: https://replicate.delivery/pbxt/KSF1kXgU3qDkCwcH24bBK1LeNUu3J7AUtuXSbxqk8K43Y6ZC/wooly-720p.mp4
  • modelType (optional): Specifies the encoder model type used for processing. Available options are vits, vitb, and vitl. The default value is vits.
    • Example: vits
  • interpupillaryDistance (optional): The distance between the centers of the pupils, measured in arbitrary units. Default is 6.34. This parameter may affect model output precision.
    • Example: 6.34

Here’s an example of the JSON payload needed to invoke this action:

{
  "modelType": "vits",
  "inputVideo": "https://replicate.delivery/pbxt/KSF1kXgU3qDkCwcH24bBK1LeNUu3J7AUtuXSbxqk8K43Y6ZC/wooly-720p.mp4",
  "interpupillaryDistance": 6.34
}

Output

Upon successful execution, this action typically returns a URI pointing to the generated 3D SBS video. Here’s an example of the output you might expect:

  • Example Output: https://assets.cognitiveactions.com/invocations/f23353f4-346b-4af9-be1c-f252fdf69991/3ce5cc31-78c7-45ff-8e5d-bc3b2e3be2b0.mp4

Conceptual Usage Example (Python)

Below is a conceptual Python code snippet demonstrating how to call the Cognitive Actions execution endpoint for the action:

import requests
import json

# Replace with your Cognitive Actions API key and endpoint
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"  # Hypothetical endpoint

action_id = "b9acf838-7dff-4f79-bbfc-c9f8fdb58fb4"  # Action ID for Generate 3D SBS Video from 2D Using Depth-Anything

# Construct the input payload based on the action's requirements
payload = {
    "modelType": "vits",
    "inputVideo": "https://replicate.delivery/pbxt/KSF1kXgU3qDkCwcH24bBK1LeNUu3J7AUtuXSbxqk8K43Y6ZC/wooly-720p.mp4",
    "interpupillaryDistance": 6.34
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json"
}

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json={"action_id": action_id, "inputs": payload}  # Hypothetical structure
    )
    response.raise_for_status()  # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully:")
    print(json.dumps(result, indent=2))

except requests.exceptions.RequestException as e:
    print(f"Error executing action {action_id}: {e}")
    if e.response is not None:
        print(f"Response status: {e.response.status_code}")
        try:
            print(f"Response body: {e.response.json()}")
        except json.JSONDecodeError:
            print(f"Response body: {e.response.text}")

In this snippet, make sure to replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action_id is set to the unique ID for the "Generate 3D SBS Video from 2D Using Depth-Anything" action, and the input payload is constructed according to the specified schema.

Conclusion

The lucataco/depth-anything-video-sbs Cognitive Actions provide developers with robust tools for transforming 2D video content into engaging 3D experiences. By integrating these actions, you can enhance your applications and offer users a richer multimedia experience. Next steps may include experimenting with different model types or interpupillary distances to optimize video quality for various viewing platforms. Happy coding!