In the following examples we will see how you can use subtitles in your videos with JSON2Video API.
Classic styles
The classic
style and its variant classic-progressive
,
are simple subtitles.
You can customize the substitles with an outline around the text and a shadow.
You can also define different colors for the current spoken word and the rest of the text,
making it simple to highlight the word that is being spoken.
Your browser does not support the video tag.
{
"type": "subtitles",
"settings": {
"style": "classic",
"outline-color": "#000000",
"outline-width": 5
}
}
$scene->addElement([
'type' => 'subtitles',
'settings' => [
'style' => 'classic',
'outline-color' => '#000000',
'outline-width' => 5
]
]);
scene.addElement({
"type": "subtitles",
"settings": {
"style": "classic",
"outline-color": "#000000",
"outline-width": 5
}
});
Your browser does not support the video tag.
{
"type": "subtitles",
"settings": {
"style": "classic",
"box-color": "#000000",
"outline-width": 10,
"word-color": "#B185A7",
"shadow-offset": 0,
"shadow-color": "#000000",
"max-words-per-line": 4,
"font-size": 280,
"font-family": "Luckiest Guy",
"position": "center-center",
"outline-color": "#000000",
"line-color": "#FFF4E9"
}
}
$scene->addElement([
'type' => 'subtitles',
'settings' => [
'style' => 'classic',
'box-color' => '#000000',
'outline-width' => 10,
'word-color' => '#B185A7',
'shadow-offset' => 0,
'shadow-color' => '#000000',
'max-words-per-line' => 4,
'font-size' => 280,
'font-family' => 'Luckiest Guy',
'position' => 'center-center',
'outline-color' => '#000000',
'line-color' => '#FFF4E9'
]
]);
scene.addElement({
"type": "subtitles",
"settings": {
"style": "classic",
"box-color": "#000000",
"outline-width": 10,
"word-color": "#B185A7",
"shadow-offset": 0,
"shadow-color": "#000000",
"max-words-per-line": 4,
"font-size": 280,
"font-family": "Luckiest Guy",
"position": "center-center",
"outline-color": "#000000",
"line-color": "#FFF4E9"
}
});
The following uses classic-progressive
, that shows the words as they are being spoken and hides those that are not.
Your browser does not support the video tag.
{
"type": "subtitles",
"settings": {
"style": "classic-progressive",
"outline-color": "#000000",
"font-family": "Libre Baskerville",
"position": "bottom-left",
"font-size": 200,
"line-color": "#faedcd",
"word-color": "#faedcd",
"shadow-color": "#d4a373",
"shadow-offset": 5,
"max-words-per-line": 3,
"outline-width": 3
}
}
$scene->addElement([
'type' => 'subtitles',
'settings' => [
'style' => 'classic-progressive',
'outline-color' => '#000000',
'font-family' => 'Libre Baskerville',
'position' => 'bottom-left',
'font-size' => 200,
'line-color' => '#faedcd',
'word-color' => '#faedcd',
'shadow-color' => '#d4a373',
'shadow-offset' => 5,
'max-words-per-line' => 3,
'outline-width' => 3
]
]);
scene.addElement({
"type": "subtitles",
"settings": {
"style": "classic-progressive",
"outline-color": "#000000",
"font-family": "Libre Baskerville",
"position": "bottom-left",
"font-size": 200,
"line-color": "#faedcd",
"word-color": "#faedcd",
"shadow-color": "#d4a373",
"shadow-offset": 5,
"max-words-per-line": 3,
"outline-width": 3
}
});
The following example uses the classic
style with max-words-per-line
set to 1.
This creates the effect that only the word that is being spoken is shown.
Your browser does not support the video tag.
{
"type": "subtitles",
"settings": {
"style": "classic",
"outline-color": "#000000",
"font-family": "Roboto",
"position": "bottom-center",
"font-size": 400,
"line-color": "#faedcd",
"word-color": "#faedcd",
"shadow-offset": 10,
"max-words-per-line": 1,
"outline-width": 5
}
}
$scene->addElement([
'type' => 'subtitles',
'settings' => [
'style' => 'classic',
'outline-color' => '#000000',
'font-family' => 'Roboto',
'position' => 'bottom-center',
'font-size' => 400,
'line-color' => '#faedcd',
'word-color' => '#faedcd',
'shadow-offset' => 10,
'max-words-per-line' => 1,
'outline-width' => 5
]
]);
scene.addElement({
"type": "subtitles",
"settings": {
"style": "classic",
"outline-color": "#000000",
"font-family": "Roboto",
"position": "bottom-center",
"font-size": 400,
"line-color": "#faedcd",
"word-color": "#faedcd",
"shadow-offset": 10,
"max-words-per-line": 1,
"outline-width": 5
}
});
Boxed styles
There are 2 types of boxed styles: boxed-line
and boxed-word
.
The boxed-line
style adds a box around the whole text.
You can specify the color of the box with the box-color
property, that defaults to black.
Your browser does not support the video tag.
{
"type": "subtitles",
"settings": {
"style": "boxed-line",
"font-family": "Roboto",
"position": "bottom-center",
"font-size": 200,
"line-color": "#faedcd",
"word-color": "#00FF00",
"max-words-per-line": 3
}
}
$scene->addElement([
'type' => 'subtitles',
'settings' => [
'style' => 'boxed-line',
'font-family' => 'Roboto',
'position' => 'bottom-center',
'font-size' => 200,
'line-color' => '#faedcd',
'word-color' => '#00FF00',
'max-words-per-line' => 3
]
]);
scene.addElement({
"type": "subtitles",
"settings": {
"style": "boxed-line",
"font-family": "Roboto",
"position": "bottom-center",
"font-size": 200,
"line-color": "#faedcd",
"word-color": "#00FF00",
"max-words-per-line": 3
}
});
The boxed-word
style adds a box around the spoken word.
Again, box-color
defines the color of the box.
Your browser does not support the video tag.
{
"type": "subtitles",
"settings": {
"style": "boxed-word",
"font-family": "Luckiest Guy",
"position": "bottom-center",
"font-size": 200,
"line-color": "#00FF00",
"word-color": "#FFFF00",
"max-words-per-line": 3,
"outline-color": "#000000",
"outline-width": 8
}
}
$scene->addElement([
'type' => 'subtitles',
'settings' => [
'style' => 'boxed-word',
'font-family' => 'Luckiest Guy',
'position' => 'bottom-center',
'font-size' => 200,
'line-color' => '#00FF00',
'word-color' => '#FFFF00',
'max-words-per-line' => 3,
'outline-color' => '#000000',
'outline-width' => 8
]
]);
scene.addElement({
"type": "subtitles",
"settings": {
"style": "boxed-word",
"font-family": "Luckiest Guy",
"position": "bottom-center",
"font-size": 200,
"line-color": "#00FF00",
"word-color": "#FFFF00",
"max-words-per-line": 3,
"outline-color": "#000000",
"outline-width": 8
}
});