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

A Different Kind of "Cancel" Button

The “Cancel” button is not part of the necessary ...

Detailed tutorial on building nextcloud private cloud storage network disk

Nextcloud is an open source and free private clou...

Vue-CLI multi-page directory packaging steps record

Page directory structure Note that you need to mo...

JS, CSS style reference writing

CSS: 1. <link type="text/css" href=&q...

Example code for implementing fullpage.js full-screen scrolling effect with CSS

When I was studying CSS recently, I found that I ...

8 essential JavaScript code snippets for your project

Table of contents 1. Get the file extension 2. Co...

CSS box hide/show and then the top layer implementation code

.imgbox{ width: 1200px; height: 612px; margin-rig...

Detailed explanation of Nginx status monitoring and log analysis

1. Nginx status monitoring Nginx provides a built...

Teach you step by step to configure MySQL remote access

Preface When using the MySQL database, sometimes ...

How to Rename a Group of Files at Once on Linux

In Linux, we usually use the mv command to rename...

Docker builds kubectl image implementation steps

If the program service is deployed using k8s inte...

Solve the compatibility issue between MySQL 8.0 driver and Alibaba Druid version

This article mainly introduces the solution to th...

Implementation of css transform page turning animation record

Page turning problem scenario B and C are on the ...