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

In-depth analysis of Nginx virtual host

Table of contents 1. Virtual Host 1.1 Virtual Hos...

JavaScript to implement slider verification code

This article shares the specific code of JavaScri...

MySQL detailed explanation of isolation level operation process (cmd)

Read uncommitted example operation process - Read...

Detailed explanation of the role of brackets in AngularJS

1. The role of brackets 1.1 Square brackets [ ] W...

Detailed explanation of the entry-level use of MySql stored procedure parameters

Use of stored procedure in parameters IN paramete...

Three ways to achieve background blur in CSS3 (summary)

1. Normal background blur Code: <Style> htm...

Detailed tutorial on installing Docker on CentOS 8

1. Previous versions yum remove docker docker-cli...

Implementation of Linux command line wildcards and escape characters

If we want to perform batch operations on a type ...

MySQL Community Server 5.7.19 Installation Guide (Detailed)

MySQL official website zip file download link htt...

Deep understanding of line-height and vertical-align

Several concepts Line box: A box that wraps an in...

Use Python to connect to MySQL database using the pymysql module

Install pymysql pip install pymysql 2|0Using pymy...

HTTP return code list (Chinese and English explanation)

http return code list (below is an overview) for ...

Why do code standards require SQL statements not to have too many joins?

Free points Interviewer : Have you ever used Linu...