Linux Commands Examples

A great documentation place for Linux commands


Extract the audio out of MJPEG container files to stdout

see also : mp2enc - sox


lav2wav [-s num] [-c num] [-v num] [-I] [-R] [-r samplerate, bitesize, channels] lavfile1 [lavfile2 ... lavfileN]

add an example, a script, a trick and tips

: email address (won't be displayed)
: name

Step 2

Thanks for this example ! - It will be moderated and published shortly.

Feel free to post other examples
Oops ! There is a tiny cockup. A damn 404 cockup. Please contact the loosy team who maintains and develops this wonderful site by clicking in the mighty feedback button on the side of the page. Say what happened. Thanks!


no example yet ...

... Feel free to add your own example above to help other Linux-lovers !


lav2wav can be used to extract the audio to stdout. This output goes to stdout and can be saved as a wav file or piped to another sound processing tool that is able to handle the wav format. This can be mp2enc and toolame for mpeg layer 2 audio, or for example lame for mpeg layer 3 audio.

The input files may be any combination of AVI (.avi), Quicktime (.qt) or editlist files so long as they are all lavtools- readable (e.g. MJPEG-encoded AVI/Quicktime or DV type 2 AVI).


lav2wav accepts the following options:

Start extracting at video frame (num)

-c num

Extract (num) frames of audio

-v num

Verbosity level (0, 1 or 2)


Ignore unsupported bitrates/bits per sample


If the file does not contain any sound. lav2wav will create silence with 44100kHz Sampelrate, 16 Bit audio bitsize and 2 Chanels

-r sr,bs,ch

If the file does not contain any sound lav2wav will generate silence with the values you supply the samplerate (sr), audio-bitsize (bs) and channel (ch).


The "WAV" file format (technically: RIFF) is really very much less than ideal for a tool intended to be used in pipelines as lav2wav is. The problem is that the header includes a field specifying the length of the file. This can’t be filled in except by seeking back to the begining and over-writing. If the output is unseekable (e.g. pipe) lav2wav simply writes a large length into the header and leaves it at that. Most tools like sox(1) or mp2enc(1) either ignore the length field anyway or only give a warning.
The audio length is inacurate calculated when lav2wav generates silence. This happens only if you have NTSC framerate and than it creates for every hour of video 1.1498sec too less of silence.

see also

mjpegtools, mp2enc , sox


This man page was written by Bernhard Praschinger.
If you have questions, remarks, problems or you just want to contact the developers, the main mailing list for the MJPEG-tools is:

For more info, see our website at

How can this site be more helpful to YOU ?

give  feedback