diff --git a/conf/config.ini b/conf/config.ini index 21e268fd..8f566338 100644 --- a/conf/config.ini +++ b/conf/config.ini @@ -277,6 +277,8 @@ sampleMS=500 fastStart=0 #MP4点播(rtsp/rtmp/http-flv/ws-flv)是否循环播放文件 fileRepeat=0 +#MP4录制写文件格式是否采用fmp4,启用的话,断电未完成录制的文件也能正常打开 +enableFmp4=0 [rtmp] #rtmp必须在此时间内完成握手,否则服务器会断开链接,单位秒 diff --git a/src/Common/config.cpp b/src/Common/config.cpp index a72ea8da..a34ee84f 100644 --- a/src/Common/config.cpp +++ b/src/Common/config.cpp @@ -297,6 +297,7 @@ const string kSampleMS = RECORD_FIELD "sampleMS"; const string kFileBufSize = RECORD_FIELD "fileBufSize"; const string kFastStart = RECORD_FIELD "fastStart"; const string kFileRepeat = RECORD_FIELD "fileRepeat"; +const string kEnableFmp4 = RECORD_FIELD "enableFmp4"; static onceToken token([]() { mINI::Instance()[kAppName] = "record"; @@ -304,6 +305,7 @@ static onceToken token([]() { mINI::Instance()[kFileBufSize] = 64 * 1024; mINI::Instance()[kFastStart] = false; mINI::Instance()[kFileRepeat] = false; + mINI::Instance()[kEnableFmp4] = false; }); } // namespace Record diff --git a/src/Common/config.h b/src/Common/config.h index 16ef6303..98ab289c 100644 --- a/src/Common/config.h +++ b/src/Common/config.h @@ -354,6 +354,8 @@ extern const std::string kFileBufSize; extern const std::string kFastStart; // mp4文件是否重头循环读取 extern const std::string kFileRepeat; +// mp4录制文件是否采用fmp4格式 +extern const std::string kEnableFmp4; } // namespace Record ////////////HLS相关配置/////////// diff --git a/src/Record/MP4Muxer.cpp b/src/Record/MP4Muxer.cpp index 5d40be1d..46fda66f 100644 --- a/src/Record/MP4Muxer.cpp +++ b/src/Record/MP4Muxer.cpp @@ -31,7 +31,8 @@ void MP4Muxer::openMP4(const string &file) { MP4FileIO::Writer MP4Muxer::createWriter() { GET_CONFIG(bool, mp4FastStart, Record::kFastStart); - return _mp4_file->createWriter(mp4FastStart ? MOV_FLAG_FASTSTART : 0, false); + GET_CONFIG(bool, recordEnableFmp4, Record::kEnableFmp4); + return _mp4_file->createWriter(mp4FastStart ? MOV_FLAG_FASTSTART : 0, recordEnableFmp4); } void MP4Muxer::closeMP4() {