简体   繁体   English

如何合并(混合)两个立体声 mp3 音频文件

[英]How to merge(Mix) two stereo mp3 audio file

I have two stereo file: 1.mp3, 2.mp3我有两个立体声文件:1.mp3、2.mp3

I want to merge this two audio files in the special way我想以特殊方式合并这两个音频文件

I mean I want 3.mp3 to be a stereo file that has 1.mp3 in it's left channel and 2.mp3 in it's right channel我的意思是我想让 3.mp3 成为一个立体声文件,它的左声道有 1.mp3,右声道有 2.mp3

You can achieve that by following these steps:您可以按照以下步骤实现:

  1. Decode 1.mp3 and 2.mp3 files解码 1.mp3 和 2.mp3 文件

  2. Save decoded raw data (in different WAVE formatted files or in memory)保存解码后的原始数据(在不同的 WAVE 格式文件或内存中)

  3. Replace of 1.mp3 decoded raw data's first or second channel values with 2.mp3 decoded raw data's first or second channel values one by one (note that this causes quality loss of audio)将1.mp3解码原始数据的第一或第二通道值逐个替换为2.mp3解码原始数据的第一或第二通道值(注意这会导致音频质量损失)

  4. Construct WAVE(raw audio data format) header based on the merged audio data features基于合并后的音频数据特征构建WAVE(raw audio data format) header

  5. Create WAVE formated 3.wav file using constructed WAVE header and merged audio data使用构建的 WAVE header 和合并的音频数据创建 WAVE 格式的 3.wav 文件

  6. Convert 3.wav file to 3.mp3 file format将 3.wav 文件转换为 3.mp3 文件格式

Doing these steps requires you to know:执行这些步骤需要您了解:

  • How to decode mp3 files to get raw data如何解码mp3文件以获取原始数据

  • How to manipulate on data bytes in buffer如何操作缓冲区中的数据字节

  • WAVE soundfile format WAVE 声音文件格式

  • How to convert wav to mp3如何将 wav 转换为 mp3

For decoding and encoding audio files in different formats you can use some appropriate sound library(for example BASS ) - this helps you to do 1 and 6 steps.要解码和编码不同格式的音频文件,您可以使用一些合适的声音库(例如BASS )——这可以帮助您完成第 1 步和第 6 步。 For constructing WAVE formated audio data you should be familiar with WAVE File Format and how audio data channels is aligned in buffer - this helps you to do 3, 4 and 5 steps要构建 WAVE 格式的音频数据,您应该熟悉WAVE 文件格式以及音频数据通道如何在缓冲区中对齐 - 这有助于您完成 3、4 和 5 个步骤

mp3 is compressed audio data. mp3 是压缩的音频数据。 you can not directly mix them using file operations.您不能使用文件操作直接混合它们。 one thing you can do is use ffmpeg library to convert the mp3 to raw PCM, mix the channels and then converting it back to mp3.你可以做的一件事是使用 ffmpeg 库将 mp3 转换为原始 PCM,混合通道,然后将其转换回 mp3。

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

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