Posted by & filed under AWS/Linux/Unix/Devops stuff.

A quick list of commands for audio/video conversion on the command line

Create mobile-compatible/optimized H.264 baseline videos (requires ffmpeg)

`which ffmpeg` -y -i /path/to/h264/file.mp4 -strict experimental -profile baseline -vcodec libx264 -level 3 /path/to/h264baseline/file.mp4

Note that faststart support may be necessary for your videos to begin playing before they have loaded completely. If your ffmpeg version is new enough you can do this by adding the “-movflags +faststart” arguments somewhere between “-strict” and “-level 3″. If you are running an older version of ffmpeg a binary should be included called “qt-faststart” which can be used to add faststart support to your file, although you’ll have to work with a temp file as the source and destination arguments used by qt-faststart need to differ.

Convert from H.264 or WMV to WebM (requires ffmpeg)

Adjust the bitrate to your liking

`which ffmpeg` -y -i /path/to/h264/file.mp4/or/file.wmv -acodec libvorbis -b 1500k /path/to/webm/output.ogv

Convert from WebM or WMV to H.264 (requires ffmpeg)

Adjust the bitrate to your liking

`which ffmpeg` -y -i /path/to/webm/file.ogv/or/file.wmv -acodec libfaac -vcodec libx264 -b 1500k /path/to/h264/output.mp4

 Convert to OggVorbis from MP3 (requires mpg321)

`which mpg321` -q /path/to/mp3file.mp3 -w – | `which oggenc` -Q -o /path/to/output.ogg -

Convert from WAV to MP3 (requires lame)

`which lame` –silent –preset standard /path/to/wavfile.wav /path/to/output.mp3

Convert from WAV to OggVorbis (requires libogg)

`which oggenc` -Q -o /path/to/output.ogg /path/to/wavfile.wav

Convert from AAC to MP3 (requires faad, lame)

create WAV file first:

`which faad` -q -o /path/to/output.wav /path/to/aacfile.m4a

create MP3 from WAV:

`which lame` –silent –preset standard /path/to/wavfile.wav /path/to/output.mp3

Convert from AAC to OggVorbis (requires faad, libogg)

create WAV file first:

`which faad` -q -o /path/to/output.wav /path/to/aacfile.m4a

create OggVorbis from WAV:

`which oggenc` -Q -o /path/to/output.ogg /path/to/wavfile.wav

Convert from OggVorbis to MP3 (requires libogg, lame)

create WAV file first:

`which oggdec` -Q -o /path/to/output.wav /path/to/oggfile.ogg

create MP3 from WAV:

`which lame` –silent –preset standard /path/to/wavfile.wav /path/to/output.mp3

Updating files in bulk

Remove spaces from all filenames in current directory:

for i in *; do mv “$i” `echo $i | sed ‘s/ //g’`; done

Convert all WAV files in current directory to MP3 files:

for i in *.wav; do `which lame` –preset standard “$i” “`echo $i | sed ‘s/(.*).wav/1.mp3/’`”; done

  • NetMusician Support

    Added “Updating files in bulk” section

  • Joe Auty

    Added “Create mobile-compatible/optimized H.264 baseline videos” section