Thursday, March 24, 2016

How to add narration for a PowerPoint video

It has been increasingly popular to have a video as supplementary material for paper submission. The video, usually less than 5 minutes, explains the key ideas of the paper in an intuitive way.
In addition, the video is narrated for viewers to catch the ideas quickly.

In this post, I'm describing how I made such a video using free and open-source tools. The only exception is Microsoft PowerPoint, which I used to make the presentation slides which are then exported to the video.

The workflow is as follows:
1. Make the slides.
2. Record the timing and narration for the slides. Suppose that both the slides and the narration are done by you in PowerPoint, then this is simple. Just go to SlideShow tab -> Record Slide Show.

The situation becomes more complex if you are not a native speaker and need someone else to help with the narration. It means, we need to merge an audio file to our existing video.

The workflow becomes:
1. Make the slides.
2. Wait for someone to make the narration audio. Take the audio file (e.g., mp3 format).
3. Segment the narration audio into parts.
4. Record the timing of the slides based on the length of each narration part. Export the slides to video.
5. Merge the audio parts to the video.

I did the steps above using Audacity and Blender.

In step 3, it is best to cut the audio into parts, one for each slide. This can be done easily in Audacity. Open the audio in Audacity, select the narration for each slide, press Ctrl + B to label it (i.e., name it by slide 1, slide 2, etc.). Finally, go to File -> Export Multiple, tick Split files based on Label, and proceed.

Now it's time to go back to PowerPoint and adjust the timing for each slide to make it fit to the length of each narration part (step 4). I added all narration files to VideoLAN playlist to display the time of each narration, and then record the timing in PowerPoint accordingly.
Note that it is alright the timing of a slide could be 0.5 or 1 second longer than its audio narration counterpart. We can trim it later. When this is done, export the video to mp4 format.

The final step is to merge each narration part to the video. To perform this task, I used Video Sequence editor in Blender. While Blender is more well known as an open-source 3D modeling and rendering package, it comes with a surprisingly good video editor.
In Blender, import the video and all audio parts to the Video Sequence editor and start positioning the audio to the video. Finally, 'render' the video and it's done.

More tips for video editing in Blender:

  • The video/audio can be split by positioning the current frame by left click and press 'K'. The selected video/audio will be cut into two parts at the current frame. 
  • Click on the starting and ending arrow of each track and right click and drag to shorten the clip.
  • To remove all gaps, place the cursor to frame 0, and press Shift + Backspace.   
  • Remember to delete the existing sound track in the original video mp4.
  • Export the video by enable Post processing in Rendering tab, set the output path, and hit Animation. 
Hack for the narration:
If you cannot find any native speakers to help with the narration, an alternative is to use text-to-speech engine to make the audio. At the time of this writing (Mar 2016), ispeech.org gives the most realistic sound quality. Unfortunately, it does not allow export to mp3 for free. But fortunately, there is a workaround. Here's how.

  • Install SpeakIt! extension on Google Chrome first. This extension uses iSpeech service to make speech from text. 
  • Play the narration using SpeakIt!. Then use Audacity's Windows WASAPI + loopback device to record the output sound. 


Thursday, March 17, 2016

Compress PDF output by LaTeX

I came across the problem of optimizing an PDF file output by LaTeX from 60 MB to less than 30 MB to fit the requirement of a submission system. The simplest way is perhaps to use GhostScript to compress the pdf. For example

gswin64c -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -dPDFSETTINGS=/default -sOutputFile=abc_compress.pdf abc.pdf

where abc.pdf is the input file.

There are five settings that one can fiddle to control the trade off between compression ratio and document quality. For images, the more compression we applied, the more downsampling and detail lost one might experience in the output pdf. Here are the settings that can be replaced with /default in the command line above:
  • /ebook 
  • /screen
  • /prepress 
  • /default : largest file size but some compression could still discards image details
  • /printer 
If you are not satisfied with the default image quality produced by GhostScript, it is possible to control to specify the image encoding we need, for example:

gswin64c -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -dAutoFilterColorImages=false -dEncodeColorImages=true -dColorImageFilter=/DCTEncode -dColorConversionStrategy=/LeaveColorUnchanged -sOutputFile=abc_compress.pdf abc.pdf 

where
-dAutoFilterColorImages=false turns off default setting for image compression,
-dColorImageFilter=/DCTEncode specify the compression type to be JPEG compression.

If you don't want any compression, replace /DCTEncode by /FlateEncode.
More documentation about the parameters could be found here.

If you don't like working with command lines, give Adobe Acrobat a try in case you haven't installed any. It's free for trial in 30 days.

Any comments are welcome.

Reference:
1. http://www.volkerschatz.com/tex/hiqpdf.html
2. Adobe Distiller parameters documentation. Some are applicable to GhostScript.