mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-25 20:27:34 +08:00
mp4录制文件名添加索引号,防止一秒内生成多个同名文件导致覆盖 (#2542)
实测发现 如果在点播推流时 如果切片大小设置比较小 一秒钟可能产生多个mp4切片 以前切片名称粒度最小为一秒 所以会存在文件覆盖问题
This commit is contained in:
parent
64b8079ac1
commit
d3f1c2fab1
@ -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<MP4Muxer>();
|
||||
|
@ -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<Track::Ptr> _tracks;
|
||||
uint64_t _last_dts = 0;
|
||||
};
|
||||
|
||||
#endif ///ENABLE_MP4
|
||||
|
Loading…
Reference in New Issue
Block a user