Best Practices
Best Practices for Video to Video Generation
Efficient API Usage:
- When calling the video to video API, store the returned
img_uuid
for subsequent requests. - Implement a polling mechanism to check the status of your video generation.
- When calling the video to video API, store the returned
Optimal Polling Strategy:
- Set your polling interval to 5 seconds between each request to the details API.
- This balance helps to get timely updates without overwhelming the server.
Handle Long-Running Processes:
- Be prepared for potentially long processing times, especially for complex video transformations.
- Implement appropriate timeout handling and user feedback in your application.
Secure Storage of Results:
- When you receive the final video URL (valid for 24 hours), download the video promptly.
- Store the downloaded video on your own secure server for long-term access and to avoid link expiration issues.
Error Handling:
- Implement robust error handling for all API calls.
- Have fallback strategies for cases where video generation fails or takes longer than expected.
Resource Management:
- Keep track of your API usage to stay within your plan limits.
- Implement rate limiting on your end to prevent accidental overuse of the API.
User Experience:
- Provide clear feedback to your users about the status of their video generation process.
- Consider implementing a notification system for when videos are ready.
Caching Strategy:
- Cache frequently used or popular video transformations to reduce API calls and improve response times.
Security:
- Never expose your API key in client-side code.
- Use server-side requests to interact with the GoEnhanceAI API.
sequenceDiagram
participant C as Client
participant S as Your Server
participant API as GoEnhanceAI API
C->>S: Request video transformation
S->>API: POST /api/v1/video2video/generate
API-->>S: Return job_id
S-->>C: Acknowledge request
loop Every 5 seconds
S->>API: GET /api/v1/jobs/detail (with job_id)
API-->>S: Return status
alt Status is "completed"
S->>API: Get video URL from job details
API-->>S: Return video URL (24h validity)
S->>S: Download and store video
S-->>C: Notify video is ready
else Status is "failed"
S-->>C: Notify of failure
else Status is "processing"
Note over S: Continue polling
end
end
C->>S: Request processed video
S-->>C: Serve video from local storage
- The client requests a video transformation from your server.
- Your server makes a POST request to the GoEnhanceAI API to initiate the video generation.
- The API returns an
img_uuid
, which your server uses for subsequent requests. - Your server acknowledges the client's request.
- Your server then enters a polling loop, checking the status every 5 seconds:
- If the status is "completed", it retrieves the video URL, downloads and stores the video, then notifies the client.
- If the status is "failed", it notifies the client of the failure.
- Finally, when the client requests the processed video, your server serves it from local storage.
Last modified: 3 months ago