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

How to use resize to implement image switching preview function

Key Points The CSS resize property allows you to ...

Solution to elementui's el-popover style modification not taking effect

When using element-ui, there is a commonly used c...

Two ways to clear table data in MySQL and their differences

There are two ways to delete data in MySQL: Trunc...

Steps to set up Windows Server 2016 AD server (picture and text)

Introduction: AD is the abbreviation of Active Di...

Pricing table implemented with CSS3

Result: Implementation Code html <div id="...

Example of how to set up a third-level domain name in nginx

Problem Description By configuring nginx, you can...

Detailed explanation of transactions and indexes in MySQL database

Table of contents 1. Affairs: Four major characte...

Linux uses dual network card bond and screwdriver interface

What is bond NIC bond is a technology that is com...

Detailed explanation of the new features of ES9: Async iteration

Table of contents Asynchronous traversal Asynchro...

In-depth analysis of MySQL query interception

Table of contents 1. Query Optimization 1. MySQL ...

How to add automatic completion commands for docker and kubectl on Mac

Introduction to kubectl kubectl is a command line...

Vue-Element-Admin integrates its own interface to realize login jump

1. First look at the request configuration file, ...

Detailed explanation of the usage of two types of temporary tables in MySQL

External temporary tables A temporary table creat...