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)