Convert WAV audio to FLV audio (1)

Source: Internet
Author: User

Based on the analysis of the FLV format in the previous article, the FLV format includes file header and file body. Therefore, you can define file header and previous tag size #0 as follows:

Const static unsigned char flvfilehdr [] = {
0x46, 0x4c, 0x56, 0 x, 0 x, 0 x, 0 x, 0 x, 0 x, 0 x, 0 x, 0x00
};

The file body consists of the tag header and tag data. Therefore, the tag header can be defined as follows:

Unsigned char flvtaghdr [] = {
0 x, 0 x, 0 x, 0 x, 0 x, 0 x, 0 x, 0 x, 0 x, 0 x, 0x00
};

Note: flvtaghdr [4] ~ Flvtaghdr [7] is used to calculate the time stamp of FLV audio data. A simple algorithm is required to calculate the time stamp of each audio data. For details, see the next article.

The tag body must be filled in according to the specific WAV audio data. Therefore, the first byte of the TAG body must include the specific parameter information of the audio data segment, which can be defined as follows:
Const static unsigned char tagdatafirstbyte [] = {
0x06
}; // The first four digits are 0, indicating the linear PCM and platform endian. The binary value is 00000110.

What follows each tag is the size of the previous tag. For example, if the size of the previous tag is 640, it can be defined as follows:
Const static unsigned char flvprevioustagsize [] = {
0x80
};

To be continued ~

PS: I wrote an article at the beginning. Please forgive me. If you have any questions or communication, you can add your YY: 301558660

Reprinted please indicate the source: zhujian blog, http://blog.csdn.net/linyanwen99/article/details/7515309

 

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.