Starting from @Thorsten's answer in How can I set a time between slides to create an automatic slideshow with beamer?, I was wondering if it's possible to get a slideshow (.mp4 or .gif) mantaining all the transitions effects in my MWE:


This is my first frame

This is my second frame

This is my third frame


PS: If I use ImageMagick to convert pdf in jpg:

convert -density 300 file.pdf page_%04d.jpg

and ffmpeg to get a video:

ffmpeg -framerate 1/3 -pattern_type glob -i '*.jpg' -c:v libx264 -r 300 -pix_fmt yuv420p video.mp4

I am not able to mantain the transition related to \transwipe.

  • 1
    You could use a screen recording application to record your screen while presenting the beamer output. There are many different applications to choose from depending on your operating system; many will be able to output to a MP4 video container. – Eric Marsden Jan 16 at 15:46
  • 1
  • @NathanielM.Beaver Sure, but I could not find any ref to \transwipe – Arianna Angeletti Jan 20 at 16:38

The suggestion in the comment is correct. Make a beamer presentation, and then get a screen filming application to film the result.

In case you want a pure bash solution, you would have to devise a script that uses the watch function to run a script which takes a printscreen 10 times a second, and run this script at whatever framerate you wish to use, divided by 10. Here is an example of such a script:

a=`cat ~/index`
if [ $1 -ne 0 ]
 echo $((a+$1)) > /users/morgan/x/index
xwd -root | convert xwd:- ~/$((a+$2)).png
cat end

One problem you run into is parallelism: making sure all your frames are synchronized. For this I used a file called index to have one central reference for all copies of the script to refer to. The other problem you run into is ending all instances at the same frame. To solve this problem, the script above cats the file end, which tells all the watch commands whether to end watching.

Finally, here is the script that I used that coordinates all of the watch commands; it calls the above script in a filename i.sh:

echo n > end   # don't end watching
echo 0 > index # start at frame 0
a=1            # which instance of `watch` we're starting
b=` bc -l <<< $(echo 1/$1 - .001) `#* amount of time between starting the `watch` instances
while [ $a -lt $1 ]
 ( watch -pgn .1 ./i.sh 0 $a ) &   # the -p tells `watch` to be more precise
 #date +%N                         # line which you use to calibrate timing on your PC
 sleep $b
 ( watch -pgn .1 ./i.sh $1 $a ) &  # last instance increments the `index` by $1
timeout $2 evince -s $3            # run presentation file $3 for $2 seconds
echo y > end                       # this should abort all `watch` instances

The usage is:

./run.sh [fps / 10] [no. of seconds to film] [presentation PDF name] 
  • Note: The .001 is the amount of time on my computer needed to run one iteration of the loop, to make sure all frames are synchronized. In order to time this on your computer, you uncomment the #date line, and then the script would display the nanoseconds at which your script begins. You then would adjust the .001 up or down, to make sure there is as close to the needed gap as practical.

One disadvantage is, that the watch commands don't know how soon the PDF viewer finishes loading and the presentation starts. For this reason, you will have to discard all printscreens that get captured before your PDF reader loads, and also add a few seconds to your presentation length, which you can discard after the capturing is done.

This is a pure bash solution, but I would suggest using the more conventional method of using a third-party utility to do the filming, unless there is a good reason not to (e.g. you don't have root access; your system is too old to support external utilities; you believe in using only open-source software; etc.).

And of course, after deleting the files at the beginning and at the end, you would then use ffmpeg as you wrote above to make the movie file. Unfortunately, no faster-than-realtime solution seems to exist out there.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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