#!/usr/bin/perl # NOTE: I have turned warnings OFF because of a stupid warning I can't be # bothered fixing yet - but they should be turned on while debugging! use strict; use A2B::CLI; my $a2b = A2B->new; my $cli = A2B::CLI->new($a2b); my @argv = $cli->argv(@ARGV); $cli->run(@argv); __END__ =head1 NAME a2b - invokes conversion tools in sequence - http://sam.nipl.net/a2b/+a2b.tgz =head1 SYNOPSIS a2b [options] [in-file out-file] --help -? Print a brief help message and exit. --list= -l List (a max. of n) possible paths. --options= -O Show options. --args= -A Show all args. --path= -p Choose a particular numbered path. --grep: -g Filters paths matching patterns (all). --nogrep: -G Filters paths not matching patterns (all). --dir= -d The working directory. --tempdir= -D The working directory, will be deleted when done. --type -m Show the mimetypes of listed file/s. --extension -x Show extension type instead of mimetype. --names -n Show filenames also. --content -c Identify input files by content only. --nocontent -C Identify input files by extension only. --in: -i: One or more input files. --out= -o The ouput file. --from= -f The source mimetype or extension. --to: -t: Acceptable destination mimetypes or extensions. --quiet -q Don't show output from the tools. --silent -Q Don't show how the conversion is done at all. --force -y Overwrite the output file without asking. =head1 OPTIONS =over 8 =item B<--help -?> Print a brief help message and exit. =item B<--list -l> [n] List (a maximum of n) possible paths that can acheive the conversion, in order of suitability. =item B<--options -O> [n] List paths like --list, and also show options that can be set as environment variables and their default values. =item B<--args -A> [n] List paths like --list, and also show the complete command lines with arguments. =item B<--path -p> [n] Choose a specific numbered path for the conversion (the default is the first / best). =item B<--dir -d> dir The working directory. If you use --dir to set the working directory, it will not be deleted after the conversion. If you omit --dir and --tempdir, a2b will use a temporary directory, and delete it after the conversion is done. =item B<--tempdir -d> dir The working directory. If you use --tempdir, the directory will be deleted after the conversion. You can not use --tempdir with an existing directory. =item B<--type -m> [file...] Show the mimetypes of listed file/s. If you use this option, no conversion will be done. =item B<--extension -m> [file...] Like --type, but show the file extension type instead of mimetype. =item B<--content -c> Identify input files by content only, not extension. =item B<--nocontent -C> Identify input files by extension only, not content. =item B<--in -i>: file ... One or more input files. For a single file, you can omit `--in' and just put the filename. =item B<--out -o> file The output file. If you omit this, a2b will use a sensible default filename. You can't specify multiple output filenames when you use multiple input files. If there are multiple output files, they will be collected in a directory having the given output file name. =item B<--from -f> mimetype/extension The source mimetype or extension - this can usually be determined automatically from the input filename or content. =item B<--to -t>: mimetype/extension ... Acceptable destination mimetypes or extensions - this can usually be determined automatically from the output filename. =item B<--quiet -q> Don't show output from the tools. If you use --quiet, you will not see any error messages from tools. =item B<--silent -Q> Don't show how the conversion is done at all. =item B<--force -y> Overwrite the output file without asking. =back =head1 DESCRIPTION B is a wrapper for many programs like B, B, B, B, B, etc., which can convert content from one mimetype to another. It can covert text, documents, images, audio and video, and anything else you want to add to its configuration. It maintains a little database of types and tools in /usr/share/a2b. B can be used to invoke individual tools in a consistent way, and to chain tools together to acheive a more complex conversion. For example, it is unlikely that there is a program called `ps2jpeg' on your system, but B can acheive this using `pstopnm' followed by `cjpeg'. Complex conversions can be made automatically with no need for the user to know what's going on. Advanced users can set options for different tools, e.g. quality /compression settings, framerate, resizing, etc. This is done by setting environment variables. B can use the following conversion programs if they are installed: a2ps asciidoc asciitopgm bmptoppm catdoc cjpeg convert djpeg dvips espeak faac faad festival ffmpeg flite flac gif2png giftopnm gocr html2ps lame latex2html makedeb madplay mencoder mencoder_h264 mpg123 mplayer normalize-audio oggdec oggenc pbmtoascii pdf2ps pdftohtml pdftoppm pdftotext pgmtopbm pngtopnm pnmtopng ppmquant ppmtobmp ppmtopgm ppmtowinicon ppmtoxpm ps2ascii ps2pdf pstoimg pstopnm rtf2latex soundstretch text2html text2wave tesseract wget winicontoppm wvCleanLatex wvHtml wvLatex wvPDF wvPS wvText xls2csv xpmtoppm. B can convert among the following file types: 3gp aac avi bmp csv doc dvi ffv1 flac flv gif html ico jpg latex man mov mp3 mp4 mpg pbm pdf pgm png pl pod pnm ppm ps rtf tiff txt wav wmv xls xpm yuv B can also use generic filetypes: vid aud img B can automatically fetch files from a URL with B, and can read audio / video from cds and dvds using B. =head1 EXAMPLES a2b --list test.mp3 test.ogg a2b test.mp3 test.ogg a2b -p2 test.mp3 test.ogg a2b vid.flv vid.mp4 a2b vid.mov audio.flac a2b short.avi out.jpg video_fps=30 a2b out.jpg/*.jpg vid.avi mencoder_opts="-ss 60 -endpos 10" a2b video.avi clip.flv a2b Makefile Makefile.gif a2b --from=txt --to:gif --list a2b --from=text/plain --to:image/gif --in:Makefile --out=Makefile.gif a2b --from=flv --to:mp3 ogg flac aac mp4 --list a2b --in:track*.cdda.wav --to:mp3 a2b a2b.html a2b.ogg a2b -q http://sam.nipl.net/ sam.aac gocr_opts="-s 7" a2b -y http://www.hko.gov.hk/abouthko/logoexplain/logoexplaine.png out.txt a2b -D a2b-tmp -g=fast dvdnav://8 rip.avi a2b -D a2b-tmp -G=pass dvdnav://8 rip.avi a2b -g=subtitles dvd://8 subtitles.sub stretch=0.5 a2b -g=stretch -d=work traffic.mp4 traffic.avi audio_shift=-5 a2b -D=a2b-tmp-rmme -g=stretch rock.mp3 rock-low.aud ; a2b rock-low.aud rock-low.mp3 ; rm rock-low.aud # be careful with -D !! =head1 BUGS B cannot yet convert from one type to that same type, and will reject any paths that would pass through a single type twice. This can make it more complex to do an operation like stretching from an mp3 to a wav or an mp3 to an mp3, for example. The rule for sound stretching needs to target the generic audio type .aud, see the audio_shift example above. =cut