output encoded duration every 60s,
improved adding new file when start time reached
正在显示
1 个修改的文件
包含
23 行增加
和
5 行删除
| @@ -1020,9 +1020,15 @@ int process_av_files(char * record_info, int piptype) | @@ -1020,9 +1020,15 @@ int process_av_files(char * record_info, int piptype) | ||
| 1020 | int64_t cur_time = 0; | 1020 | int64_t cur_time = 0; |
| 1021 | bool has_file = sorted_media.size()!=0; | 1021 | bool has_file = sorted_media.size()!=0; |
| 1022 | std::string out_media_file,first_media_file; | 1022 | std::string out_media_file,first_media_file; |
| 1023 | + | ||
| 1024 | + int64_t nextfile_start_time_ms; | ||
| 1025 | + int encode_loop_count = 0; | ||
| 1026 | + | ||
| 1023 | if (has_file) { | 1027 | if (has_file) { |
| 1024 | media_info info = sorted_media.front(); | 1028 | media_info info = sorted_media.front(); |
| 1025 | first_media_file = info.name; | 1029 | first_media_file = info.name; |
| 1030 | + nextfile_start_time_ms = info.start_time_ms; | ||
| 1031 | + | ||
| 1026 | out_media_file = get_outmedia_file_name(record_info); | 1032 | out_media_file = get_outmedia_file_name(record_info); |
| 1027 | printf("open output file:%s\n", out_media_file.c_str()); | 1033 | printf("open output file:%s\n", out_media_file.c_str()); |
| 1028 | int ret = videoTranscoder.open_output_file(out_media_file.c_str()); | 1034 | int ret = videoTranscoder.open_output_file(out_media_file.c_str()); |
| @@ -1035,26 +1041,38 @@ int process_av_files(char * record_info, int piptype) | @@ -1035,26 +1041,38 @@ int process_av_files(char * record_info, int piptype) | ||
| 1035 | } | 1041 | } |
| 1036 | } | 1042 | } |
| 1037 | 1043 | ||
| 1038 | - | ||
| 1039 | while (has_file){ | 1044 | while (has_file){ |
| 1040 | while (has_file){ | 1045 | while (has_file){ |
| 1041 | - media_info info = sorted_media.front(); | ||
| 1042 | - | ||
| 1043 | - if (info.start_time_ms - cur_time < MIN_TIME_INTERVAL) { | 1046 | + if (nextfile_start_time_ms - cur_time < MIN_TIME_INTERVAL) { |
| 1047 | + media_info info = sorted_media.front(); | ||
| 1044 | sorted_media.pop_front(); | 1048 | sorted_media.pop_front(); |
| 1045 | videoTranscoder.add(info); | 1049 | videoTranscoder.add(info); |
| 1050 | + has_file = sorted_media.size() != 0; | ||
| 1051 | + if (has_file) { | ||
| 1052 | + nextfile_start_time_ms = sorted_media.front().start_time_ms; | ||
| 1053 | + } | ||
| 1046 | } | 1054 | } |
| 1047 | else { | 1055 | else { |
| 1048 | break; | 1056 | break; |
| 1049 | } | 1057 | } |
| 1050 | - has_file = sorted_media.size()!=0; | ||
| 1051 | } | 1058 | } |
| 1052 | 1059 | ||
| 1053 | cur_time = videoTranscoder.transcode(); | 1060 | cur_time = videoTranscoder.transcode(); |
| 1061 | + | ||
| 1062 | + encode_loop_count++; | ||
| 1063 | + if (encode_loop_count == 1200) { | ||
| 1064 | + encode_loop_count = 0; | ||
| 1065 | + printf("\n encoded : %d seconds\n", cur_time / 1000); | ||
| 1066 | + } | ||
| 1054 | } | 1067 | } |
| 1055 | 1068 | ||
| 1056 | while (!videoTranscoder.all_processed()){ | 1069 | while (!videoTranscoder.all_processed()){ |
| 1057 | cur_time = videoTranscoder.transcode(); | 1070 | cur_time = videoTranscoder.transcode(); |
| 1071 | + encode_loop_count++; | ||
| 1072 | + if (encode_loop_count == 1200) { | ||
| 1073 | + encode_loop_count = 0; | ||
| 1074 | + printf("\n encoded : %d seconds\n", cur_time / 1000); | ||
| 1075 | + } | ||
| 1058 | } | 1076 | } |
| 1059 | 1077 | ||
| 1060 | videoTranscoder.close(); | 1078 | videoTranscoder.close(); |
-
请 注册 或 登录 后发表评论