Skip to content

For AI agents: every API docs page in one plain-text file is at /docs/llms-full.txt, and the documentation index is at /llms.txt. This page is available as Markdown at https://diffio.ai/docs/developers/guides/restore-video-and-stream.md, and every docs URL returns Markdown when requested with Accept: text/markdown.

Restore a video and stream it

Restore the speech in a video, download the restored MP4, and stream the result in a browser with hls.js.

How it works

  1. Your code → Diffio API: POST /projects, talk.mp4, generation
  2. Your code → Media host: upload.requests, the SDK sends the parts
  3. Diffio API → Your code: generation complete, files.video (MP4)
  4. Your code → Diffio API: GET /projects/{id}, video_preview_status: "ready"
  5. Your code → Diffio API: GET …/media, files.hls_master, 6 hour URLs
  6. Your code → Browser: player.html, hls_master URL
  7. Browser → Media host: GET hls_master, playlists and segments, any origin
The browser streams straight from the media host; your API key never reaches it.

Build it

  1. 1

    Restore the video

    Upload MP4, MOV, WebM, AVI, MKV, 3GP or 3G2 (up to 2 GB; see Video support) like any recording. The finished generation has files.video: the same video with the restored speech, as an MP4. file="video" (downloadFile: "video" in Node) saves it.

  2. 2

    Wait for the picture stream

    The picture for streaming is prepared from the upload: the project's video_preview_status goes preparing → ready. Until then, files.hls_master plays sound only; if it ends failed, files.video still works.

  3. 3

    Stream it

    files.hls_master plays the restored sound with the picture. Safari plays HLS itself; other browsers use hls.js. The media host answers these URLs from any origin, and they stop working at expires_at (6 hours): in production, your server asks for a fresh grant each time someone opens the player.

The complete script

Pass a video file; it writes restored.mp4 and player.html.

What you get

A restored downtown street interview in the Diffio app: the video picture above the waveform, the Restored switch and the Background amount slider at 25%

Soundtrack as uploaded

Restored by Diffio 4.7 Pro

A street interview in Kansas City with traffic passing: its soundtrack as uploaded, the speech restored by Diffio 4.7 Pro, and the restored video in the Diffio app. Video by Kansas City, Mo. City Communications, CC BY 3.0. More restored videos.
  • restored.mp4: the video with the restored speech.
  • player.html: the HLS stream with the picture, playable in any modern browser for 6 hours.
Output of python video.py talk.mp4
Terminal
saved restored.mp4 and player.html; the stream works until 2026-11-13T06:33:47Z

API reference

  • POSTCreate a project (/projects): Upload a video like any recording.
  • GETGet a project (/projects/{project_id}): has_video and video_preview_status.
  • GETGet a playback grant (/projects/{project_id}/generations/{generation_id}/media): video, hls_master, video_hls and the other files.

Report an issue with this page