Skip to content

Instantly share code, notes, and snippets.

@shostelet
Last active September 19, 2023 07:35
Show Gist options
  • Save shostelet/aa372dfa77e117d8caa88a4dac97f01e to your computer and use it in GitHub Desktop.
Save shostelet/aa372dfa77e117d8caa88a4dac97f01e to your computer and use it in GitHub Desktop.
# separated IN + OUT to one stereo
filename="my_audio"
ffmpeg -i $filename-in.mp3 -i $filename-out.mp3 -filter_complex "[0]apad[a];[a][1]amerge[aout]" -map "[aout]" $filename.mp3
# Mono to stereo
ffmpeg -i mono.wav -ac 2 stereo.wav
# Stereo to mono
ffmpeg -i stereo.wav -ac 1 mono.flac
# Get audio file characteristics
ffprobe -i audio_file.mp3 -v error -show_entries 'stream=codec_type,channels,channel_layout,sample_rate,duration'
# Convert to mp3
# -vn : ensure no video, not even a cover
# -ar : audio sampling frequency. Use the one shown by doing a `ffmpeg -i input.wav`
# -ac 2 : ensure stereo
# -b:a 192k : ensure biterate of 192k
ffmpeg -i input.wav -vn -ar 8000 -ac 2 -b:a 192k output.mp3
# MP3 to Raw PCM
ffmpeg -i input.mp3 -acodec pcm_s16le -f s16le -ac 1 -ar 8000 output.pcm
# Stereo to Stereo with left channel muted
ffmpeg -i stereo.wav -af "pan=stereo|c1=c1" left_muted_stereo.wav
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment