Manipulating Image & Video files

In this page

  1. Convert video format to xvid
  2. Image conversions and corrections

1. Convert video format to xvid

Convert video format to xvid
    $ sudo apt-get install mencoder		# Install mencoder
$ mencoder <inputfile> -ovc xvid -xvidencopts pass=1 -oac mp3lame \ -lameopts vbr=3 -o /dev/null # First pass redirected to /dev/null (no output)
$ mencoder <inputfile> -ovc xvid -xvidencopts pass=2:bitrate=1000 -oac mp3lame \ -lameopts vbr=3 -o <outputfile> # Second pass redirected to a new file
$ ffmpeg -i <filename> # Find the bit rate of the original movie
* Note: Sometimes it may be necessary to change the sound rate with the option "-srate 8000" (or other rate). * Useful aliases: $ alias p1='mencoder -ovc xvid -xvidencopts pass=1 -oac mp3lame -lameopts vbr=3' $ alias p2h='mencoder -ovc xvid -xvidencopts pass=2:bitrate=8500 -oac mp3lame -lameopts vbr=3' * And their usages: $ p1 <originalfile> -o /dev/null $ p2h <originalfile> -o <finalfile>


4. Image conversions and corrections

The following is a series of useful tools to manipulate images, convert formats and stuff.

5.1 Recalculate EPS bounding box

eps bounding box
    $ epstool --copy -b f1.eps f2.eps

5.2 Convert emf to svg. The first option is to convert a single file. The second option (4 lines) converts all files in current and subfolders.

emf to svg
    $ unoconv -f svg file.emf

    $ unoconv --listener &                                # Turns on listener
    $ find . -name '*.emf' -exec unoconv -f svg "{}" \;   # Converts files
    $ fg                                                  # Brings listener to fg
    $ ^C                                                  # Kills listener

5.3 Resize all files in a folder.

Resize all files in a folder (two options)
$ mogrify -resize 40% -format png *
    
$ for file in *.png; do convert $file -resize 40% smaller-$file; done