diff --git a/src/Record/MP4Recorder.cpp b/src/Record/MP4Recorder.cpp index fd7c8955..4784fcda 100644 --- a/src/Record/MP4Recorder.cpp +++ b/src/Record/MP4Recorder.cpp @@ -41,16 +41,16 @@ MP4Recorder::~MP4Recorder() { void MP4Recorder::createFile() { closeFile(); auto date = getTimeStr("%Y-%m-%d"); - auto time = getTimeStr("%H-%M-%S"); - auto full_path_tmp = _folder_path + date + "/." + time + ".mp4"; - auto full_path = _folder_path + date + "/" + time + ".mp4"; + auto file_name = getTimeStr("%H-%M-%S") + "-" + std::to_string(_file_index++) + ".mp4"; + auto full_path = _folder_path + date + "/" + file_name; + auto full_path_tmp = _folder_path + date + "/." + file_name; /////record 业务逻辑////// _info.start_time = ::time(NULL); - _info.file_name = time + ".mp4"; + _info.file_name = file_name; _info.file_path = full_path; GET_CONFIG(string, appName, Record::kAppName); - _info.url = appName + "/" + _info.app + "/" + _info.stream + "/" + date + "/" + time + ".mp4"; + _info.url = appName + "/" + _info.app + "/" + _info.stream + "/" + date + "/" + file_name; try { _muxer = std::make_shared(); diff --git a/src/Record/MP4Recorder.h b/src/Record/MP4Recorder.h index 69175238..3e0c8013 100644 --- a/src/Record/MP4Recorder.h +++ b/src/Record/MP4Recorder.h @@ -57,13 +57,14 @@ private: private: bool _have_video = false; size_t _max_second; + uint64_t _last_dts = 0; + uint64_t _file_index = 0; std::string _folder_path; std::string _full_path; std::string _full_path_tmp; RecordInfo _info; MP4Muxer::Ptr _muxer; std::list _tracks; - uint64_t _last_dts = 0; }; #endif ///ENABLE_MP4