media | audio edit

Convert

convert ape to wav.

ffmpeg -i in.ape out.wav

ffmpeg -i CDImage.ape z.wav

find ape files and convert them to flac:

find /path/to/MainDir/ -type f -name "*.ape" -execdir sh -c ' ffmpeg -i "$1" "${1%.ape}.flac" ' _ {} \;

convert flac to mp3. here the number after qscale:a is quality.

ffmpeg -i in.flac -qscale:a 2 out.mp3

cut and convert flac to mp3. here the number after qscale:a is quality.

ffmpeg -i in.flac -ss 00:00:50 -to 00:03:28 -qscale:a 2 out.mp3

cut mp3.

ffmpeg -i in.mp3 -ss 00:00:53 -to 00:02:28 -acodec copy out.mp3

flag to implement milliseconds:

-ss 00:00:15.aaa -t 00:00:20.bbb

extract audio from video:

ffmpeg -i input.flv -vn -acodec copy output.aac

batch extract audio from videos:

for f in *.avi; do ffmpeg -i "${f}" -acodec copy "${f}.mp3"; done

script for batch extracting:

#!/bin/bash

echo
for f in *.wmv; do 
    if [ -f "${f}.mp3" ]; then
        echo "File ${f}.mp3 exists."; 
        echo;
        echo "-----------------------------------------------------";
        echo;
    else
        echo "Converting ${f}";
        echo;
        ffmpeg -i "${f}" -hide_banner -loglevel fatal -stats -qscale:a 0 "${f}.mp3";
        echo;
        echo "-----------------------------------------------------";
        echo;        
    fi
done

Join files

Join flac files:

shntool join *.flac -o flac

Join mp3 files:

mp3wrap output.mp3 *.mp3

CUE files

To split an audio file accompanied by a CUE sheet into tracks in .wav format, use the shnsplit command:

shnsplit -f file.cue file.ape

Format for output file names can be specified with the -t option (%n for track number, %t for title):

shnsplit -f file.cue -t "%n %t" file.ape

Split from and to FLAC format:

shnsplit -f file.cue -t %n-%t -o flac file.flac

Split and encode to FLAC format:

shnsplit -f file.cue -o flac file.ape

Encoding options, including the encoder itself, can be specified with the -o parameter.

shnsplit -f file.cue -o "flac flac -s -8 -o %f -" file.ape

Reference:

wiki.archlinux.org