Video pipeline: from script to a YouTube-ready MP4
Have an idea for an appliance overview, household tutorial, or dashboard demo, but dread editing the video? Pi Agent's pitch_video pipeline connects AI scriptwriting, synthetic narration, browser capture, editing, burned-in subtitles, and cloud upload. You provide the idea; the result is an MP4 ready for YouTube or a group chat. This chapter explains what the pipeline does, when it works well, and where it falls short. Chapter 18 covers the 720 MB first-start download, while Chapter 19 explains automatic Google Drive uploads.
Why use this video pipeline?
Here is the practical problem: you have something worth sharing, but producing a watchable video takes time and skills you may not have.
Perhaps you want to share an overview of a new robot vacuum with friends, demonstrate a one-tap “Away” automation on your Home Assistant dashboard, or record instructions showing a child how to control the living-room lights from a tablet. Editing, narration, and captions can turn a simple idea into hours of work—and operating the interface while speaking often takes several attempts.
The built-in video pipeline addresses that problem. The add-on provides the underlying tools—ffmpeg, Playwright with Chromium, edge-tts, and rclone—while an installed Skill coordinates them. Community versions are often called pitch_video or pi-video; the actual slug depends on the version you install (see Chapter 15). Tell the AI, in English, what kind of video you want, how long it should be, and who will watch it. The pipeline then works through these stages:
- Draft the script—organize the opening, main content, and closing, with a duration for each section.
- Generate narration—use Microsoft's edge-tts engine to convert the English script into speech.
- Capture the screen—open an invisible browser with Playwright and record the scripted actions scene by scene.
- Edit the video—combine the visuals, narration, and subtitles with ffmpeg, then add transitions.
- Upload the result—send the completed video to a configured Google Drive folder with rclone so that it is available on your other devices.
The rendering work runs on your Home Assistant host, so you do not need a separate editing computer or another software subscription. Your two main tasks are to define the video clearly and decide whether the finished result meets your needs. The AI and the tools handle the production steps.
What happens behind the scenes: six stages
To use the pipeline effectively, first understand what it does. Think of it as a production line in which six stages turn your request into a finished file:
| Stage | What happens | Tool | Approximate time for a 3-minute video |
|---|---|---|---|
| 1. Write the script | The AI reads your request, divides the English narration into sections, assigns a duration to each section, and decides what to show. | The AI provider configured in Chapters 5 and 11; a reasoning model is recommended | 30 seconds to 1 minute, including your confirmation |
| 2. Generate narration | Text-to-Speech (TTS) converts each section of the English script into a WAV or MP3 file. | edge-tts, the TTS engine used by Microsoft Edge | 10–30 seconds |
| 3. Capture the screen | A headless browser follows the script, performs each action, and records the screen. | Playwright + Chromium | 1–3 minutes, approximately the video's running time |
| 4. Align subtitles | Word-boundary timestamps from the narration are used to create an SRT subtitle file, with a start and end time for each caption. | edge-tts SubMaker (word-boundary events → SRT) |
A few seconds |
| 5. Edit and burn in subtitles | The visuals, narration, and subtitles are combined into an MP4, with fade transitions between sections. | ffmpeg, including the libass subtitle engine and xfade transition filter | 30 seconds to 2 minutes |
| 6. Upload to the cloud | The finished MP4 is transferred to your chosen Google Drive folder for viewing in the mobile app. | rclone, a cloud-storage synchronization tool | Usually 30 seconds to 3 minutes, depending on upload speed |
Altogether, a 3-minute video usually takes about 5 to 10 minutes from the moment you approve the job until it reaches Google Drive. The exact time depends on your hardware, network, and installed Skill. You can do something else while the pipeline runs quietly on the Home Assistant host.
Why does first startup download 720 MB?
When first installed (see Chapter 2), Pi Agent itself is only a few dozen MB. The first time you start the add-on, however, it downloads approximately 600–720 MB in the background. That might take 1–2 minutes on a 100 Mbps home connection and will be more noticeable on a mobile hotspot. One common misconception is worth correcting: the video pipeline does not trigger this download. The add-on's video-tools-init process starts it in the background on first launch. Nor does the 720 MB contain every pipeline tool; it is the portion downloaded to the /data/pi-agent/ volume. The other portion—ffmpeg, libass, fonts, and rclone—is already built into the add-on's container image and arrives with the roughly 300 MB image download.
| Downloaded to the volume | Purpose | Approximate size |
|---|---|---|
| Chromium browser (Playwright build) | Playwright uses this browser for screen capture. It runs without displaying a window and accounts for most of the download. | About 500–600 MB |
| Python virtual environment + 4 packages | A virtual environment containing playwright (Python browser control), edge-tts (TTS narration), pyyaml (script-file parsing), and mutagen (audio-duration detection) |
About 40–60 MB |
This is the download commonly described as “about 720 MB”; the actual total is between 600 and 720 MB, depending on the Playwright version and pip dependencies. The following tools require no additional download because they are part of the container image:
| Tool built into the image | Purpose |
|---|---|
| ffmpeg + libass | Core tools for editing, xfade transitions, and burned-in subtitles |
| fonts-noto-cjk / fonts-noto-color-emoji / fontconfig | Fonts and font handling for legible subtitles and color emoji |
| rclone | Uploads to services such as Google Drive, Dropbox, and OneDrive |
If you never install Pi Agent, it never uses this additional 720 MB. Once you start the add-on, however, the files are downloaded to the volume even if you never create a video; there is currently no “chat-only mode” switch. Chapter 18 explains the details.
Where this pipeline works well
Match the pipeline's strengths to practical situations and you will find more uses than you might expect:
| Scenario | Typical length | Example prompt | Audience |
|---|---|---|---|
| Appliance overview | 60–120 seconds | “Create a 90-second video in English introducing my new robot vacuum. Cover its key features and compare it with the previous model.” | Family group chat, friends, or an online community |
| Household instructions for children or older adults | 60–180 seconds | “Explain in English, using language a primary-school student can understand, how to sort paper, plastic, metal cans, and food waste for recycling.” | Family members, a school community, or older relatives |
| Home Assistant automation demo | 60–180 seconds | “Record what happens when I select ‘Away mode’ on my Home Assistant dashboard, with English narration explaining each action.” | Household members, the Home Assistant community, or blog readers |
| Product review | 90–240 seconds | “Turn my notes from 2 weeks of using this app into an English video covering 3 advantages and 2 disadvantages.” | YouTube viewers or social-media followers |
| Lesson for children | 60–120 seconds | “Explain solar power generation in English for a 10-year-old, using a friendly narration style.” | Family devices or a school assignment |
| Short group-chat update | 30–60 seconds | “Create a 30-second English video explaining what everyone should prepare for severe weather.” | A group chat, where burned-in subtitles help people watching without sound |
| Recipe demonstration | 60–180 seconds | “Create a 3-minute English tutorial for a simple cucumber salad, including ingredients, steps, and key precautions.” | A family group chat or blog audience |
| Calendar or event preview | 15–45 seconds | “Create a relaxed 20-second English preview of our weekend family schedule.” | A group chat or shared calendar |
These examples have one feature in common: they are short videos driven by explanation rather than on-camera performance. You do not need to appear on screen, choreograph complex camera moves, or buy expensive equipment. The pipeline turns knowledge into narration, visuals, and subtitles—a format that can be easier to follow than plain text and far quicker to produce than a manually edited video.
Where this pipeline falls short
No tool can do everything. Avoid forcing pitch_video into the following situations, where a different production method will give you a much better result:
| Unsuitable scenario | Why it falls short | Alternative |
|---|---|---|
| On-camera performances | Playwright can operate a browser and capture a computer screen, but it cannot film you. AI-generated people may also look unconvincing. | Film with a phone and edit the footage in an app such as CapCut, or combine your phone footage with narration and graphics from the pipeline. |
| Background music with licensing requirements | The pipeline handles narration, not background music. Music from the YouTube Audio Library or another source must be added separately. | Add music to the finished video in CapCut or iMovie, or, if you are comfortable with ffmpeg, add a music track through the pitch_video Skill. |
| Long-form videos over 10 minutes | Long Playwright captures consume substantial CPU time; generating 10 minutes of narration takes several minutes, and rendering a large file takes even longer. | Split the material into episodes of no more than 5 minutes, or use dedicated editing software for a long video. |
| Complex camera work, effects, or cuts | The visuals come from a browser recorded by Playwright. The pipeline cannot create elaborate camera moves or effects; it provides only basic xfade transitions. | For a cinematic result, use CapCut, Premiere, or DaVinci Resolve. |
| Live streaming | This is a batch-production pipeline, not a live system. Producing one video takes 5–10 minutes. | Use OBS or a mobile live-streaming app instead. |
| Copyright-sensitive material | An AI-written script may draw on information from your sources, while the narration is synthetic. Distribution and commercial use require careful attention to copyright and AI-disclosure rules. | For commercial use, confirm that your sources are lawful, label AI-generated material where required, and check Microsoft's current terms for commercial use of edge-tts. |
Hands-on: create your first video
Assume you have completed all 3 prerequisites: the first-start download in Chapter 18, rclone setup for Google Drive in Chapter 19, and pitch_video Skill installation in Chapter 15. Here is how to produce a video:
-
Open a new Session and choose a reasoning-capable AI
Return to the main Pi Agent screen and select “New conversation” in the upper-left corner to create a Session (see Chapter 8). Choose a reasoning model from the model menu—for example, GLM-4.6, Anthropic Claude Sonnet, or DeepSeek-R1. Do not use the least capable budget model: the script determines the video's quality, so this is one place where a stronger model is worthwhile. As Chapter 12 explains, reasoning models plan before answering and tend to produce better-structured scripts.
-
Describe the video clearly in plain language
Type your request directly into the conversation. For example: “Create a 90-second video in English explaining how much electricity our smart plug could save for a typical 3-person household. Use a relaxed tone for an older general audience.” Include 4 elements: (1) length, (2) topic, (3) tone, and (4) audience. The more specific your request, the closer the English script will be to what you want.
-
Review the outline and request changes
The AI should first show you an outline and draft script rather than immediately starting production—for example, a 10-second opening that introduces the problem, a 60-second main section with 3 points about saving energy, and a 20-second call to action. Review it carefully: Is the order right? Does the tone sound like you? Has it included anything you do not want? Reply with specific English instructions such as “In the English script, rewrite the second section to focus on XX” or “Shorten the English opening to 5 seconds.” The AI will revise it. Several rounds of revision are normal and much faster than rebuilding the final video later.
-
Approve the script and let the AI call the pitch_video Skill
Once you reply, “Yes, use this English script,” the AI calls the pitch_video Skill installed in Chapter 15. A tool card appears in the conversation (see Chapter 9) and reports the current stage: generating narration, capturing the screen, or editing. You can leave the window while it works; the job continues even when you are not watching it.
-
Retrieve the finished video a few minutes later
If you configured Google Drive upload (see Chapter 19), the finished MP4 appears in the selected folder and may trigger a notification in the Google Drive mobile app. Without Google Drive, the file remains at
/data/pi-agent/projects/<project-name>/on the Home Assistant host. Download it with a file-management add-on such as Samba or File Editor. -
If you are not satisfied, ask for another version
If the narration is too fast, the subtitles are poorly positioned, or a section is too long, give the AI a new English instruction in the same Session: “Create another English version with slower narration and no opening section.” It can adjust the settings and rerun the same script. If the script itself needs work, say, “Rewrite the entire script in English in an XXX style,” and the pipeline will start again from the beginning. You do not have to edit the configuration file yourself; describe the revisions in the conversation.
Where the final and intermediate files are stored
The pipeline produces more than a single MP4. It also retains intermediate files that you can edit, reuse, or process independently. They are stored under /data/pi-agent/projects/<project-name>/; the add-on creates the projects/ directory on first startup, and you can verify it in File Editor. The filenames and extensions below represent a typical layout for a community pitch_video Skill. The webm, wav, and srt extensions match common Playwright, edge-tts, and ffmpeg outputs. Your installed version or custom configuration may differ, so treat the files in your project directory as authoritative:
| File | What it contains | How you can use it |
|---|---|---|
final.mp4 |
The finished video, combining visuals, narration, and subtitles | Upload it directly to YouTube, a messaging service, or a social network. |
subtitles.srt |
A timed plain-text subtitle file | Upload it separately to YouTube as an English caption track, or translate it to create additional language tracks. |
script.md |
The original AI-written English script in Markdown | Edit it and rerun the pipeline, or adapt it into a blog post. |
voice/*.wav |
A separate narration track for each section | Reuse a track in a podcast or another video, or even as a notification sound. |
clips/*.webm |
Individual screen recordings captured by Playwright | Add different narration to a clip or turn part of it into a GIF. |
segments/*.mp4 |
Individual rendered sections with narration and subtitles | Share one section independently instead of sending the entire video. |
project.json |
The project's settings and parameter record | Reuse the same settings for another video in a similar style. |
This structure means that you are not limited to accepting the final video or starting again from scratch. To change the script, edit script.md and rerun the workflow. To use a different voice, replace the contents of voice/. To reuse a single section, take it from segments/. This is a composable workflow: every stage leaves an asset that you can work with.
clips/, segments/, and voice/; pipeline outputs can grow large enough to overwhelm a backup. It retains the smaller essential files: final.mp4, script.md, subtitles.srt, and project.json. Copy the entire project to a NAS separately if you want to preserve every intermediate file.Complete these 3 prerequisites first
A common first-time frustration is asking the AI, in English, to create a video and being told that it cannot. In most cases, one of these prerequisites is missing:
| Prerequisite | Where to complete it | Symptom when missing | How to verify it |
|---|---|---|---|
| Install the pitch_video Skill | Chapter 14 explains the concept; Chapter 15 covers installation. | The AI says, “I do not have a tool that can create an English video for you.” | The pitch_video entry has a green status indicator in Pi Agent Settings → Skills. |
| Complete the 720 MB first-start download | Chapter 18 | The tool remains on “Preparing environment” for a long time, or the error says that Chromium, Playwright, or ffmpeg is missing. | You have successfully run pitch_video once and produced a finished file; later runs start more quickly. |
| Configure rclone for Google Drive (optional, but strongly recommended) | Chapter 19 | The video is complete but no cloud notification arrives, so you must retrieve the file with File Editor. | The finished video appears in the selected Google Drive folder on your mobile device. |
Completing all 3 gives you the full end-to-end workflow. You can skip Google Drive while testing; the output remains in /data/pi-agent/projects/ and can be retrieved with a file-management add-on, but it will not synchronize automatically to your other devices.
What does one video cost?
The pipeline itself has little direct monetary cost. The primary usage-based expense is the API call used to write and revise the English script. Always check the current terms and prices for your chosen services:
| Cost item | Resource used | Typical cost for a 90-second video |
|---|---|---|
| AI scriptwriting | The provider configured in Chapter 5 | Usually the only direct API charge. A 90-second script uses approximately 1–3K tokens, with the total depending on the selected model and how many revisions you request. See Chapter 10 for pricing context, then confirm the provider's current rates. |
| TTS narration | edge-tts, provided by Microsoft | No separate charge for personal use is identified here; check Microsoft's current terms, especially for commercial use. |
| Playwright screen capture | Your Home Assistant host's CPU | No separate API charge, although the host consumes electricity. |
| ffmpeg editing | Your Home Assistant host's CPU and RAM | No separate API charge. |
| Google Drive upload | rclone and a Google account with 15 GB of shared Gmail, Drive, and Photos storage; from May 2026, some new accounts in certain regions may start with 5 GB until a phone number is verified | No separate charge while you remain within the account's included quota; paid storage pricing varies by market and plan. |
| Electricity | Several minutes of CPU-intensive work on the Home Assistant host | Usually negligible for a single video, but the actual amount depends on your hardware and electricity tariff. |
For a 90-second video, the model and the number of revisions determine most of the direct cost. A lower-cost provider can reduce that amount, although a less capable model may produce a weaker script. Choose according to the quality you need and verify the live rate before running a large batch.
Advanced: parameters you can customize
The default pipeline output should already be usable. Once you have completed several successful runs, you can consider adjusting the following settings:
- Resolution: The default is 1080p (Full HD). At 720p, files are smaller and uploads are faster, which suits group-chat sharing. A 4K file is much larger and is generally worthwhile only for platforms such as YouTube.
- Frame rate: The default is 30 fps (30 frames per second). A 60 fps video is smoother but larger; 24 fps can create a cinematic feel, although screen motion may look less fluid.
- Narration voice: Choose an English edge-tts voice that suits your audience. The source-language examples are
zh-TW-HsiaoChenNeural(female),zh-TW-YunJheNeural(male),zh-TW-HsiaoYuNeural(female, younger), and thezh-CN-*family. For an English video, consult the current voice catalog and select an English voice ID. - Narration speed: edge-tts supports
rate="+20%"to speed up speech and-20%to slow it down. A slightly slower pace can make explanatory narration easier to follow. - Subtitle font: The default is Noto Sans CJK. To use another font, place the font file in the path expected by the Skill and update the configuration.
- Transition duration: The xfade filter defaults to 0.5 seconds. Use 0.2 seconds for faster cuts or 1 second for a slower, more cinematic transition.
- Subtitle position: The default is bottom-center. You can move subtitles to the top, lower-left, or center by changing the libass ASS style.
These settings are stored in the installed video Skill under /data/pi-agent/skills/<skill name>/. The configuration is usually in config.yaml or YAML frontmatter within SKILL.md; consult the Skill's README for the version you installed. Open the file with the File Editor add-on, make the change, and save it. Run 3 to 5 videos successfully before customizing anything so that you have a known-good baseline and can identify which change caused a failure.
README.md and example configuration. That is developer-level work rather than part of this introductory guide.Common problems and solutions
-
“AI is writing the script” takes a long time, or the script lacks depth
The selected model is probably not capable enough for the task. A budget model such as GLM-Flash, or another non-reasoning model, may return a shallow list rather than a well-structured script. Switch to a reasoning model such as GLM-4.6, Claude Sonnet, or DeepSeek-R1 (see Chapter 12). Use the model menu in the lower-left corner of the Pi Agent conversation, then ask: “Rewrite this script in English with the same requirements and a clearer structure.”
-
The recording is black, or the entire video has no picture
The Playwright environment was not installed correctly. This is the most common Chapter 18 problem: the first-start download was interrupted, Chromium was not fully extracted, or a shared library is missing. Follow the “Trigger the download again” instructions in Chapter 18. Delete both the Chromium download directory at
/data/pi-agent/playwright-cache/and the sentinel file at/data/pi-agent/.video-tools-installed, then restart the add-on to reinstall them. -
The video has pictures and narration, but no subtitles—or the subtitles appear as boxes or question marks
There are 2 likely causes: (a) ffmpeg did not burn the SRT file into the video—check the Skill configuration for a subtitle or burn-in option, whose exact name depends on the installed version; or (b) the subtitles were added, but the selected font is missing. The add-on includes
fonts-noto-cjk, so a missing-font error usually means that the Skill specifies a non-default font file that does not exist. Solution: change the Skill's font setting back toNoto Sans CJK TC, or runfc-list :lang=zh-twin a ttyd terminal to see which Traditional Chinese fonts the system recognizes. -
The video finished, but it did not appear in Google Drive
rclone may be misconfigured, or the Google account may have exceeded its storage quota. Run the diagnostics in the “Check rclone status” section of Chapter 19. The most common causes are (a) an expired rclone token that requires authorization again, or (b) a full Google Drive account. Follow the exact error message to renew authorization or free storage.
-
The pipeline crashes halfway through, and Home Assistant becomes very slow
The Home Assistant host may be short of CPU or memory. The pipeline needs a dual-core CPU and at least 2 GB of memory for acceptable performance; a Raspberry Pi 3 or very old mini PC may struggle. Solutions: (a) check memory use under Home Assistant System → Hardware; (b) stop other resource-intensive add-ons such as Frigate or Whisper; (c) move to a Pi 5 or x86 mini PC if the host is too limited; or (d) reduce the video to 720p at 24 fps. The source estimates that the last option can halve resource requirements.
-
The narration stutters or contains noise
The connection from edge-tts to Microsoft's service may be unstable. Confirm that the Home Assistant host has a reliable internet connection; use
ping speech.platform.bing.comto check for packet loss. The source useszh-TW-HsiaoChenNeuralas its local example; for this English workflow, choose an English voice from the current edge-tts catalog or wait for the connection to improve before running the English narration again. This is an external-service issue rather than an ffmpeg rendering problem.
Frequently asked questions
Can I use this pipeline to edit a 1-hour video?
Must I use AI narration? I want to use my own voice.
voice/*.wav. Record yourself reading the English script with a phone app, save the result as MP3 or WAV, and replace the files in that directory. Then ask the AI, in English, to “Rerun stages 4–6 using the existing English narration” so that it edits, burns in subtitles, and uploads the video. The result combines your voice, the captured visuals, and AI-generated subtitles. If you want only the English script and prefer to edit the video yourself, stop after stage 1 and use script.md.How do I add properly licensed background music?
-i background.mp3; or (c) add music from the YouTube Audio Library in YouTube's editor after upload. Important: “Copyright-free” music must genuinely be licensed for your intended use. A track that merely sounds similar to another work is not safe; YouTube may mute an infringing video or redirect its revenue. Sources include the YouTube Audio Library, Free Music Archive, and Pixabay Music, but always check the specific license.Can I change the resolution? I want 4K.
scale=3840:2160 to ffmpeg. First decide whether 4K is useful: (1) if Playwright captures a 1080p browser window, scaling it to 4K enlarges the pixels without adding detail; (2) a 3-minute 4K video may be 500 MB–1 GB, making it harder to upload and share; and (3) 1080p is already sufficient on most phones. A more practical option is to capture a 1440p browser viewport with viewport: 2560x1440 while keeping the output at 1080p. This can make interface elements and text clearer without the overhead of a 4K file.Can I use only the narration stage for a podcast?
/data/pi-agent/venv/bin/edge-tts --voice zh-TW-HsiaoChenNeural --text "your script" --write-media out.mp3. This source-language command writes an MP3; for an English podcast, consult the current edge-tts catalog, select an English voice, and provide English script text. Alternatively, run the video Skill once, keep its audio output, and discard the rendered video. A dedicated podcast Skill may appear in the Pi Agent ecosystem in the future; consult the official changelog.Can I upload the video to YouTube and monetize it?
Can friends watch the finished video in a messaging app?
Can the pipeline run without a GPU?
Can I provide subtitles in English and another language?
subtitles.srt and translate a copy with a suitable service. If your original track is in another language, you can ask Pi Agent, “Translate these subtitles into English while preserving every SRT timestamp,” and save the result as subtitles.en.srt. Upload both tracks to YouTube so that viewers can switch languages. Displaying 2 languages simultaneously in the picture requires changes to the pitch_video Skill's subtitle-generation logic and is advanced customization. For a first project, use YouTube's multilingual subtitle-track feature.How can I recover after breaking the Skill configuration?
.bak extension. If your edit breaks the Skill, restore the .bak copy. If you did not make a backup, most Skill repositories include default settings, often in config.yaml, config.default.yaml, or an embedded example in SKILL.md; use the files from the version you installed. As a last resort, delete /data/pi-agent/skills/<skill name>/ and reinstall it using the method in Chapter 15. A Skill is usually only a few MB, so reinstallation is quick, although you will need to reapply your preferences.