mp4录制完成后是否进行二次关键帧索引写入头部
This commit is contained in:
parent
7608aa6fa9
commit
f0deafd722
|
|
@ -117,6 +117,8 @@ fileSecond=3600
|
||||||
#mp4点播每次流化数据量,单位毫秒,
|
#mp4点播每次流化数据量,单位毫秒,
|
||||||
#减少该值可以让点播数据发送量更平滑,增大该值则更节省cpu资源
|
#减少该值可以让点播数据发送量更平滑,增大该值则更节省cpu资源
|
||||||
sampleMS=100
|
sampleMS=100
|
||||||
|
#mp4录制完成后是否进行二次关键帧索引写入头部
|
||||||
|
fastStart=0
|
||||||
#MP4点播(rtsp/rtmp/http-flv/ws-flv)是否循环播放文件
|
#MP4点播(rtsp/rtmp/http-flv/ws-flv)是否循环播放文件
|
||||||
fileRepeat=0
|
fileRepeat=0
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -271,6 +271,9 @@ const string kFilePath = RECORD_FIELD"filePath";
|
||||||
//mp4文件写缓存大小
|
//mp4文件写缓存大小
|
||||||
const string kFileBufSize = RECORD_FIELD"fileBufSize";
|
const string kFileBufSize = RECORD_FIELD"fileBufSize";
|
||||||
|
|
||||||
|
//mp4录制完成后是否进行二次关键帧索引写入头部
|
||||||
|
const string kFastStart = RECORD_FIELD"fastStart";
|
||||||
|
|
||||||
//mp4文件是否重头循环读取
|
//mp4文件是否重头循环读取
|
||||||
const string kFileRepeat = RECORD_FIELD"fileRepeat";
|
const string kFileRepeat = RECORD_FIELD"fileRepeat";
|
||||||
|
|
||||||
|
|
@ -280,6 +283,7 @@ onceToken token([](){
|
||||||
mINI::Instance()[kFileSecond] = RECORD_FILE_SECOND;
|
mINI::Instance()[kFileSecond] = RECORD_FILE_SECOND;
|
||||||
mINI::Instance()[kFilePath] = RECORD_FILE_PATH;
|
mINI::Instance()[kFilePath] = RECORD_FILE_PATH;
|
||||||
mINI::Instance()[kFileBufSize] = 64 * 1024;
|
mINI::Instance()[kFileBufSize] = 64 * 1024;
|
||||||
|
mINI::Instance()[kFastStart] = false;
|
||||||
mINI::Instance()[kFileRepeat] = false;
|
mINI::Instance()[kFileRepeat] = false;
|
||||||
},nullptr);
|
},nullptr);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -270,6 +270,8 @@ extern const string kFileSecond;
|
||||||
extern const string kFilePath;
|
extern const string kFilePath;
|
||||||
//mp4文件写缓存大小
|
//mp4文件写缓存大小
|
||||||
extern const string kFileBufSize;
|
extern const string kFileBufSize;
|
||||||
|
//mp4录制完成后是否进行二次关键帧索引写入头部
|
||||||
|
extern const string kFastStart;
|
||||||
//mp4文件是否重头循环读取
|
//mp4文件是否重头循环读取
|
||||||
extern const string kFileRepeat;
|
extern const string kFileRepeat;
|
||||||
} //namespace Record
|
} //namespace Record
|
||||||
|
|
|
||||||
|
|
@ -584,6 +584,7 @@ void HttpSession::Handle_Req_GET(int64_t &content_len) {
|
||||||
if (iRangeEnd == 0) {
|
if (iRangeEnd == 0) {
|
||||||
iRangeEnd = tFileStat.st_size - 1;
|
iRangeEnd = tFileStat.st_size - 1;
|
||||||
}
|
}
|
||||||
|
auto httpHeader = makeHttpHeader(bClose, iRangeEnd - iRangeStart + 1, get_mime_type(strFile.data()));
|
||||||
const char *pcHttpResult = NULL;
|
const char *pcHttpResult = NULL;
|
||||||
if (strRange.size() == 0) {
|
if (strRange.size() == 0) {
|
||||||
//全部下载
|
//全部下载
|
||||||
|
|
@ -592,9 +593,6 @@ void HttpSession::Handle_Req_GET(int64_t &content_len) {
|
||||||
//分节下载
|
//分节下载
|
||||||
pcHttpResult = "206 Partial Content";
|
pcHttpResult = "206 Partial Content";
|
||||||
fseek(pFilePtr.get(), iRangeStart, SEEK_SET);
|
fseek(pFilePtr.get(), iRangeStart, SEEK_SET);
|
||||||
}
|
|
||||||
auto httpHeader = makeHttpHeader(bClose, iRangeEnd - iRangeStart + 1, get_mime_type(strFile.data()));
|
|
||||||
if (strRange.size() != 0) {
|
|
||||||
//分节下载返回Content-Range头
|
//分节下载返回Content-Range头
|
||||||
httpHeader.emplace("Content-Range",StrPrinter<<"bytes " << iRangeStart << "-" << iRangeEnd << "/" << tFileStat.st_size<< endl);
|
httpHeader.emplace("Content-Range",StrPrinter<<"bytes " << iRangeStart << "-" << iRangeEnd << "/" << tFileStat.st_size<< endl);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,11 +33,11 @@
|
||||||
namespace mediakit{
|
namespace mediakit{
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
#define fseek64 _fseeki64
|
#define fseek64 _fseeki64
|
||||||
#define ftell64 _ftelli64
|
#define ftell64 _ftelli64
|
||||||
#else
|
#else
|
||||||
#define fseek64 fseek
|
#define fseek64 fseek
|
||||||
#define ftell64 ftell
|
#define ftell64 ftell
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void MP4MuxerBase::init(int flags) {
|
void MP4MuxerBase::init(int flags) {
|
||||||
|
|
@ -236,7 +236,9 @@ MP4MuxerFile::MP4MuxerFile(const char *file) {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
});
|
});
|
||||||
|
|
||||||
init(MOV_FLAG_FASTSTART);
|
GET_CONFIG(bool, mp4FastStart, Record::kFastStart);
|
||||||
|
|
||||||
|
init(mp4FastStart ? MOV_FLAG_FASTSTART : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
MP4MuxerFile::~MP4MuxerFile() {
|
MP4MuxerFile::~MP4MuxerFile() {
|
||||||
|
|
@ -254,15 +256,6 @@ int MP4MuxerFile::onWrite(const void *data, uint64_t bytes) {
|
||||||
return bytes == fwrite(data, 1, bytes, _file.get()) ? 0 : ferror(_file.get());
|
return bytes == fwrite(data, 1, bytes, _file.get()) ? 0 : ferror(_file.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
|
||||||
#define fseek64 _fseeki64
|
|
||||||
#define ftell64 _ftelli64
|
|
||||||
#else
|
|
||||||
#define fseek64 fseek
|
|
||||||
#define ftell64 ftell
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int MP4MuxerFile::onSeek(uint64_t offset) {
|
int MP4MuxerFile::onSeek(uint64_t offset) {
|
||||||
return fseek64(_file.get(), offset, SEEK_SET);
|
return fseek64(_file.get(), offset, SEEK_SET);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue