Page 1 of 1

如何使用pipeline录制两种不同的格式?

Posted: Tue May 14, 2019 10:27 am
by coollofty

Code: Select all

	//WAV
	audio_pipeline_cfg_t pipeline_wav = DEFAULT_AUDIO_PIPELINE_CONFIG();
	wav_encoder_cfg_t wav_enc_cfg = DEFAULT_WAV_ENCODER_CONFIG(); 
    wavRecorder = audio_pipeline_init(&pipeline_wav);

	audio_pipeline_register(wavRecorder, i2s_stream_reader, "i2s");
	audio_pipeline_register(wavRecorder, wav_encoder_init(&wav_enc_cfg), "wav");
	audio_pipeline_register(wavRecorder, fs_stream_writer, "file");
	audio_pipeline_link(wavRecorder, (const char *[]) {"i2s", "wav", "file"}, 3);

	// AMR-WB
	audio_pipeline_cfg_t pipeline_amr = DEFAULT_AUDIO_PIPELINE_CONFIG();
	amrwb_encoder_cfg_t amr_enc_cfg = DEFAULT_AMRWB_ENCODER_CONFIG();	
    amrRecorder = audio_pipeline_init(&pipeline_amr);

	audio_pipeline_register(amrRecorder, i2s_stream_reader, "i2s");
	audio_pipeline_register(amrRecorder, amrwb_encoder_init(&amr_enc_cfg), "Wamr");
	audio_pipeline_register(amrRecorder, fs_stream_writer, "file");
	audio_pipeline_link(amrRecorder, (const char *[]) {"i2s", "Wamr", "file"}, 3);	
我使用上面这样的一段代码,是无法工作的,要么注释掉上面的WavEncoder,要么注释掉正面的AmrEncoder。请问要怎样才能在同一个程序里,可以录制Wav和AMR-WB两种格式?

Re: 如何使用pipeline录制两种不同的格式?

Posted: Thu May 23, 2019 4:03 am
by jason.mao
Hi

I2S element的数据是实时的,只要被下级element读走就没有了。根据你的描述,你参考 http_play_and_save_to_file example,把输入换成I2S,输出一路为WAV, 一路为AMR。