简体   繁体   English

创建带有淡入淡出的示例mp3

[英]Creating a sample mp3 with fade

I need to know if it is possible to create a 30 second sample MP3 from a WAV file. 我需要知道是否可以从WAV文件创建30秒的示例MP3。 The generated MP3 file must feature a fade at the start and end. 生成的MP3文件的开头和结尾必须具有淡入淡出的功能。

Currently using ffmpeg, but can not find any documentation that would support being able to do such a thing. 当前使用ffmpeg,但找不到任何支持能够执行此操作的文档。

Could someone please provide me the name of software (CLI, *nix only) that could achieve this? 有人可以给我提供可以实现此目的的软件名称(仅CLI,* nix)吗?

This will 这会

  • trim out from Position 45 sec. 从位置45秒修剪。 the next 30 seconds (0:45.0 30) and 接下来的30秒(0:45.0 30)和
  • fade the first 5 seconds (0:5) and the last 5 seconds (0 0:5) and 淡出前5秒(0:5)和后5秒(0 0:5),然后
  • convert from wav to mp3 从wav转换为mp3

     sox infile.wav outfile.mp3 trim 0:45.0 30 fade h 0:5 0 0:5 

Check out SoX - Sound eXchange SoX-Sound eXchange

I have not used it myself but one of my friends speaks highly of it. 我自己没有使用过它,但是我的一位朋友对此高度评价。

From web page (highlighted my me) : 从网页(突出显示我)

SoX is a cross-platform (Windows, Linux, MacOS X, etc.) command line utility that can convert various formats of computer audio files in to other formats. SoX是跨平台(Windows,Linux,MacOS X等)命令行实用程序,可以将各种格式的计算机音频文件转换为其他格式。 It can also apply various effects to these sound files , and, as an added bonus, SoX can play and record audio files on most platforms. 它还可以对这些声音文件应用各种效果 ,而且,作为额外的好处,SoX可以在大多数平台上播放和录制音频文件。

The best way to do this is to apply the 30-second truncation, fade in and fade out to the WAV audio data before converting it to an MP3. 最好的方法是将30秒截断,淡入和淡出到WAV音频数据, 然后再将其转换为MP3。 If your conversion library has a method that takes an array of samples, this is very easy to do. 如果您的转换库中有一个采用样本数组的方法,那么这很容易做到。 If the method only accepts a WAV file (either in-memory or on disk), then this is slightly less easy as you have to learn the WAV file format (which is easy to write but somewhat more difficult to read). 如果该方法仅接受WAV文件(在内存中或在磁盘上),那么这将变得不那么容易,因为您必须学习WAV文件格式(该文件易于编写但阅读起来有些困难)。 Either way, applying gain and/or attenuation to time-domain sample data (as in a WAV file) is much easier than trying to apply these effects to frequency-domain data (as in an MP3 file). 无论哪种方式,将增益和/或衰减应用于时域采样数据(如在WAV文件中)比尝试将这些效果应用于频域数据(如MP3文件) 容易得多。

Of course, if your conversion library already does all this, it's best to just use that and not worry about it yourself. 当然,如果您的转换库已经完成了所有这一切,那么最好只是使用它而不必自己担心。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM