【问题标题】:Trim audio files with Sox in milliseconds在几毫秒内使用 Sox 修剪音频文件
【发布时间】:2012-09-15 17:38:45
【问题描述】:

有没有办法用 SoX 修剪文件的结尾,以毫秒为单位,我试过这个:

sox tracks\5_7.mp3 ntracks\05_7.mp3 trim 2 2.195

但是,它只是说End position is after expected end of audio,尽管文件实际上是那么长。

所以我试图让这首歌长 2.000 秒,而不是 2.195 秒,而且,我用 600 多个文件这样做,所以需要从命令行完成。

这是我的警告:

sox WARN mp3: MAD lost sync"(this always happens, means nothing) 
sox WARN trim: Last 1 position(s) not reached (audio shorter than expected)
sox WARN sox: 'tracks\01_1.mp3' balancing clipped 3 samples; decrease volume?

此音频文件用于“00:00:02.19”。

在命令行中输入的行是:

sox -v3 tracks\01_1.mp3 ntracks\01_1.mp3 trim 2 0.19 pause

这是我详细的开始:

D:\Stuff\Habbo trax maker\trax maker\mp3support>sox -V3 tracks\01_1.mp3 ntracks\
01_1.mp3 trim 2 0.19
sox:      SoX v14.4.0

Input File     : 'tracks\01_1.mp3'
Channels       : 1
Sample Rate    : 44100
Precision      : 16-bit
Duration       : 00:00:02.19 = 96755 samples = 164.549 CDDA sectors
File Size      : 17.6k
Bit Rate       : 64.0k
Sample Encoding: MPEG audio (layer I, II or III)

sox INFO sox: Overwriting `ntracks\01_1.mp3'
sox INFO mp3: using MP3 encoding defaults

Output File    : 'ntracks\01_1.mp3'
Channels       : 1
Sample Rate    : 44100
Precision      : 24-bit
Sample Encoding: MPEG audio (layer I, II or III)
Comment        : 'Processed by SoX'

sox INFO sox: effects chain: input        44100Hz  1 channels
sox INFO sox: effects chain: trim         44100Hz  1 channels
sox INFO sox: effects chain: output       44100Hz  1 channels
sox WARN mp3: MAD lost sync
sox WARN trim: Last 1 position(s) not reached (audio shorter than expected).

【问题讨论】:

  • 好的,我做了 V 详细或逐字或任何开头:P
  • 还有一个问题...当我检查音频的大小时,使用不同的程序(因为 SoX 只检查到小数点后第二位)它大约 0-99MilliSeconds 关闭,是否有可能解决这个问题?
  • 是的,但是,SoX 没有显示到毫秒,所以我看不出它在 SoX 中是否准确,这就是为什么我在另一个程序中检查它:P 它是 2.036 秒长.另外,我怎样才能停止混合改变音量?
  • wav 文件非常庞大,并且在我正在做的事情中支持 ogg arnt,我的程序有超过 640 个声音文件。我可以,将其编码为 .wav,修剪,然后再将其编码回去,这行得通吗?
  • 看起来我无法完成我的音乐程序.. 除非有一个 C++ 库可以更好地加入或修剪声音:P 实际上你可以在混合后让 SoX 覆盖另一个声音,所以声音 1 持续了 2.036 秒,声音 2 开始 00:00:02.000,即使另一部分还没有停止?

标签: audio sox


【解决方案1】:

如果要以毫秒精度进行修剪,请指定它:

sox in.mp3 out.mp3 trim 2 0.195

in.mp3out.mp3 的偏移量为 2 秒的情况下节省了 195 毫秒。

如果您只想要文件的前两秒,请像这样使用 trim:

sox in.mp3 out.mp3 trim 0 2

如果您想跳过文件的前两秒,请像这样使用 trim:

sox in.mp3 out.mp3 trim 2

如果您想从文件末尾修剪 195 毫秒,请使用 gerald's 答案。

手册摘录:

trim start [length|=end]
   The optional length parameter gives the length of audio to output after the 
   start sample and is thus used to trim off the end of the audio.
   Alternatively, an absolute end location can be given by preceding it with 
   an equals sign. Using a value of 0 for the start parameter will allow trimming
   off the end only.

【讨论】:

  • 不,对我都没有用:S 文件的长度为 0 秒
  • 我的解压中没有soxi.exe文件:S
  • 我有 1.4.4.0 顺便说一句我试过了: sox tracking\01_1.mp3 ntracks\01_1.mp3 trim 2.0 0.19 但它只是将文件设置为 0 我什至尝试过 sox tracking\01_1.mp3 ntracks\ 01_1.mp3 修剪 00:00:02.0 00:00:00.19
  • 我想传递一个 [[start, end ]] 时间列表和一个音频,以便将这些部分静音。使用 sox 或 ffmpeg 实现这一目标的最佳方法是什么?即
  • @kRazzyR:按照MCVE 准则将此作为新问题发布
【解决方案2】:

你应该像这样在毫秒内修剪

trim 26.26 =32.3245678 

这意味着它将修剪 26.26 秒,精确到 32.3245678 秒

这将为您提供准确的结果

使用这个= 选项,我们需要给出时间的结束而不是= 前面的持续时间

希望这能解决你的问题

【讨论】:

  • sox C:/wamp/www/audio/092A-0942-0930-0940.ogg ./output/1426308767635.ogg trim 0.000 =0.101
【解决方案3】:

您是否尝试过这样使用反向命令:

sox tracks\5_7.mp3 ntracks\05_7.mp3 reverse trim 0.195 reverse

这应该会丢弃文件的最后 0.195 毫秒(它适用于我)。

【讨论】:

  • 这是我需要的。感谢@Thor 指点我这里!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-03-28
  • 1970-01-01
  • 2022-11-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多