mp4录制新增追踪日志

This commit is contained in:
xia-chu 2023-08-08 14:24:45 +08:00
parent aac8905619
commit 08299b6652

View File

@ -54,6 +54,7 @@ void MP4Recorder::createFile() {
try { try {
_muxer = std::make_shared<MP4Muxer>(); _muxer = std::make_shared<MP4Muxer>();
TraceL << "Open tmp mp4 file: " << full_path_tmp;
_muxer->openMP4(full_path_tmp); _muxer->openMP4(full_path_tmp);
for (auto &track :_tracks) { for (auto &track :_tracks) {
//添加track //添加track
@ -71,10 +72,13 @@ void MP4Recorder::asyncClose() {
auto full_path_tmp = _full_path_tmp; auto full_path_tmp = _full_path_tmp;
auto full_path = _full_path; auto full_path = _full_path;
auto info = _info; auto info = _info;
TraceL << "Start close tmp mp4 file: " << full_path_tmp;
WorkThreadPool::Instance().getExecutor()->async([muxer, full_path_tmp, full_path, info]() mutable { WorkThreadPool::Instance().getExecutor()->async([muxer, full_path_tmp, full_path, info]() mutable {
info.time_len = muxer->getDuration() / 1000.0f; info.time_len = muxer->getDuration() / 1000.0f;
// 关闭mp4可能非常耗时所以要放在后台线程执行 // 关闭mp4可能非常耗时所以要放在后台线程执行
TraceL << "Closing tmp mp4 file: " << full_path_tmp;
muxer->closeMP4(); muxer->closeMP4();
TraceL << "Closed tmp mp4 file: " << full_path_tmp;
if (!full_path_tmp.empty()) { if (!full_path_tmp.empty()) {
// 获取文件大小 // 获取文件大小
info.file_size = File::fileSize(full_path_tmp.data()); info.file_size = File::fileSize(full_path_tmp.data());
@ -86,6 +90,7 @@ void MP4Recorder::asyncClose() {
// 临时文件名改成正式文件名防止mp4未完成时被访问 // 临时文件名改成正式文件名防止mp4未完成时被访问
rename(full_path_tmp.data(), full_path.data()); rename(full_path_tmp.data(), full_path.data());
} }
TraceL << "Emit mp4 record event: " << full_path;
//触发mp4录制切片生成事件 //触发mp4录制切片生成事件
NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastRecordMP4, info); NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastRecordMP4, info);
}); });