I need a script called myslide which does the following:

myslide -f 15 -t 20 "Hello World"

produces a movie file (to be played by mplayer), which just displays "Hello World" in the center of the screen in font size 15 for 20 seconds.

Is there an easy way to do this?

1 Answer 1


There are two possibilities presented here, using.

EDIT: Both scripts have now been condensed and modified to play only a single frame for the duration of however many seconds are specified. mplayer can handle very low FPS (eg. 0.008547009 and 0.003154574 FPS worked fine, ie. 117 and 317 seconds playing time).

NOTE: On the Ubuntu 10.04 machine. mplayer does not play the first frame, so I've needed to include 2 frames to achieve the specified time. So, be aware that another player may play both frames and thereby double the playing time.

AviSynth is a versatile/poweful frame-server. There is no GUI. It is a scripting language for non-linear audio-video editing/creating/filtering.
Being a frame server, it does not need to create a video on disk. It can serve the video/audio directly, frame-by-frame, to any AviSynth aware tool, be it a media player or encoder...

AviSynth is Free and Open Source Software written for Windows (have I lost you? :) ... Attempts were made, but it was not successfully ported to *nix (I believe the developers tried but it got bogged down as its original design was heavily hooked into Windows stuff. It does, however, work well under wine. The wine version of mplayer and Avidemux can process .avs scripts (there are others; eg VirtualDub, and AvsPmod which is a mini-"IDE" GUI for Avisynth).

Here is an AviSynth script to do what you want.

myslide  15 20 "Hello from AviSynth"

fontSize=$1; sec=$2; text="$3"
>>test.avs printf 'Blankclip( 2 ,width=640 ,height=480 ,fps=1/float(%s), color=$000000)\n' "$sec"
>>test.avs printf ' \ .Subtitle("%s", font="Arial", size=%s, text_color=$ff0000, align=5)\n' "$text" "$fontSize" 
wine avs2yuv.exe  test.avs -  2>/dev/null |
ffmpeg -b 100 -i - "test.mp4" 2>/dev/null

mplayer test.mp4

avs2yuv is a command-line program, intended for use under Wine, to interface between Avisynth and Linux-based video tools.
avs2yuv only reads a video stream, but AviSynth can frame-serve audio and video to Avidemux via AvsProxy (which ships with Avidemux)...


Here is another way, using convert from package imagemagick. This method creates a series of .jpg images.

myslide  15 20 "Hello from convert"

fontSize=$1; sec=$2; text="$3"
FPS=$(awk 'END{print 1/'$2'}' /dev/null)
convert -background lightblue -fill blue -pointsize $fontSize -gravity center -size 640x480 caption:"$text" "test$$0.jpg"
cp test$$0.jpg "test$$1.jpg" # Add 1 extra; mplayer doesn't play ist frame (on test system)
ffmpeg -y -r $FPS -b 100 -i test$$%d.jpg test.mp4
rm  test$$*.jpg # remove temp images

mplayer test.mp4
  • The resulting .mp4 from the above example is 8.4 KiB, regardless of the playing time... The make/encoding time is very fast for the convert method at 0m0.111s. The AviSynth takes 0m1.237s, which is probably because of the need to initialize wine and the extra step of needing avs2yuv to bridge the windows/*nix divide.
    – Peter.O
    Commented Feb 7, 2012 at 8:03
  • Re. AviSynth's Subtitle filter: I haven't used it for quite a while and forgot it only handles a single line. I've been mainly using another filter which reads the more elaborate Advanced Sub-Station Alpha subtitles .ass (and many more).. .ass may be the, most customizable subtitle format available.. The filter is called TextSub and is part of VSFilter (TextSub & VobSub). To make multi-line captions, I use a script, but Aegisub is a great .ass subtitle editor; good documentation..
    – Peter.O
    Commented Feb 7, 2012 at 11:30
  • @Alexar: Peter’s script looks fine to me.  If you are aware of a problem with it, please describe it in a comment and give Peter a chance to fix it.  I voted to reject your suggested edit because it looks like vandalism (to me). Commented May 4, 2020 at 2:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .