Noise suppression for audio recording and pcm+h264 encapsulation MP4

Source: Internet
Author: User
Tags fread

Nickname: Marine fish 1001 Date: October 25, 2014-October 31, 2014

1. Task completed this week: noise suppression for audio recording. pcm+h264 package MP4, last week for audio g711a, and the parameter is not ideal for synthesis.

2. Task not completed this week: Timestamp issue

3. Next week plan: Find timestamps related literature

4. Key technical Point Description:

Platform: Linux HI3515

Cross compiler: Arm-hisiv100nptl-linux


The noise suppression of this week's audio recording is improved by using Hi3515 's own audio recording source. When the original recording audio, no audio input still has a large noise, so in the document to find the method of audio suppression. Found a self-bringing function "Hi_mpi_ai_enableanr"

Syntax

Hi_s32 Hi_mpi_ai_enableanr (Audio_dev audiodevid, Ai_chn aichn);

Find a call to this function in the source code:

Hi_s32 Sample_comm_audio_startai (Audio_dev aidevid, Hi_s32 s32aichncnt,aio_attr_s *pstAioAttr, HI_BOOL bAnrEn, AUDIO_ resample_attr_s *pstairesmpattr)

{

if (hi_true = = Banren)
{
if (Hi_mpi_ai_enableanr (Aidevid, i))
{
printf ("%s:hi_mpi_ai_enableanr (%d,%d) failed with% #x \ n", __function__,\
Aidevid, I, S32ret);
return hi_failure;
}
}

}

The Banren parameter is the input parameter of the function, so the call to find this function can turn on AI noise suppression.

Finally found the place to call S32ret = Sample_comm_audio_startai (Aidev, s32aichncnt, Pstaioattr, Gs_baianr, gs_pstairesmpattr);

That is, GS_BAIANR determines whether to turn on noise suppression. Continue to find

static Hi_bool Gs_baianr = Hi_false;

Discovery is not open, so decisively changed to Gs_baianr = Hi_true;

Run after compiling, recording, but prompt error.

HI_MPI_AI_ENABLEANR [line]:971 [info]:aidev:0, ANR should be or poin

After translation is: ANR should be 80 or every FRM160 point

Find code find

#define SAMPLE_AUDIO_PTNUMPERFRM 320

Staioattr.u32ptnumperfrm = sample_audio_ptnumperfrm;

That is, the code will be the length of each frame of audio positioning 320, so change to 160 test, run, can be normal recording.

Of course, because the synthesis of MP4 program is also used 320, that also to be changed to 160, the generated MP4 and the original no de-noising contrast, although still have a little bit of noise, but obviously a lot smaller.

(The source code that needs to be recorded can be downloaded from my download channel) http://download.csdn.net/detail/sbadhwm/8106601




pcm+h264 Package MP4 Program source code is to refer to http://blog.csdn.net/skdkjzz/article/details/40393891 this article, as long as the g711a to the PCM part of the line removed

where the main function

while (((Gbytesread = Fread (Pbg711abuffer, 1, 164, Joseph_aac_config->fpin)) && (>0 < 312)) Switch

while ((Npcmread = Fread (Pbpcmtmpbuffer, 1, Joseph_aac_config->fpin) >0) && (Nvideoret < 312))

 pPCM = pbG711ABuffer + 4;            memset (pbpcmtmpbuffer, 0, pcmsize);            memset (joseph_aac_config->pbaacbuffer, 0, joseph_aac_config->nmaxoutputbytes);                         /*g711 to pcm*/           if (npcmread  = g711a_decode (pbpcmtmpbuffer,  &pcmsize,  ppcm,  gbytesread-4))  < 0)            {                printf (" g711a -> pcm  fail\ n ");               break;           } 
This section does not need to be deleted directly.

if (Npcmread < 320) Change to if (Npcmread < 160)

Then delete the array, function, and definition that you don't need to use before. Compile and run.

The corresponding program will not be sent, because it is someone else that take to change, want to go to the great god that download.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.