I spent a little time trying to work out how to repurpose pdf slide decks that I had released to Slideshare into videos for release on Instagram.
And now, with a few simple moves, and the use of
ffmpeg I can do just that.
As part of my content repurposing workflow I:
- create a transcript of my YouTube Videos
- edit the Slide Deck into a presentation
- upload a PDF of the presentation to Slideshare
- embed the YouTube video into the Slideshare presentation
I wanted to take the PDF and turn it automatically into an Instagram video because I thought that might be faster than editing down the YouTube video.
First I need a set of images
I converted my PDF into a set of PNG files using:
This gives me a
.zip file with all the slides as
Option One - Instagram Gallery Post
I could use the Instagram Gallery post functionality to upload 10 of these images at a time. But if my Slide Deck has more slides than that, then I would need to create two or three posts.
But this might be anoption if you have a small deck - just upload all the images as a gallery.
Option Two - Use FFmpeg to create a video
I have used FFmpeg before to create a ‘soundwave video’ to include in some of my video podcasts.
I know it can generate videos from images.
Time to investigate.
I found the following blog posts and online references useful:
FFmpeg is an open-source tool for manipulating and creating video from the command line.
After reading all of the above information I managed to do the following:
- create a 1 minute video of size 1080x1080
- from 20
.png files of resolution 2134x1600
I could have used ImageMagick to resize all the images first and make it easy, but I wanted to try and do it all in FFmpeg as that would ease my workflow later.
Using the following command - all on one line - did the trick.
ffmpeg -framerate 1/3 -f image2 -s 1080x1080 -i slides-%02d.png
-r 30 -vcodec libx264 -crf 25 -pix_fmt yuv420p
test.mp4 -start_number 1
- ”-framerate 1⁄3” - output 1 frame every 3 seconds (for 20 slides that equals a 60 second video)
- ”-f image2” - work with images (docs suggest this is optional)
- ”-s 1080x1080” - output size of video to be 1080x1080 for Instagram
- ”-i slides-%02d.png” - input files are images named “slides-01.png”, “slides-02.png”, “slides-03.png”, etc.
- ”-vf” the video filters that do the scaling and padding - I’ll cover this later
- ”-r 30” - output at 30 frames per second.
- ”-vcodec libx264 -crf 25 -pix_fmt yuv420p” - magic video processing stuff that I copy and pasted from one of the pages
- “test.mp4” the output filename
I found that I did not actually need:
The video filter uses two filters:
- scale - to resize the image from 2134x1600 to width of 1080 and a height which is relative to the width change and keep the aspect ration the same
- pad - pad out the image so that it is 1080x180 and fill in any border with ‘white’ and position the image in the video at x=0 and y= (output height - input height )/2 which is in the middle. So a top and bottom white border, but the image is the same width as the video so x=0.
So my final command is:
ffmpeg -framerate 1/3 -f image2 -s 1080x1080
-vcodec libx264 -crf 25 -pix_fmt yuv420p
remember that it is all on one line
I then copy this to my mobile and upload it to Instagram.
It is possible to add an audio track so I could add music or a voice over.
I will certainly be using this approach again. And you can see how it turned out:
I repeated this for another set of slides and used them on Facebook and Twitter, where they also look quite good.
It also works well as a Facebook Video Post. Since, Facebook - like Instagram, autoplays video in muted mode, these type of videos can fit will on these platforms. Although I suspect a 10 second slide transition is too long and it really needs to be more like 3-5 seconds.
It can also work on Twitter as well. But you have to wait a few minutes for the Twitter servers to render it effectively before passing judgement on the quality.