mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 12:37:09 +08:00
优化hls
This commit is contained in:
parent
4bb9bef320
commit
237a7d71f3
@ -269,11 +269,11 @@ namespace Hls {
|
|||||||
#define HLS_FIELD "hls."
|
#define HLS_FIELD "hls."
|
||||||
|
|
||||||
//HLS切片时长,单位秒
|
//HLS切片时长,单位秒
|
||||||
#define HLS_SEGMENT_DURATION 0
|
#define HLS_SEGMENT_DURATION 3
|
||||||
const char kSegmentDuration[] = HLS_FIELD"segDur";
|
const char kSegmentDuration[] = HLS_FIELD"segDur";
|
||||||
|
|
||||||
//HLS切片个数
|
//HLS切片个数
|
||||||
#define HLS_SEGMENT_NUM 1
|
#define HLS_SEGMENT_NUM 3
|
||||||
const char kSegmentNum[] = HLS_FIELD"segNum";
|
const char kSegmentNum[] = HLS_FIELD"segNum";
|
||||||
|
|
||||||
//HLS文件写缓存大小
|
//HLS文件写缓存大小
|
||||||
|
@ -89,20 +89,20 @@ bool HLSMaker::write_index_file(int iFirstSegment, unsigned int uiLastSegment, i
|
|||||||
if (m_ui32NumSegments) {
|
if (m_ui32NumSegments) {
|
||||||
snprintf(acWriteBuf,
|
snprintf(acWriteBuf,
|
||||||
sizeof(acWriteBuf),
|
sizeof(acWriteBuf),
|
||||||
"#EXTM3U\n"
|
"#EXTM3U\r\n"
|
||||||
"#EXT-X-VERSION:3\n"
|
"#EXT-X-VERSION:3\r\n"
|
||||||
"#EXT-X-ALLOW-CACHE:NO\n"
|
"#EXT-X-ALLOW-CACHE:NO\r\n"
|
||||||
"#EXT-X-TARGETDURATION:%u\n"
|
"#EXT-X-TARGETDURATION:%u\r\n"
|
||||||
"#EXT-X-MEDIA-SEQUENCE:%u\n",
|
"#EXT-X-MEDIA-SEQUENCE:%u\r\n",
|
||||||
maxSegmentDuration + 1,
|
maxSegmentDuration + 1,
|
||||||
iFirstSegment);
|
iFirstSegment);
|
||||||
} else {
|
} else {
|
||||||
snprintf(acWriteBuf,
|
snprintf(acWriteBuf,
|
||||||
sizeof(acWriteBuf),
|
sizeof(acWriteBuf),
|
||||||
"#EXTM3U\n"
|
"#EXTM3U\r\n"
|
||||||
"#EXT-X-VERSION:3\n"
|
"#EXT-X-VERSION:3\r\n"
|
||||||
"#EXT-X-ALLOW-CACHE:NO\n"
|
"#EXT-X-ALLOW-CACHE:NO\r\n"
|
||||||
"#EXT-X-TARGETDURATION:%u\n",
|
"#EXT-X-TARGETDURATION:%u\r\n",
|
||||||
maxSegmentDuration);
|
maxSegmentDuration);
|
||||||
}
|
}
|
||||||
if (fwrite(acWriteBuf, strlen(acWriteBuf), 1, pM3u8File.get()) != 1) {
|
if (fwrite(acWriteBuf, strlen(acWriteBuf), 1, pM3u8File.get()) != 1) {
|
||||||
@ -113,7 +113,7 @@ bool HLSMaker::write_index_file(int iFirstSegment, unsigned int uiLastSegment, i
|
|||||||
for (unsigned int i = iFirstSegment; i < uiLastSegment; i++) {
|
for (unsigned int i = iFirstSegment; i < uiLastSegment; i++) {
|
||||||
snprintf(acWriteBuf,
|
snprintf(acWriteBuf,
|
||||||
sizeof(acWriteBuf),
|
sizeof(acWriteBuf),
|
||||||
"#EXTINF:%.3f,\n%s-%u.ts\n",
|
"#EXTINF:%.3f,\r\n%s-%u.ts\r\n",
|
||||||
m_iDurations[i-iFirstSegment]/1000.0,
|
m_iDurations[i-iFirstSegment]/1000.0,
|
||||||
m_strFileName.c_str(),
|
m_strFileName.c_str(),
|
||||||
i);
|
i);
|
||||||
@ -124,7 +124,7 @@ bool HLSMaker::write_index_file(int iFirstSegment, unsigned int uiLastSegment, i
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (iEnd) {
|
if (iEnd) {
|
||||||
snprintf(acWriteBuf, sizeof(acWriteBuf), "#EXT-X-ENDLIST\n");
|
snprintf(acWriteBuf, sizeof(acWriteBuf), "#EXT-X-ENDLIST\r\n");
|
||||||
if (fwrite(acWriteBuf, strlen(acWriteBuf), 1, pM3u8File.get()) != 1) {
|
if (fwrite(acWriteBuf, strlen(acWriteBuf), 1, pM3u8File.get()) != 1) {
|
||||||
WarnL << "Could not write last file and endlist tag to m3u8 index file";
|
WarnL << "Could not write last file and endlist tag to m3u8 index file";
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user