FMUSER Wirless Transmit Video And Audio More Easier !
es.fmuser.org
it.fmuser.org
fr.fmuser.org
de.fmuser.org
af.fmuser.org ->Afrikaans
sq.fmuser.org ->Albanian
ar.fmuser.org ->Arabic
hy.fmuser.org ->Armenian
az.fmuser.org ->Azerbaijani
eu.fmuser.org ->Basque
be.fmuser.org ->Belarusian
bg.fmuser.org ->Bulgarian
ca.fmuser.org ->Catalan
zh-CN.fmuser.org ->Chinese (Simplified)
zh-TW.fmuser.org ->Chinese (Traditional)
hr.fmuser.org ->Croatian
cs.fmuser.org ->Czech
da.fmuser.org ->Danish
nl.fmuser.org ->Dutch
et.fmuser.org ->Estonian
tl.fmuser.org ->Filipino
fi.fmuser.org ->Finnish
fr.fmuser.org ->French
gl.fmuser.org ->Galician
ka.fmuser.org ->Georgian
de.fmuser.org ->German
el.fmuser.org ->Greek
ht.fmuser.org ->Haitian Creole
iw.fmuser.org ->Hebrew
hi.fmuser.org ->Hindi
hu.fmuser.org ->Hungarian
is.fmuser.org ->Icelandic
id.fmuser.org ->Indonesian
ga.fmuser.org ->Irish
it.fmuser.org ->Italian
ja.fmuser.org ->Japanese
ko.fmuser.org ->Korean
lv.fmuser.org ->Latvian
lt.fmuser.org ->Lithuanian
mk.fmuser.org ->Macedonian
ms.fmuser.org ->Malay
mt.fmuser.org ->Maltese
no.fmuser.org ->Norwegian
fa.fmuser.org ->Persian
pl.fmuser.org ->Polish
pt.fmuser.org ->Portuguese
ro.fmuser.org ->Romanian
ru.fmuser.org ->Russian
sr.fmuser.org ->Serbian
sk.fmuser.org ->Slovak
sl.fmuser.org ->Slovenian
es.fmuser.org ->Spanish
sw.fmuser.org ->Swahili
sv.fmuser.org ->Swedish
th.fmuser.org ->Thai
tr.fmuser.org ->Turkish
uk.fmuser.org ->Ukrainian
ur.fmuser.org ->Urdu
vi.fmuser.org ->Vietnamese
cy.fmuser.org ->Welsh
yi.fmuser.org ->Yiddish
A few days ago, I spent some time to study HTTP live streaming (HLS) technology and implement an HLS encoder, hlsliveencoder, written in C + +. Its function is to capture the camera and microphone, real-time H.264 video coding and aac audio coding, and according to the HLS protocol specification, generate segmented standard TS file and m3u8 index file. Through my hlsliveencoder and the third-party HTTP server (such as nginx), we successfully realized the live streaming of HTTP and passed the test on the iPhone. I will write some of the gains here.
1. Analysis of HLS Technology
HTTP live streaming (HLS) is a streaming media transport protocol based on HTTP implemented by Apple Inc., which can realize live and on-demand streaming media. It is mainly used in IOS system to provide audio and video live and on-demand solutions for IOS devices (such as iPhone and iPad). HLS on demand is basically a common segmented HTTP on demand. The difference is that its segments are very small. In order to realize HLS on demand, the key is to segment media files. At present, there are many open source tools that can be used. I will not discuss it here, just talk about HLS live broadcast technology.
Compared with the common live streaming protocols, such as RTMP protocol, RTSP protocol, MMS protocol and so on, the biggest difference of HLS live streaming is that the live client does not get a complete data stream. HLS protocol stores the live data stream as continuous, short-term and long media files (mpeg-ts format) on the server side, while the client side continuously downloads and plays these small files, because the server side always generates new small files from the latest live data, so that the client side only needs to play the files obtained from the server in order to realize the live. It can be seen that HLS basically realizes live broadcasting by means of VOD technology. Because the data is transmitted through HTTP protocol, there is no need to consider the problem of firewall or proxy, and the time of segmenting files is very short. The client can quickly select and switch the code rate to adapt to the playback under different bandwidth conditions. However, due to the technical characteristics of HLS, its delay is always higher than that of ordinary live streaming protocol.
According to the above understanding, to achieve HTTP live streaming live, we need to study and implement the following key technologies.
(1) Collect the data of video source and audio source
(2) The original data is encoded by H264 and AAC
(3) Video and audio data are packaged as mpeg-ts packets
(4) HLS segmentation generation strategy and m3u8 index file
2. HTTP transport protocol
Among them, the first and second points have been mentioned in my previous article, and the last point is that we can use the existing HTTP server, so the implementation of the third and fourth points is the key.
(1) Program framework and Implementation
Through the above analysis, the logic and process of HLS live encoder are basically clear: start the audio and video coding thread respectively, realize the audio and video acquisition through DirectShow (or other) technology, and then call libx264 and libfaac respectively for video and audio coding. After the two encoding threads encode the audio and video data in real time, they store it in a segment file of mpeg-ts format according to the customized partition strategy. When a segment file is stored, the m3u8 index file is updated. As shown in the figure below:
In the figure above, after receiving the video and audio data, hlsliveencoder needs to first determine whether the current partition should end, and create a new partition to continue the continuous generation of TS partition. It should be noted that the new fragmentation should start from the key frame to prevent the player from decoding failure. The core code is as follows:
The interface of tsmuxer is also relatively simple.
(2) HLS segment generation strategy and m3u8
① Segmentation strategy
The segmentation strategy of HLS is basically recommended to split every 10 seconds. Of course, the specific time should be marked according to the actual length of the split
Generally speaking, for the sake of cache and other reasons, the latest three fragment addresses are kept in the index file and updated in the form of "sliding window".
② Introduction of m3u8 file
M3u8 is the index file of HTTP live streaming. M3u8 can be regarded as. M3U format file basically, the difference is that m3u8 file uses UTF-8 character encoding.
Copy code
#Extm3u M3U file header, must be placed in the first line
#Serial number of the first TS segment of ext-x-media-sequence
#Ext-x-targetduration the maximum duration of each TS segment
#Does ext-x-allow-cache allow cache
#End of ext-x-endlist m3u8 file
#Extinf extra info, the information of split ts, such as duration, bandwidth, etc
|
Enter email to get a surprise
es.fmuser.org
it.fmuser.org
fr.fmuser.org
de.fmuser.org
af.fmuser.org ->Afrikaans
sq.fmuser.org ->Albanian
ar.fmuser.org ->Arabic
hy.fmuser.org ->Armenian
az.fmuser.org ->Azerbaijani
eu.fmuser.org ->Basque
be.fmuser.org ->Belarusian
bg.fmuser.org ->Bulgarian
ca.fmuser.org ->Catalan
zh-CN.fmuser.org ->Chinese (Simplified)
zh-TW.fmuser.org ->Chinese (Traditional)
hr.fmuser.org ->Croatian
cs.fmuser.org ->Czech
da.fmuser.org ->Danish
nl.fmuser.org ->Dutch
et.fmuser.org ->Estonian
tl.fmuser.org ->Filipino
fi.fmuser.org ->Finnish
fr.fmuser.org ->French
gl.fmuser.org ->Galician
ka.fmuser.org ->Georgian
de.fmuser.org ->German
el.fmuser.org ->Greek
ht.fmuser.org ->Haitian Creole
iw.fmuser.org ->Hebrew
hi.fmuser.org ->Hindi
hu.fmuser.org ->Hungarian
is.fmuser.org ->Icelandic
id.fmuser.org ->Indonesian
ga.fmuser.org ->Irish
it.fmuser.org ->Italian
ja.fmuser.org ->Japanese
ko.fmuser.org ->Korean
lv.fmuser.org ->Latvian
lt.fmuser.org ->Lithuanian
mk.fmuser.org ->Macedonian
ms.fmuser.org ->Malay
mt.fmuser.org ->Maltese
no.fmuser.org ->Norwegian
fa.fmuser.org ->Persian
pl.fmuser.org ->Polish
pt.fmuser.org ->Portuguese
ro.fmuser.org ->Romanian
ru.fmuser.org ->Russian
sr.fmuser.org ->Serbian
sk.fmuser.org ->Slovak
sl.fmuser.org ->Slovenian
es.fmuser.org ->Spanish
sw.fmuser.org ->Swahili
sv.fmuser.org ->Swedish
th.fmuser.org ->Thai
tr.fmuser.org ->Turkish
uk.fmuser.org ->Ukrainian
ur.fmuser.org ->Urdu
vi.fmuser.org ->Vietnamese
cy.fmuser.org ->Welsh
yi.fmuser.org ->Yiddish
FMUSER Wirless Transmit Video And Audio More Easier !
Contact
Address:
No.305 Room HuiLan Building No.273 Huanpu Road Guangzhou China 510620
Categories
Newsletter