Commit 08299b66 by xia-chu

mp4录制新增追踪日志

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