В началоUnix Toolbox → 16. CONVERT MEDIA
Gentoo-doc HOME Пред.: 15. INSTALL SOFTWAREВ началоУровень выше: Unix ToolboxСлед.: 17. PRINTING

16. 16. CONVERT MEDIA

Sometimes one simply need to convert a video, audio file or document to another format.

16.1. 16.1 Text encoding

Text encoding can get totally wrong, specially when the language requires special characters like адз. The command iconv can convert from one encoding to an other.

# iconv -f <from_encoding> -t <to_encoding> <input_file>

# iconv -f ISO8859-1 -t UTF-8 -o file.input > file_utf8

# iconv -l # List known coded character sets

Without the -f option, iconv will use the local char-set, which is usually fine if the document displays well.

16.2. 16.2 Unix - DOS newlines

Convert DOS (CR/LF) to Unix (LF) newlines within a Unix shell. See also dos2unix and unix2dos

if you have them.

# sed 's/.$//' dosfile.txt > unixfile.txt

Convert Unix to DOS newlines within a Windows environment. Use sed from mingw or cygwin.

# sed -n p unixfile.txt > dosfile.txt

16.3. 16.3 PDF to Jpeg and concatenate PDF files

Convert a PDF document with gs (GhostScript) to jpeg (or png) images for each page. Also

much shorter with convert (from ImageMagick or GraphicsMagick).

# gs -dBATCH -dNOPAUSE -sDEVICE=jpeg -r150 -dTextAlphaBits=4 -dGraphicsAlphaBits=4 \

-dMaxStripSize=8192 -sOutputFile=unixtoolbox_%d.jpg unixtoolbox.pdf

# convert unixtoolbox.pdf unixtoolbox-%03d.png

# convert *.jpeg images.pdf # Create a simple PDF with all pictures

Ghostscript can also concatenate multiple pdf files into a single one.

# gs -q -sPAPERSIZE=a4 -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=all.pdf \

file1.pdf file2.pdf ... # On Windows use '#' instead of '='

16.4. 16.4 Convert video

Compress the Canon digicam video with an mpeg4 codec and repair the crappy sound.

# mencoder -o videoout.avi -oac mp3lame -ovc lavc -srate 11025 \

-channels 1 -af-adv force=1 -lameopts preset=medium -lavcopts \

vcodec=msmpeg4v2:vbitrate=600 -mc 0 vidoein.AVI

16.5. 16.5 Copy an audio cd

The program cdparanoia13 can save the audio tracks (FreeBSD port in  audio/cdparanoia/),

oggenc can encode in Ogg Vorbis format, lame converts to mp3.

# cdparanoia -B # Copy the tracks to wav files in current dir

# lame -b 256 in.wav out.mp3 # Encode in mp3 256 kb/s

# for i in *.wav; do lame -b 256 $i `basename $i .wav`.mp3; done

# oggenc in.wav -b 256 out.ogg # Encode in Ogg Vorbis 256 kb/s

13.http://xiph.org/paranoia/

Пред.: 15. INSTALL SOFTWAREВ началоУровень выше: Unix ToolboxСлед.: 17. PRINTING
В началоUnix Toolbox → 16. CONVERT MEDIA