Add Title Clip

Right-click on empty space in the project bin, or click the kdenlive-add-clipgo-downAdd Clip icon on the project bin toolbar, and select Add Title Clip.

project_bin_add_title

Adding a title clip

This opens the built-in Title Editor.

See Klipy titulků for more details.

Here is a script courtesy of Grog (see his post for more details and how to use it in Windows) that turns subtitles into titles that can be further edited in the Title Editor:

 1#!/bin/bash
 2
 3read -p "frame rate:"$'\n' frate
 4[ "$frate" = "" ] && frate=60
 5echo "..."
 6
 7[ -d ./Kden_Titles/ ] && rm -r ./Kden_Titles
 8mkdir -p Kden_Titles
 9
10readarray -t frm < <( (sed -n '2~4p' ./*.srt) )
11readarray -t sub < <( (sed -n '3~4p' ./*.srt) )
12
13n=1
14w=$(bc<<<"length(${#sub[@]}*2)")
15
16for i in "${!frm[@]}"; do
17
18        b=$(date -d "${frm[i]:0:12}" "+%S.%3N")
19        e=$(date -d "${frm[i]:17:12}" "+%S.%3N")
20        ee=$(date -d "${frm[i-1]:17:12}" "+%S.%3N")
21
22        if [ "$i" -eq 0 ]; then ee=0; fi
23        if [ "$(bc<<<"$b<$ee && $i!=0")" -eq 1 ]; then b="$(bc<<<"$b+60")"; fi
24        if [ "$(bc<<<"$e<$b")" -eq 1 ]; then e="$(bc<<<"$e+60")"; fi
25
26        blank="$(bc <<< "($b*$frate+0.5)/1-($ee*$frate+0.5)/1")"
27        duration="$(bc <<< "($e*$frate+0.5)/1-($b*$frate+0.5)/1")"
28
29        if [ "$blank" -gt 0 ]; then
30        sed -e "s/30/$blank/" -e "s/%s//" ./*.kdenlivetitle* > ./Kden_Titles/"$(printf "%0*d" "$w" "$n")"_.kdenlivetitle
31        ((n++))
32        fi
33
34        sed -e "s/30/$duration/" -e "s/%s/${sub[i]}/" ./*.kdenlivetitle* > ./Kden_Titles/"$(printf "%0*d" "$w" "$n")".kdenlivetitle
35        ((n++))
36
37done
38
39sleep 1
40echo "Titles in $PWD/Kden_Titles"$'\n'
41touch ./Kden_Titles/*_*
42
43$SHELL

The highlighted lines point out the %s variable (the same used as the standard placeholder for template titles). You can change that to anything you prefer, like placeholder, for example.

Here is the same script but for Powershell in Windows (save it as .ps1):

# Prompt for frame rate
$frate = Read-Host "frame rate"
if (-not $frate) { $frate = 60 }
Write-Host "..."

# Remove existing Kden_Titles directory if it exists
if (Test-Path -Path "./Kden_Titles/") { Remove-Item -Path "./Kden_Titles/" -Recurse -Force }
New-Item -ItemType Directory -Path "Kden_Titles"

# Read frames and subtitles from SRT files
$frm = Get-Content -Path '*.srt' | Select-Object -Skip 1 | ForEach-Object -Begin {$i=0} -Process {if ($i++ % 4 -eq 0) {$_}}
$sub = Get-Content -Path '*.srt' | Select-Object -Skip 2 | ForEach-Object -Begin {$i=0} -Process {if ($i++ % 4 -eq 0) {$_}}
# output File name width / counter
$w = [math]::Ceiling($sub.Count * 2)
$w = "$w".length
$n = 1
# Template file placeholders
[regex] $p_1='30'
[regex] $p_2='%s'

for ($i = 0; $i -lt $frm.Count; $i++) {
    # Timing
   $b = [datetime]::ParseExact($frm[$i].Substring(0, 12), "hh:mm:ss,fff", $null).ToString("ss.fff")
   $e = [datetime]::ParseExact($frm[$i].Substring(17, 12), "hh:mm:ss,fff", $null).ToString("ss.fff")
   $ee = if ($i -gt 0) { [datetime]::ParseExact($frm[$i - 1].Substring(17, 12), "hh:mm:ss,fff", $null).ToString("ss.fff") } else { 0 }
   # Add 60s if necessary
   if ($i -eq 0) { $ee = 0 }
   if ($b -lt $ee -and $i -ne 0) { $b = [math]::Round([double]$b + 60, 3) }
   if ($e -lt $b) { $e = [math]::Round([double]$e + 60, 3) }
   # Clip length / padding
   $blank = [math]::Round([decimal]$b * $frate + 0.1) - [math]::Round([decimal]$ee * $frate + 0.1)
   $duration = [math]::Round([decimal]$e * $frate + 0.1) - [math]::Round([decimal]$b * $frate + 0.1)
   # Replace placeholders
   if ($blank -gt 0) {
      Get-Content -Path ./*.kdenlivetitle* |
           ForEach-Object { $p_1.replace("$_", "$blank", 1) } |
           ForEach-Object { $p_2.replace("$_", '',1) } |
      Set-Content -Path "./Kden_Titles/$($n.ToString("D$w"))_.kdenlivetitle"
      $n++
   }
   Get-Content -Path ./*.kdenlivetitle* |
   ForEach-Object { $p_1.replace("$_", "$duration", 1) } |
   ForEach-Object { $p_2.replace("$_", $sub[$i],1) } |
   Set-Content -Path "./Kden_Titles/$($n.ToString("D$w")).kdenlivetitle"
   $n++
}

Start-Sleep -Seconds 1
Write-Host "`nTitles in $PWD\Kden_Titles`n"
# Set date modified for blank clips
(Get-ChildItem -Path ./Kden_Titles/*_*) | % {$_.LastWriteTime = (Get-Date)}