Sox:用 pad 合并两个音频文件
我正在使用 sox
工具,并且想要合并两个音频文件,例如 long.ogg
和 short.ogg
输出文件output.ogg
。 使用 $ sox -m long.ogg Short.ogg output.ogg 非常容易。
问题是,我希望 n 秒后播放 short.ogg
(而 long.ogg
应该从头开始)。为此,我找到了pad效果。但我不明白仅延迟 short.ogg
输入文件而不是 long.ogg
输入文件的语法。
我找到了一种(肮脏的)这样做的方法(n=6):
$ sox short.ogg delayed.ogg pad 6
$ sox -m long.ogg delayed.ogg output.ogg
我不想创建中间文件。预先感谢您的帮助。
I'm using the sox
tool and I would like to merge two audio files, let's say long.ogg
and short.ogg
to output a file output.ogg
.
This is very easy using $ sox -m long.ogg short.ogg output.ogg
.
Thing is, I would like the short.ogg
to be played after n seconds (while long.ogg
should start right from the beginning). To do so, I've found the pad effect. But I don't understand the syntax to delay only the short.ogg
input file, not the long.ogg
one.
I found a (dirty) way of doing so (with n=6):
$ sox short.ogg delayed.ogg pad 6
$ sox -m long.ogg delayed.ogg output.ogg
I would like not to have to create an intermediate file. Thanks in advance for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您应该能够执行以下操作:
sox 的
-p
选项用于管道 - 基本上,它告诉 sox 使用 stdout 作为输出。使用-
作为第二个 sox 的输入实际上是说输入是 stdin(它恰好是前一个 sox 的 stdout,因为我们使用|
进行管道传输)。pad 0 6
告诉 pad 开头 0 秒,结尾 6 秒。希望这有帮助。
You should be able to do something like:
-p
option to sox is used for piping - basically, it tells sox to use stdout as the output. Using-
as the input to the second sox is actually saying input is stdin (which happens to be the stdout of the previous sox, as we are piping with|
).pad 0 6
tells pad 0 seconds at the beginning and 6 seconds at the end.Hope this helps.
感谢 icyrock,我设法找到了解决方案。我正在使用:
对于多轨(归功于奥兰多):
Thanks to icyrock, I managed to find a solution. I'm using:
For multi tracks (credits to Orlando):
这是另一个受益于使用双引号的解决方案。它使命令更具可读性并且非常容易扩展:
这将连接所有三个文件,每个文件后有 1 秒的暂停(odin、silence、dva、silence、tri、silence。)
应用于原始帖子,我们' d get:
(在 Windows 上的 SoX 14.4.1 上测试正常。)
我几乎没有看到任何使用双引号的 SoX 示例,所以我希望这对某人有帮助!
Here is another solution benefiting from the use of double-quotes. It makes the command much more readable and very easy to extend:
This would concatenate all three files, with a 1-second pause after each (odin, silence, dva, silence, tri, silence.)
Applied to the original post, we'd get:
(Tested OK on SoX 14.4.1 on Windows.)
I have hardly seen any SoX example using double-quotes, so I hope this helps someone!
因为我还不允许发表评论,我只想说我喜欢 Fabien 的答案,因为它也可以与“NULL”声音文件一起使用:例如,
将在 300 Hz 处写入 1 秒的正弦音,然后是 1 400 Hz 正弦音的秒并将其写入文件“useful.wav”。
只会将 1 秒 400 Hz 的正弦波写入文件“farts.wav”。该文件缺少 300 Hz 的第一个正弦波。
Because I'm not allowed to comment yet, I would just like to say that I like Fabien's answer because it can also be used with the "NULL" soundfile: e.g.,
Will write 1 second of a sine tone at 300 Hz followed by 1 second of a sine tone at 400 Hz and write it to the file "useful.wav".
Will only write 1 second of a sine wave at 400 Hz to the file "farts.wav". The file is missing the first sine wave at 300 Hz.
也遇到了延迟命令。
您可以执行以下操作:
sox.exe -m Short.ogg long.ogg 延迟 6
这将合并两个文件,short.ogg 将在 6 秒后开始进入 long.ogg
Ran across delay command as well.
You could do the following:
sox.exe -m short.ogg long.ogg delay 6
This will merge the two files and short.ogg will start 6 seconds into long.ogg