2

How can I show letters one at the time using FFMpeg, I'm talking about something like this:

enter image description here

Thank you.

3 Answers 3

0
  1. Use Paint or GIMP to type a letter, save it as img-001.png
  2. do the next letter and img-002.png
  3. ffmpeg -framerate 60 -i img-%03d.png output.mp4
  4. adjust the input frame rate
0
3

Typewriter effect on ffmpeg using an .ass file, I generated this gif using the following line:

ffmpeg -f lavfi -i color=size=640x480:rate=30:color=black -vf "subtitles=typewriter.ass" -t 8 ffmpeg_typewriter.gif

enter image description here

I used the Eagisub program to get the parameters used in karaoke !! I created two styles (style1 and style2) both with different fonts, background etc. The shadow colors, background colors were chosen transparent because they appear however transparent, and the time of {\Kn} defines the character display time or time of the word or phrase, just change the n as long as you want !!! Too simple !! follow the file generated on Eagisub that can be easily edited by hand !! That's it thanks !!

    [Script Info]
; Script generated by Aegisub 3.2.2
; http://www.aegisub.org/
Title: Default Aegisub file
ScriptType: v4.00+

[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: style1,Ubuntu Mono,100,&H00FFFFFF,&HFF0000FF,&HFF000000,&H00000000,0,0,0,0,100,100,0,0,1,0,0,4,10,10,10,1
Style: style2,DejaVu Sans Mono,37,&H00FFFFFF,&HFF0000FF,&HFF000000,&H00000000,0,0,0,0,100,100,0,0,1,0,0,4,10,10,10,1

[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:01.10,0:00:12.00,style1,,0,0,0,,{\pos(109,187.5)}{\k25}H{\k25}e{\k25}l{\k25}l{\k10}o{\k15}!{\k15}\NI{\k15}'{\k15}m{\k15} D{\k15}i{\k15}v{\k15}e{\k15}r{\k15}s{\k15}a{\k15}l{\k15}i{\k15}z{\k15}a{\k15}n{\k15}d{\k15}o{\k15}!{\k15}!
Dialogue: 0,0:00:05.50,0:00:09.40,style2,,0,0,0,,{\k15\pos(108,374)}Editing{\k15} a {\k15}.ass {\k15}with {\k15}Aegisub {\k15}to\N {\k15}generate {\k15}the {\k15}typewriter {\k15}effect.
1
1

After improving for my case what Thiago said.

I arrived to this:

First the ffmpeg code

For mp4:

ffmpeg -f lavfi -i color=c=black:s=640x480:d=8 -vf "subtitles=typewriter.ass" -video_track_timescale 24000 output.mp4

ASS file

Then let's create a minimal ASS: All Tags info are here

[Script Info]
; Comment with ";"
ScriptType: v4.00+

[V4+ Styles]
Format: Name,  Fontname,  Fontsize,  PrimaryColour,  SecondaryColour,  OutlineColour,  BackColour,  Bold,  Italic,  Underline,  StrikeOut,  ScaleX,  ScaleY,  Spacing,  Angle,  BorderStyle,  Outline,  Shadow,  Alignment,  MarginL,  MarginR,  MarginV,  Encoding
Style: style1,  Arial,  30,  &H00FFFFFF, &HFF0000FF, &HFF000000, &H00000000, 0, 0, 0, 0, 100, 100, 0, 0, 1, 0, 0, 7, 20, 20, 20, 1


[Events]
Format: Layer,  Start,  End,  Style,  Name,  MarginL,  MarginR,  MarginV,  Effect,  Text
Dialogue: 0, 0:00:00.5, 0:00:12.00, style1, , 0, 0, 0, , Your text is here

Let's the text only as a typewriter style. I will let you play with the tags for your purpose.

Here is the simpler command I do to create the \k (karaoke) balise for each letter. I use a random sequence between 10 and 25 centisecondes with an increment of 5 cs for each character. You can run in in bash (check WSL for Windows)

echo "Let's try to create a type writer text rapidly" | sed 's/./&\n/g' | while read p; do r=$(seq 10 5 25| shuf | head -1); echo {\\k$r}$p; done | tr -d '\n' | sed 's/}{/} {/g'

which will output e.g.: {\k10}L{\k15}e{\k25}t{\k25}'{\k25}s{\k25} {\k15}t{\k10}r{\k10}y{\k25} {\k15}t{\k15}o{\k15} {\k25}c{\k25}r{\k10}e{\k15}a{\k20}t{\k15}e{\k15} {\k10}a{\k25} {\k10}t{\k10}y{\k20}p{\k20}e{\k10} {\k25}w{\k20}r{\k25}i{\k15}t{\k15}e{\k25}r{\k15} {\k15}t{\k15}e{\k15}x{\k10}t{\k15} {\k25}r{\k20}a{\k10}p{\k15}i{\k25}d{\k15}l{\k25}y{\k20}

You just have to put it in your file :)

Gif to show the result

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.