本文介绍了裁剪MP3到前30秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

原始问题

我想要从现有的MP3文件中生成一个新的(完全有效的)MP3文件,作为预览 - 尝试购买之前的风格。新文件应该只包含第一个 n 秒的轨道。

I want to be able to generate a new (fully valid) MP3 file from an existing MP3 file to be used as a preview -- try-before-you-buy style. The new file should only contain the first n seconds of the track.

现在,我知道我可以在 em> n 秒(从比特率和头大小计算),但这在VBR轨道上有点脏,真正的PITA。我想要生成一个合适的MP3文件。

Now, I know I could just "chop the stream" at n seconds (calculating from the bitrate and header size) when delivering the file, but this is a bit dirty and a real PITA on a VBR track. I'd like to be able to generate a proper MP3 file.

任何一个想法?

答案

mp3split和ffmpeg都是很好的解决方案。我选择了ffmpeg,因为它通常安装在linux服务器上,也是。这里有一些更好的命令行参数,用于通过ffmpeg生成预览

Both mp3split and ffmpeg are both good solutions. I chose ffmpeg as it is commonly installed on linux servers and is also easily available for windows. Here's some more good command line parameters for generating previews with ffmpeg


  • -t< seconds> / code> 剁指定秒数

  • -y 强制文件覆盖

  • -ab< bitrate> 设置比特率 -ab 96k

  • -ar< rate Hz> 率例如 -ar 22050 22.05kHz

  • -map_meta_data< outfile>:< infile> 将跟踪元数据从infile复制到outfile

  • -t <seconds> chop after specified number of seconds
  • -y force file overwrite
  • -ab <bitrate> set bitrate e.g. -ab 96k
  • -ar <rate Hz> set sampling rate e.g. -ar 22050 for 22.05kHz
  • -map_meta_data <outfile>:<infile> copy track metadata from infile to outfile

而不是设置-ab和-ar,您可以复制原始曲目Tim Farley建议的设置如下:

instead of setting -ab and -ar, you can copy the original track settings, as Tim Farley suggests, with:


  • -acodec copy

推荐答案

我还推荐ffmpeg,但John Boker建议的命令行有一个意想不到的副作用:它将文件重新编码为默认比特率(至少在这里的版本是64 kb / s)。这可能会给您的客户造成您的声音文件质量的错误印象,并且还需要更长的时间。

I also recommend ffmpeg, but the command line suggested by John Boker has an unintended side effect: it re-encodes the file to the default bitrate (which is 64 kb/s in the version I have here at least). This might give your customers a false impression of the quality of your sound files, and it also takes longer to do.

这里是一个命令行,将切片至30秒,转码:

Here's a command line that will slice to 30 seconds without transcoding:

ffmpeg -t 30 -i inputfile.mp3 -acodec copy outputfile.mp3

-acodec开关告诉ffmpeg使用不转码的特殊复制编解码器。

The -acodec switch tells ffmpeg to use the special "copy" codec which does not transcode. It is lightning fast.

注意:该命令根据Oben Sonne的评论进行更新

NOTE: the command was updated based on comment from Oben Sonne

这篇关于裁剪MP3到前30秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 07:28