Wednesday, October 19, 2016

Uploading a technical report to arXiv

Recently, I had to upload a technical report to arXiv. Their system requires that the LaTeX source has to be included. Actually, for computer vision and graphics paper where lots of images are included in the paper, uploading the LaTeX source is not straightforward. 

The scenario I encounter is that I have a complex LaTeX file with a bunch of figures. Each figure is made by a few minipages that include tens of images. As the arXiv system does not allow multiple files upload at a time, and due to the complicated file organization in my figure folder, it does not make sense to upload all the figure images. 

My solution is to split all the figures and tables into a single pdf file, and then modify the existing LaTeX file to include figures from the pdf instead. The steps are as follows. 

1. Include
\usepackage[active,tightpage,floats]{preview}
to the original LaTeX and compile. All floats (including captions) will be saved into a single pdf. Let's say we name it figures.pdf. 

2. Fork the original LaTeX to a new file, e.g., name arxiv.tex. In this file, all figures that has minipages and includegraphics are replaced with the code like this:

\begin{figure}
    \centering
    \includegraphics[page=X]{figures.pdf}
    \caption{}
    \label{fig:abc}
\end{figure}
where X is the page number to include. 

Note that to maintain correct cross-reference, figure caption and label has to be declared. Since the caption is already included in figures.pdf, we simply put an empty caption here. Remember to include
\usepackage{caption}
\captionsetup[figure]{labelformat=empty}
at the beginning to disable the caption numbering. This assumes that all figures are managed this way so disabling the caption numbering does not affect other figures. 

If compression is needed, one can compress the figures.pdf accordingly. 

3. Finally, simply upload arxiv.tex, arxiv.bbl, and figures.pdf, and other necessary class and style files if necessary. Note that arXiv does not compile BibTex (.bib) file automatically. One has to compile it and only upload the .bbl file. Uploading .bib file does not work. 

P.S. Do not treat your original paper as a figure and create arxiv.tex that looks like this:
\documentclass[a4paper]{article}
\usepackage{hyperref}
\hypersetup{
  pdfinfo={
    Title={},
    Author={},
    Subject={},
    Keywords={}
  }
}
\usepackage{pdfpages}

\begin{document}
\includepdf[pages=1-last]{original.pdf}
\end{document}

This can bypass the submission system, but the arXiv admin will hold your submission until you contact them. :) 

Thursday, April 21, 2016

Insect 3D models

I just came across some great free 3D models of insects on the web. In Wavefront OBJ format. Download them at http://zerokobo.web.fc2.com

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.