How to use linux commands to convert and splice audio formats

How to use linux commands to convert and splice audio formats

Install FFmpeg flac

eric@ray:~$ sudo apt install FFmpeg flac

Install lame faac

eric@ray:~$ sudo apt install lame faac

Convert a video with the .ape extension to m4a (mp4) format

1. First, use the ffmpeg command or flac command to convert it to mav format, and then use lame to convert wav to mp4 format

eric@ray:~/Music$ ffmpeg -i Gracie-Theme.ape Gracie-Theme.wav

##or eric@ray:~/Music$ flac -d Gracie-Theme.flac Gracie-Theme.wav

2. Use the lame command to compress it into MP3

##Use lame command: Use VBR dynamic bit rate compression, 0 means the highest quality, 9 means the lowest quality, the default is 4

eric@ray:~/Music$ lame -v Gracie-Theme.wav

##Or use faac encoding to get m4a (mp4) or mp3 format files: 100 means the highest quality is 100% 

eric@ray:~/Music$ faac -w -q 100 Gracie-Theme.wav -o Gracie-Theme.mp4

3. You can also use ffmpeg to compress to get m4a format:

#Here we use the built-in aac encoding of ffmpeg, and set the bit rate to a fixed 320k

eric@ray:~/Music$ ffmpeg -i Gracie-Theme.wav -strict experimental -c:a aac -b:a 320k Gracie-Theme.m4a

#You can also use ffmpeg to decompress and compress in one command: -map_metadata means to keep the song metadata, i.e. name, singer, etc. eric@ray:~/Music$ ffmpeg -i Gracie-Theme.flac -ab 320k -map_metadata 0 Gracie-Theme.m4a

4. Batch scripts

#!/bin/bash

for FILE in *.ape;
do
ffmpeg -i "$FILE" temp.wav;
lame -b 320 temp.wav "${FILE%.*}.mp3";
rm temp.wav
done

For an ape/flac file containing multiple songs

In this case, there is usually a cue file, which contains the album name, singer name, name of each song, and time range of the ape/flac file. You can first use the above method to convert the entire file into Mp3 format, and then use the mp3splt tool to split it.

Split cue file into mp3:

eric@ray:~/Music$mp3splt -c song.cue -o @n.@t song.mp3

Common parameters:

@a: singer name

@b: Album title

@t:Song title

@n: track number

Audio Merger

# Audio merging (two audios overlap)

eric@ray:~/Music$ffmpeg -i first.mp3 -i second.mp3 -filter_complex amix=inputs=2:duration=first:dropout_transition=2 -f mp3 third.mp3

#Two audio splicing eric@ray:~/Music$ffmpeg -i d1.mp3 -i d2.mp3 -filter_complex '[0:0] [1:0] concat=n=2:v=0:a=1 [a]' -map [a] j5.mp3

#Three audio splicing eric@ray:~/Music$ffmpeg -i title.wav -i content.WAV -i end.wav -filter_complex '[0:0] [1:0] [2:0] concat=n=3:v=0:a=1 [a]' -map [a] synthesis.wav

References

FFmpeg and AAC Encoding Guide https://trac.ffmpeg.org/wiki/Encode/AAC

The above Linux command method to achieve audio format conversion and splicing is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • Detailed explanation of Linux text file and WIN text file line break format conversion command

<<:  How to determine if the Linux system is installed on VMware

>>:  JavaScript built-in date and time formatting time example code

Recommend

28 Famous Blog Redesign Examples

1. WebDesignerWall 2. Veerle's Blog 3. Tutori...

vue-cli configuration uses Vuex's full process record

Table of contents Preface Installation and Usage ...

How to deploy MySQL 5.7 & 8.0 master-slave cluster using Docker

> Deploy MySQL 5.7 cluster master & slave ...

HTML basics - CSS style sheets, style attributes, format and layout details

1. position : fixed Locked position (relative to ...

Detailed explanation of several storage methods of docker containers

Table of contents Written in front Several storag...

Sharing ideas on processing tens of millions of data in a single MySQL table

Table of contents Project Background Improvement ...

Solve the problem of docker images disappearing

1. Mirror images disappear in 50 and 93 [root@h50...

Analysis of the process of building a LAN server based on http.server

I don’t know if you have ever encountered such a ...

Tutorial on building svn server with docker

SVN is the abbreviation of subversion, an open so...

HTML basic syntax is convenient for those who are just starting to learn HTML

1.1 General marking A general tag consists of an ...

Detailed tutorial on installing Tomcat8.5 in Centos8.2 cloud server environment

Before installing Tomcat, install the JDK environ...

Solution to the Docker container cannot be stopped and deleted

Find the running container id docker ps Find the ...