MP4 file writes audio and video (using MPEG4IP)

Source: Internet
Author: User

Audio and video storage using the MPEG4IP library interface


Mp4writesample Write-Audio Video frame (requires precise control of timestamp, time stamp can use relative value, that is, the current frame timestamp minus the timestamp of the previous frame)

Mp4addh264videotrack adding H264 Track (timescale time factor parameter is important, based on the timestamp type definition of the video frame, 90000 (video standard sample timestamp) or (MS Timestamp))

Mp4addaudiotrack Add audio AAC track (timesacle time factor parameter set to "Ms Timestamp")



Audio AAC

The sampling frequency is the number of times per second that the acoustic amplitude sample is sampled when the analog sound waveform is digitized.

。 The frequency range of normal hearing is approximately between 20hz~20khz, according to the Nyquist sampling theory, in order to ensure that the sound is not distorted, the sampling frequency should be around 40kHz. Commonly used audio sampling frequency 8kHz, 11.025kHz, 22.05kHz, 16kHz, 37.8kHz, 44.1kHz, 48kHz, etc., if the use of higher sampling frequency, but also to achieve the sound quality of the DVD

When decoding AAC audio with a sampling rate of 44.1kHz, the decoding time of a frame must be controlled within 23.22 milliseconds.

Background knowledge:

(An AAC original frame contains 1024 samples and related data over a period of time)

Analysis:

1 AAC

Playback time of the audio frame = number of samples/sample frequency (in s) for the corresponding sample of an AAC frame

A frame of 1024 sample. Sample Rate Samplerate 44100KHz, 44,100 samples per second, so the playback time of the audio frame according to the formula = the number/sampling frequency of the sample sample corresponding to an AAC frame

The playback time of the current AAC frame is = 1024*1000000/44100= 22.32ms (in ms)

2 MP3

MP3 Each frame is 1152 bytes, then:

frame_duration = 1152 * 1000000/sample_rate

For example: Sample_rate = 44100HZ, the calculated length is 26.122ms, this is often heard mp3 each frame playback time fixed to 26ms.



Video H264

Video frame timestamp, two types of standard sample timestamp (millisecond timestamp *90) and millisecond timestamp (per frame rate, 1000/frame rate = Playback duration)



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.