Product Video in Colab
Upload a product photo and generate a five-second clip.
Lip Sync in Colab
Upload a video and voiceover, then preview and download the result.
Before you start
-
Install Python 3.10 or later and create a virtual environment:
On Windows, activate it with
.venv\Scripts\Activate.ps1in PowerShell. -
Create an API key, then set
MAGIC_HOUR_API_KEYin your terminal environment. Keep the key out of source control, browser code, and shared notebooks. - Use files you own or have permission to use. For lip sync, obtain permission from the person whose likeness and voice you use.
Product photo → five-second video
For a store owner, marketer, or developer prototyping product clips: put a clear product image namedproduct.jpg beside your script. A single product with an
uncluttered background is a useful starting point.
Save this as product_video.py, then run python product_video.py from that folder:
Existing video + voiceover → lip-synced clip
For a creator or localization workflow: putspeaker.mp4 and voiceover.mp3
beside your script. Use a video with one clearly visible face and clean speech
audio. Both inputs should cover at least the first five seconds.
This recipe syncs mouth movement to audio you already supply; it does not
translate a script, clone a voice, or generate the voiceover.
Save this as lip_sync.py, then run python lip_sync.py from that folder:
end_seconds to a range covered by your inputs; review the
Lip Sync reference first.
Recover a result without generating again
Both recipes print the project ID before waiting for the render. Save that ID. If polling or downloading fails, do not rerun the creation script just to recover the output: that would submit another billable generation. Instead, save this asrecover_video.py, replace the ID, and run
python recover_video.py:
error or canceled project will not resume rendering through this call.
Inspect the returned error before deciding whether to submit a new project. If
creation itself times out before returning an ID, check your dashboard before
retrying; the server may have accepted the request.
Move beyond a local prototype
- Keep generation on your backend, not in a browser request with an exposed key.
- Store the project ID with the user’s request so interrupted work can be recovered.
- The SDK polling helper waits until a terminal status; it has no overall render deadline. For production, use a background worker or webhooks, not a long-running web request.
- Download or copy completed output to your storage. See Inputs and Outputs for file handling.
- Keep the human quality check before turning a one-clip recipe into a batch job.