Vizard AI offers a robust API that enables developers to seamlessly integrate AI-powered video clipping and transcription into their applications. This guide provides a comprehensive, step-by-step approach to utilizing the Vizard AI API, ensuring you can efficiently transform long-form videos into engaging, short clips suitable for various platforms.
Step 1: Generate Your API Key
To begin, you need to obtain an API key from Vizard AI:
Access the API Key Generation Page:
Log in to your Vizard AI account.
Navigate to the 'Workspace' section.
Click on 'Invite' and then select 'API'.
Generate the API Key:
Click the "Get API Key" button. Your unique API key will be displayed within seconds.
Note: This feature requires a Pro plan.
Important: Treat your API key like a password. Keep it confidential and do not share it with anyone.
Step 2: Post a Long Video
With your API key ready, you can now post a long video for processing:
Prepare the Request:
URL: https://elb-api.vizard.ai/hvizard-server-front/open-api/v1/project/create
Method: POST
Headers:
Content-Type: application/json
VIZARDAI_API_KEY: YOUR_API_KEY
Construct the Request Body: The body should be a JSON object containing the following parameters:
json
Copiar código
{ "lang": "en", "videoUrl": "https://example.com/video.mp4", "ext": "mp4", "preferLength": [0], "projectName": "Sample Video", "subtitleSwitch": 1, "headlineSwitch": 1, "videoType": 1 }
lang: Language code of the video (e.g., "en" for English).
videoUrl: The URL of the remote video. Ensure it starts with http or https and is downloadable.
ext: Extension of the video file (e.g., "mp4", "3gp", "avi", "mov").
preferLength: Desired duration of the clipped video. Options are:
0: Auto
1: Less than 30s
2: 30s to 60s
3: 60s to 90s
4: 90s to 3min
projectName: (Optional) Name of the long video.
subtitleSwitch: (Optional) Subtitle switch. 0 for off; 1 for on (default value).
headlineSwitch: (Optional) Headline switch. 0 for off; 1 for on (default value).
videoType: Type of the video:
1: Remote video file that can be downloaded directly through a web browser.
2: YouTube link.
3: Google Drive link.
4: Vimeo link.
5: StreamYard link.
Note: The videoType parameter is mandatory.
Send the Request: Use your preferred HTTP client to sen with the constructed headers and body.
Step 3: Poll for Short Clips
After submitting the video, you can retrieve the generated clips:
Prepare the Polling Request:
URL: https://elb-api.vizard.ai/hvizard-server-front/open-api/v1/project/query/{projectId}
Method: GET
Headers:
VIZARDAI_API_KEY: YOUR_API_KEY
Send the Request: Replace {projectId} in the URL with the actual project ID received from the creation response.
Handle the Response: The response will be a JSON object containing the status code and, upon successful processing, a list of video clips with their download URLs.
Step 4: Download and Utilize the Clips
Once the clips are generated:
Download the Clips: Use the provided download URLs to fetch the video clips. Note that these URLs are valid for 3 hours; ensure you download them within this timeframe.
Integrate into Your Application: Incorporate the downloaded clips into your application as needed, whether for social media posts, marketing materials, or other uses.
Additional Considerations
Rate Limits: The API allows 3 requests per minute and 20 requests per hour.
Supported Video Sources:
The Vizard AI API supports several video sources, which allows you to upload videos from various platforms. Here are the supported video types:
Remote Video:
URL of the remote video that can be downloaded directly through a web browser. The videoType should be set to 1 in this case.
YouTube Video:
You can provide a YouTube video link. This is useful for videos hosted on YouTube. Set videoType to 2 for YouTube links.
Google Drive:
If your video is hosted on Google Drive, you can provide the Google Drive URL. Use videoType set to 3 for this source.
Vimeo Video:
Vimeo video links are also supported. Use videoType set to 4 for Vimeo video sources.
StreamYard Video:
For videos hosted on StreamYard, you can provide the video URL and set videoType to 5.
Each of these video sources has its specific use case, and you should select the appropriate one based on where your video is hosted.
Step 5: Error Handling
When working with any API, it’s important to handle errors gracefully to ensure a smooth user experience. Here are some common error codes you might encounter when using the Vizard AI API and how to address them:
Invalid API Key (Error Code 401):
This occurs when the API key provided is incorrect or missing. Double-check that your API key is correct and included in the request header as VIZARDAI_API_KEY: YOUR_API_KEY.
Solution: Verify your API key in your account dashboard and ensure that it is correctly included in the header of your request.
Invalid Video URL (Error Code 400):
If the video URL is malformed, unreachable, or incompatible, the API will return this error.
Solution: Ensure that the video URL starts with http or https and that it points to a downloadable video. You can test the URL by opening it in a web browser.
Server Issues (Error Code 500):
This error indicates an issue with the Vizard AI server. It might occur temporarily due to server overload or internal issues.
Solution: Retry the request after some time. If the issue persists, contact Vizard AI support for further assistance.
Timeout (Error Code 408):
This occurs if the request takes too long to process. It may happen if the video file is too large or the server is under heavy load.
Solution: Retry the request, and ensure that your video file meets the size and format specifications outlined in the documentation. Consider uploading smaller files if necessary.
Step 6: Managing Your Projects
Once you've successfully integrated the Vizard AI API into your application, it's important to manage your projects effectively. Here are some tips to keep track of and organize your video projects:
Project Naming and Tagging:
To stay organized, use clear and descriptive names for your video projects in the projectName parameter. You can also create a system of tags or labels to categorize your projects by type, target audience, or campaign.
Monitoring Project Status:
Regularly poll the API for the status of your video projects. If you’re working with multiple video clips at once, it’s crucial to ensure that all clips have been successfully processed before downloading them.
Archiving and Cleanup:
Once your clips are downloaded and integrated into your application, archive or delete old projects to keep your workspace clean. This will help prevent clutter and ensure you’re always working with the latest content.
Step 7: Best Practices for Video Clipping
To get the most out of the Vizard AI API, consider these best practices for video clipping:
Video Quality:
Always upload high-quality videos for better results. The API works best when given videos with clear audio and high resolution. Low-quality videos may result in poor clip quality, especially in the automated transcription and headline generation processes.
Optimize for Social Media:
When selecting the preferred length of the clip, consider your target platform. For example, if you plan to post on Instagram or TikTok, choose shorter clips (preferably under 60 seconds). The API allows you to specify the length of the clips, so tailor this to your needs.
Ensure Accurate Transcriptions:
If you enable subtitles and headlines, ensure that the video’s audio is clear and free of background noise. Clear speech and well-recorded videos will yield better results when the API generates transcriptions and headlines.
Test and Adjust:
Don’t hesitate to experiment with different settings (like preferLength and subtitleSwitch) to find the optimal configuration for your videos. Testing and adjusting based on the results will help you fine-tune your process for the best outcomes.
Step 8: Scaling Your Use of Vizard AI API
As your needs grow and you start processing more videos, you may want to consider scaling your use of the Vizard AI API:
Batch Processing:
If you're working with large volumes of video content, consider implementing batch processing. This involves submitting multiple video requests in quick succession or scheduling requests during off-peak hours to avoid hitting rate limits.
Automate Video Uploads and Polling:
Use webhooks or set up automated scripts to upload videos and poll for results without manual intervention. This can significantly speed up your workflow and reduce the overhead of managing multiple projects.
Optimize for Different Video Types:
Depending on your audience or project, you may need to work with different video sources (e.g., YouTube, Vimeo, or Google Drive). Vizard AI supports various video types, so optimize your integration by selecting the right source for each project.
Conclusion
The Vizard AI API is a powerful tool that allows you to automate the process of clipping long-form videos, creating engaging short clips, and transcribing content for social media or marketing purposes. By following this detailed, step-by-step guide, you can efficiently integrate the API into your workflow, customize video processing to meet your needs, and handle any errors or challenges that may arise. With its flexibility and scalability, the Vizard AI API is a valuable resource for developers looking to leverage AI for video content creation and management.
By understanding the API's features and best practices, you’ll be able to streamline your video clipping process, create high-quality clips faster, and unlock new opportunities for engagement and content distribution.
Comments