Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of realizing Audio format conversion and splicing with linux Command

2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

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 suffix.ape to m4a(mp4) format

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

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

2, and then use the lame command compressed into MP3

##Using the lame command: Use VBR dynamic bitrate compression, 0 means the highest quality, 9 means the lowest quality, default is 4eric@ray:~/Music$ lame -v Gracie-Theme.wav##or use faac encoding to get m4a(mp4), mp3 format file: 100 means the highest quality 100% eric@ray:~/Music$ faac -w -q 100 Gracie-Theme. wav-o Gracie-Theme. mp4

3, can also use ffmpeg compression to get m4a format:

#This uses the built-in aac encoding of ffmpeg, and sets the bit rate to a fixed 320keric@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 it into a command:-map_metadata to retain 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/bashfor FILE in *.ape;doffmpeg -i "$FILE" temp.wav;lame -b 320 temp.wav "${FILE%.*}. mp3";rm temp.wavdone

For an ape/flac file containing multiple songs

In this case, there is usually a cue file that contains the album name, artist name, and name of each song and time range of the ape/flac file. You can use the above method to convert the entire file to 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 name

@t: song title

@n: Track number

audio merge

#Audio Merge 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 stitching 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 mosaics eric@ray:~/Music$ffmpeg -i title.wav -i content. wav-i trailer.wav -filter_complex '[0:0] [1:0] [2:0] concat=n=3:v=0:a=1 [a]' -map [a] synthesis.wav

resources

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

The above linux command to achieve audio format conversion and splicing method is Xiaobian shared with everyone's full content, I hope to give you a reference, but also hope that everyone more support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report