Introduction to YTML
YTML (YouTube Markup Language) is a custom markup language designed to simplify video creation by defining animations, voiceovers, timing, and transitions. It extends HTML capabilities with additional semantic tags to manage video production workflows, supporting seamless integration with audio and visual assets.
Key Principlesβ
- β HTML Compatibility: YTML is a superset of HTML, allowing seamless use of HTML elements and CSS animations.
- β Custom Tags: Provides video-specific tags for music, voiceovers, transitions, and reusable components.
- β Flexibility: Enables dynamic timing, reusable components, and conditional logic for scripting.
π Installationβ
YTML requires Python 3.8+ and can be installed via pip:
pip install ytml-toolkit
β οΈ Note: In some cases, you may need to install Playwright for headless browser support.
Run the following command if you encounter issues:playwright install
β¨ Example YTML Scriptβ
Below is a basic example of a YTML script:
<config>
FRAME_RATE=30 VIDEO_WIDTH=1920 VIDEO_HEIGHT=1088 ENABLE_AI_VOICE=True
</config>
<composite id="intro">
<frame duration="3s">
<div>Welcome to my channel!</div>
</frame>
<voice start="0.5s" end="4s">Hello and welcome to my channel.</voice>
<music src="background.mp3" loop="true" start="0s" end="10s" />
</composite>
The above script will:
- Display the text "Welcome to my channel!" for 3 seconds.
- Play a voiceover saying "Hello and welcome to my channel."
- Add background music starting at 0 seconds and looping.
π¬ Sample Output Videoβ
Hereβs an example of a video generated using YTML:
π οΈ YTML CLI Commandsβ
YTML provides a CLI tool to convert .ytml scripts into video files.
Basic Usageβ
ytml -i input.ytml -o output.mp4
This command:
- Takes
input.ytmlas input. - Generates
output.mp4as the final video.
CLI Optionsβ
| Option | Description |
|---|---|
-i, --input | Path to the YTML input file |
-o, --output | Output video file (default: output_video.mp4) |
--use-gtts | Uses gTTS VocalForge instead of Eleven Labs for voice generation |
--skip | Skips specific steps (parse, voiceover, render, sync, compose) |
--resume | Resume a job using the provided UUID |
--job | Job ID of voiceovers to mix (Requires --skip voiceover) |
--preview | Preview HTML output only |
--version | Show CLI version |
--verbose | Enable detailed logging |
Example Usagesβ
-
Skip rendering & voiceover steps:
ytml -i script.ytml -o output.mp4 --skip render voiceover -
Resume a previously stopped job:
ytml --resume 123e4567-e89b-12d3-a456-426614174000 -
Preview the HTML structure instead of rendering a video:
ytml -i script.ytml --preview -
Enable verbose logging:
ytml -i script.ytml -o output.mp4 --verbose
βοΈ YTML Configurationβ
YTML allows custom configurations through the <config> section.
Example Config Blockβ
<config>
FRAME_RATE=30 VIDEO_WIDTH=1920 VIDEO_HEIGHT=1088 ENABLE_AI_VOICE=True
DEFAULT_TRANSITION_EFFECT="fade" AI_IMAGE_STYLE="3D" LOG_LEVEL="DEBUG"
</config>
π Asset Management in YTMLβ
YTML automatically includes predefined CSS, JavaScript, and animation files at the start of every script. These assets help maintain styling, enable animations, and integrate interactive components.
Default Assetsβ
YTML appends the following assets to every script:
CSS Filesβ
{
"css": ["css/merge_conflict_styles.css"]
}
JavaScript Filesβ
{
"js": ["js/mermaid_init.js", "js/prism.js"]
}
Animation Filesβ
{
"animations": ["js/typewriter_effect.js"]
}
Handling Additional Assetsβ
- All referenced files in a YTML script (CSS, JS, images, sounds, fonts) must be placed inside the
assets/directory. - When using custom styles or animations, update the
<config>section:<config>
HTML_ASSETS = { "css": ["css/custom_styles.css"], "js":
["js/custom_script.js"], "animations": ["js/new_animation.js"] }
</config>
π Setting Up AI Voice Generationβ
YTML supports AI-generated voiceovers via Eleven Labs API. To enable it:
- Set up your API key:
export ELEVEN_LABS_API_KEY="your-api-key-here" - Ensure AI voice is enabled in the YTML script:
<config> ENABLE_AI_VOICE=True AI_VOICE_ID="yDUXXKsu0jF5vdJnWAPU" </config>
If no API key is set, YTML will fall back to Google Text-to-Speech (gTTS).
βοΈ YTML Configurationβ
YTML allows custom configurations through the <config> section. Hereβs an overview:
Example Config Blockβ
<config>
FRAME_RATE=30 VIDEO_WIDTH=1920 VIDEO_HEIGHT=1088 ENABLE_AI_VOICE=True
DEFAULT_TRANSITION_EFFECT="fade" AI_IMAGE_STYLE="3D" LOG_LEVEL="DEBUG"
</config>
Configuration Optionsβ
| Setting | Description | Default |
|---|---|---|
FRAME_RATE | Video frame rate | 30 |
VIDEO_WIDTH | Output video width | 1920 |
VIDEO_HEIGHT | Output video height | 1088 |
ENABLE_AI_VOICE | Enables AI-generated voiceovers | True |
DEFAULT_TRANSITION_EFFECT | Default video transition | "fade" |
AI_IMAGE_STYLE | Style for AI-generated images | "3D" |
LOG_LEVEL | Logging level (DEBUG, INFO, etc.) | "INFO" |
π οΈ Config File Loadingβ
YTML can read configurations from a file and override default values.
Example: Reading Configurationsβ
from ytml_config import get_config_from_file
config = get_config_from_file("script.ytml")
print(config.FRAME_RATE) # Prints the frame rate from the script
YTML extracts <config> sections and applies them dynamically.
π― Summaryβ
β
YTML simplifies video creation with a markup-based approach
β
Installation via pip install ytml-toolkit
β
Use ytml -i input.ytml -o output.mp4 to generate videos
β
Supports AI voices via ELEVEN_LABS_API_KEY
β
Configuration available via <config> section
