My Music (Listen with quality headphones)

Wednesday 13 February 2013

Useful linux bash commands for audio file editing and manipulation

Here are some useful linux bash commands I use to convert between different audio file types when making my samples.


AUDIO COMMANDS


Extract audio from a flash video file (flv) and save it as a wav:
mplayer video.flv -vc null -vo null -ao pcm:fast:waveheader:file=outfile.wav


Capture a live audio stream from the system output and save it as a flac file:
jack_capture -f flac


Convert a flac file to a high quality mp3 file with a 128kbps bitrate:
flac -cd sample.flac |lame -h – sample.mp3


Convert all flac files in the current directory to high quality mp3 files with a 128kbps bitrate:
for f in *.flac;do flac -cd "$f"|lame -b 192 – "${f%.flac}.mp3";done


Convert a flac file to a wav file:
flac -d sample.flac


Convert all flac files in the current directory to wav files:
flac -d *


Convert a flac file to an ogg vorbis audio file:
oggenc sample.flac -o sample.ogg

Convert all wav files in the current directory to ogg:
for w in *.wav;do oggenc "$w" -o "${w%.wav}.ogg";done


Convert a wav file to an mp3 with 192 bitrate:
lame -b 192 sample.wav


Reversing the audio playback of a file and saving it as a new file:
sox input.flac output.flac reverse


Trim an audio file, starting e.g. at 0 and stopping at 6.85714 seconds:
sox input.wav output.wav trim 0 6.85714


Batch trim all flac files in a folder, starting e.g. at 0 and stopping at 3.47826087 seconds:
for f in *.flac;do sox "$f" "${f%.flac}_.flac" trim 0 3.47826087;done


Remove the first 0.047 seconds of an audio file:
sox input.wav output.wav trim 0.047


Combine (concatenate) all flac files in the current directory into one file:
sox --combine concatenate $(ls|grep .flac) out.flac


Add the LADSPA canyon delay effect to a whole folder of flac files in batch mode:
for f in *.flac;do ecasound -i:"$f" -o:"${f%.flac}_.flac" -el:canyon_delay,0.439,-0.14,0.439,0.5,2735.45288;done


Batch fix loop files that click at the end, by adding a fadeout effect to the very end of the file:
for w in *.wav;do sox "$w" "${w%.wav}_.wav" fade 0 $(soxi -D $w) 0.00045;done




List numbered loops files generated from "" from 0.wav...N.wav (used as in parameter for the command "Combine (concatenate) all flac files in the current directory into one file"):
ls -tr


Extract xml metadata from lmms mmpz file (e.g. to get the track measure labels you set):
lmms -d my-lmms-project.mmpz > dump.xml



VIDEO COMMANDS


Convert flash flv video to mp4:
ffmpeg -i input.flv output.mp4



On a related noted, here are my photo tutorials about music production.

1 comment:

  1. Hello and good day to you can I convert flac to Lpcm wav for audio DVD ( not DVD-A ) eg. sox *.flac −t wavpcm −s *.wav ???? I would like to encode to Lpcm 96 kHz x 24 bits x 2 channels = 4608 kb/s DVD Video specs audio only. I use Ubuntu 14.04 linux

    ReplyDelete

My content is under the Creative Commons Attribution 3.0 license. I work hard to publish relevant and useful information in order to help people learn difficult things and find solutions to their problems, so please attribute me if you reuse my content elsewhere.