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
HLS and Http Live Streaming are protocols for real-time streaming defined by Apple. HLS is implemented based on the HTTP protocol. The transmission content includes two parts, one is the M3U8 description file, and the other is the TS media file.
1. M3U8 file
The media file is described in text, which is composed of a series of tags.
#EXTM3U
#EXT-X-TARGETDURATION:5
#EXTINF:5,
./0.ts
#EXTINF:5,
./1.ts
#EXTM3U: The first line of each M3U8 file must be this tag.
#EXT-X-TARGETDURATION: Specify the maximum media segment time length (seconds). The time length specified in #EXTINF must be less than or equal to this maximum value. This value can only appear once.
#EXTINF: Describe the length of a single media file. Media files follow, such as ./0.ts
It can be distributed by HTTP on iOS device and mac. The playlist standard is the m3u8 file extended by m3u, and the media file is MPEG2-TS or AAC file (audio only).
There are two application scenarios for m3u8 files:
Multi-rate adaptation stream,
#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1280000
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2560000
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=7680000
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=65000,CODECS="mp4a.40.5"
http://example.com/audio-only.m3u8
Single rate adaptation stream
#EXTM3U
#EXT-X-TARGETDURATION:5220
#EXTINF:5220,
http://media.example.com/entire.ts
#EXT-X-ENDLIST
The International Standards Organization defines this rfc doc:
http://tools.ietf.org/html/draft-pantos-http-live-streaming-06
The m3u8 file is an extension of the m3u file. The extended keywords are defined in the rfc:
among them:
#EXT-X-TARGETDURATION
Define the maximum duration of each TS.
#EXT-X-MEDIA-SEQUENCE
Define the serial number of the first file in the current m3u8 file. Each ts file has a fixed and unique serial number in the m3u8 file. The serial number is used to switch the code rate for alignment during MBR.
#EXT-X-KEY
Define the encryption method and the url of the key file, used to obtain the 16bytes key file to decode the ts file.
Attributes:
METHOD
URL
#EXT-X-PROGRAM-DATE-TIME
Absolute time of the first file
#EXT-X-ALLOW-CACHE
Whether to allow cache.
#EXT-X-ENDLIST
Indicates the end of the m3u8 file. Live m3u8 does not have this tag.
#EXT-X-STREAM-INF
Attributes:
BANDWIDTH specifies the bit rate
PROGRAM-ID unique ID
CODECS specifies the encoding type of the stream
#EXT-X-DISCONTINUITY
When the tag is encountered, the following attributes have changed:
file format
number and type of tracks
encoding parameters
encoding sequence
timestamp sequence
#EXT-X-VERSION This attribute can be used or not, you can have none
M3U8 is divided into top-level M3U8 and second-level M3U8. The top-level M3U8 is mainly used for multi-rate adaptation. The second-level M3U8 is the real slice file.
By default, the client will first select the request with the highest bitrate. If it finds that the bitrate cannot be reached, it will request a stream with a low bitrate
A top-level M3U8 file in actual use is as follows:
#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=201273221265,BANDWIDTH=358400
11.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=201273221265,BANDWIDTH=972800
22.m3u8
The top-level M3U8 file above defines two second-level files, 11.m3u8 and 22.m3u8, and the client will select one of them to get its content.
The content of the secondary M3U8 file is as follows:
#EXTM3U
#EXT-X-VERSION:1
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:3,
1-4.ts
#EXTINF:8,
1-6.ts
#EXTINF:8,
1-8.ts
#EXTINF:8,
1-10.ts
#EXTINF:8,
1-12.ts
#EXTINF:8,
1-14.ts
#EXTINF:8,
1-16.ts
#EXTINF:9,
1-18.ts
#EXTINF:6,
1-20.ts
#EXTINF:8,
1-22.ts
#EXTINF:9,
1-24.ts
#EXTINF:3,
1-26.ts
#EXT-X-ENDLIST
After the client gets the above secondary M3U8 file, it will continue to request the file inside, and then it can be played.
The above is about the on-demand situation and the situation of live broadcast, there will be attributes in the M3U8 file to tell it is live, and the client will periodically request new M3U8 files.
//When HLS realizes on-demand and live broadcast, the difference of M3U8 file
1. Problem description
Recently I did a transcoded slice playback test, using HLS (HTTP Live Streaming) to do the live broadcast. Each TS segmentation time is 10s, and the following live m3u8 files are generated according to the TS segmentation files
Copy code
#EXTM3U
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-TARGETDURATION:10
#EXTINF:10
hls/1.ts
#EXTINF:10
hls/2.ts
#EXTINF:10
hls/3.ts
#EXTINF:10
hls/4.ts
#EXTINF:10
hls/5.ts
#EXTINF:10
hls/6.ts
#EXTINF:10
hls/7.ts
#EXTINF:10
hls/8.ts
#EXTINF:10
hls/9.ts
#EXTINF:10
hls/10.ts
Copy code
Save the above m3u8 file as live.m3u8, put it in the Apache document directory, and play the following URL with VLC:
http://localhost/live.m3u8
The test found that the first file to start playing was not 1.ts. After several tests, it was found that:
As long as there are more than three files in the list, the last three files in the list are always played
2. Problem solving
It's very sad that after searching the Internet, I didn't find any effective information. A buddy encountered the same situation, did he share his experience after solving it?
After consulting with a colleague, the colleague said that it is possible because the live m3u8 file list needs to be updated in real time. If we do a test, we can add #EXT-X-ENDLIST at the end first. This method has been tested It works, but this is no longer live m3u8 mode
After searching the Internet again, I confirmed that I finally found a live m3u8 description
Live Playlist (Sliding Window)
For live sessions, the index file is updated by removing media URIs from the file as new media files are created and made available.
Important: The EXT-X-ENDLIST tag is not present in the Live playlist, indicating that new media files will be added to the index file as they become available.
See Listing 3 for an example live playlist as it would appear at the beginning of a session.
Listing 3 Live Playlist at the beginning of a session.
Copy code
#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:1
#EXTINF:10,
fileSequence1.ts
#EXTINF:10,
fileSequence2.ts
#EXTINF:10,
fileSequence3.ts
#EXTINF:10,
fileSequence4.ts
#EXTINF:10,
fileSequence5.ts
Copy code
The EXT-X-MEDIA-SEQUENCE tag value MUST be incremented by 1 for every media URI that is removed from the playlist file. Media URIsmust be removed from the playlist file in the order that they appear in the playlist. The updated index file presents a moving window into a continuous stream. This type of session is suitable for continuous broadcasts.
Here's the same playlist after it has been updated with new media URIs:
Listing 4 Live Playlist after updating the media URIs.
Copy code
#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:2
#EXTINF:10,
fileSequence2.ts
#EXTINF:10,
fileSequence3.ts
#EXTINF:10,
fileSequence4.ts
#EXTINF:10,
fileSequence5.ts
#EXTINF:10,
fileSequence6.ts
Copy code
3.live m3u8 update rules
The list of live m3u8 files needs to be updated continuously, update rules:
Remove the top (think played) file in a file playlist
Continuously update the EXT-X-MEDIA-SEQUENCE tag, increment by 1
4. Experiment
Write a small program to generate live m3u8 for testing
Usage:
m3u8_gen.exe start_num list_count duration filename.m3u8 [prefix]
Usage example:
m3u8_gen.exe 1 3 10 live.m3u8 hls/
Generate live.m3u8 file as
Copy code
#EXTM3U
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-TARGETDURATION:10
#EXTINF:10
hls/1.ts
#EXTINF:10
hls/2.ts
#EXTINF:10
hls/3.ts
Copy code
Write a BAT script to update the live.m3u8 file every 10s
Copy code
@echo off
f
|
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