adjust the start time of files read from recordinfo,
because the time offset is not begin from the recordinfo file,but maybe from the last recordinfo file with same uid.
正在显示
3 个修改的文件
包含
22 行增加
和
13 行删除
| @@ -55,7 +55,7 @@ int CAVTranscoder::add(media_info & info) | @@ -55,7 +55,7 @@ int CAVTranscoder::add(media_info & info) | ||
| 55 | if (_start_time == INT64_MAX) { | 55 | if (_start_time == INT64_MAX) { |
| 56 | _start_time = info.start_time_ms; | 56 | _start_time = info.start_time_ms; |
| 57 | _cur_v_time = _start_time; | 57 | _cur_v_time = _start_time; |
| 58 | - _cur_a_time = _start_time; | 58 | + _cur_a_time = (double)_start_time; |
| 59 | } | 59 | } |
| 60 | vector < CAVDecoder *>::iterator it = _decoders.begin(); | 60 | vector < CAVDecoder *>::iterator it = _decoders.begin(); |
| 61 | for (; it != _decoders.end(); it++) { | 61 | for (; it != _decoders.end(); it++) { |
| @@ -139,7 +139,7 @@ int CAVTranscoder::close() | @@ -139,7 +139,7 @@ int CAVTranscoder::close() | ||
| 139 | #if USE_AACBSF | 139 | #if USE_AACBSF |
| 140 | av_bitstream_filter_close(aacbsfc); | 140 | av_bitstream_filter_close(aacbsfc); |
| 141 | #endif | 141 | #endif |
| 142 | - int i; | 142 | + unsigned int i; |
| 143 | for (i = 0; i<2; i++) | 143 | for (i = 0; i<2; i++) |
| 144 | { | 144 | { |
| 145 | if (_ofmt_ctx && _ofmt_ctx->nb_streams > i && _ofmt_ctx->streams[i] && _ofmt_ctx->streams[i]->codec) | 145 | if (_ofmt_ctx && _ofmt_ctx->nb_streams > i && _ofmt_ctx->streams[i] && _ofmt_ctx->streams[i]->codec) |
| @@ -205,7 +205,7 @@ int CAVTranscoder::open_output_file(const char *filename) | @@ -205,7 +205,7 @@ int CAVTranscoder::open_output_file(const char *filename) | ||
| 205 | enc_ctx->max_qdiff = 4; | 205 | enc_ctx->max_qdiff = 4; |
| 206 | enc_ctx->qmin = 10; | 206 | enc_ctx->qmin = 10; |
| 207 | enc_ctx->qmax = 30; | 207 | enc_ctx->qmax = 30; |
| 208 | - enc_ctx->qcompress = 0.6; | 208 | + enc_ctx->qcompress = 0.6f; |
| 209 | enc_ctx->framerate.den = 20; | 209 | enc_ctx->framerate.den = 20; |
| 210 | enc_ctx->framerate.num = 1; | 210 | enc_ctx->framerate.num = 1; |
| 211 | 211 | ||
| @@ -289,7 +289,7 @@ int CAVTranscoder::open_output_file(const char *filename) | @@ -289,7 +289,7 @@ int CAVTranscoder::open_output_file(const char *filename) | ||
| 289 | for (; it != decoders_got_frame.end(); it++) { | 289 | for (; it != decoders_got_frame.end(); it++) { |
| 290 | AVFrame * pFrame = (*it)->_cur_a_frame; | 290 | AVFrame * pFrame = (*it)->_cur_a_frame; |
| 291 | if (pFrame) { | 291 | if (pFrame) { |
| 292 | -#if LIBAVCODEC_VERSION_MAJOR < 57 | 292 | +#ifdef PCM_USING_FLTP_FOR_AAC_ENCODE |
| 293 | int16_t * psrc = (int16_t *)pFrame->extended_data[0]; | 293 | int16_t * psrc = (int16_t *)pFrame->extended_data[0]; |
| 294 | int16_t * pdst = (int16_t *)pDstFrame->extended_data[0]; | 294 | int16_t * pdst = (int16_t *)pDstFrame->extended_data[0]; |
| 295 | #else | 295 | #else |
| @@ -319,7 +319,7 @@ int CAVTranscoder::open_output_file(const char *filename) | @@ -319,7 +319,7 @@ int CAVTranscoder::open_output_file(const char *filename) | ||
| 319 | int CAVTranscoder::mix_and_output_one2many_vframe(vector<CAVDecoder *> & decoders_got_frame) | 319 | int CAVTranscoder::mix_and_output_one2many_vframe(vector<CAVDecoder *> & decoders_got_frame) |
| 320 | { | 320 | { |
| 321 | int idxTeacher = -1; | 321 | int idxTeacher = -1; |
| 322 | - for (int i = 0; i < decoders_got_frame.size(); i++){ | 322 | + for (unsigned int i = 0; i < decoders_got_frame.size(); i++){ |
| 323 | if (decoders_got_frame[i]->_media_role == mr_teacher) { | 323 | if (decoders_got_frame[i]->_media_role == mr_teacher) { |
| 324 | idxTeacher = i; | 324 | idxTeacher = i; |
| 325 | break; | 325 | break; |
| @@ -349,7 +349,7 @@ int CAVTranscoder::open_output_file(const char *filename) | @@ -349,7 +349,7 @@ int CAVTranscoder::open_output_file(const char *filename) | ||
| 349 | } | 349 | } |
| 350 | 350 | ||
| 351 | int imageIdx = 0; | 351 | int imageIdx = 0; |
| 352 | - for (int i = 0; i < decoders_got_frame.size(); i++){ | 352 | + for (unsigned int i = 0; i < decoders_got_frame.size(); i++){ |
| 353 | if (i != idxTeacher) { | 353 | if (i != idxTeacher) { |
| 354 | //scale eacher frame | 354 | //scale eacher frame |
| 355 | CAVDecoder * pDecoder = decoders_got_frame[i]; | 355 | CAVDecoder * pDecoder = decoders_got_frame[i]; |
| @@ -83,6 +83,9 @@ typedef struct FilteringContext { | @@ -83,6 +83,9 @@ typedef struct FilteringContext { | ||
| 83 | #define VFRAME_DURATION_MS 50 | 83 | #define VFRAME_DURATION_MS 50 |
| 84 | 84 | ||
| 85 | #if LIBAVCODEC_VERSION_MAJOR < 57 | 85 | #if LIBAVCODEC_VERSION_MAJOR < 57 |
| 86 | +#define PCM_USING_FLTP_FOR_AAC_ENCODE | ||
| 87 | +#endif | ||
| 88 | +#ifdef PCM_USING_FLTP_FOR_AAC_ENCODE | ||
| 86 | #define PCM_FORMAT_FOR_AAC_ENCODE AV_SAMPLE_FMT_S16 | 89 | #define PCM_FORMAT_FOR_AAC_ENCODE AV_SAMPLE_FMT_S16 |
| 87 | #else | 90 | #else |
| 88 | #define PCM_FORMAT_FOR_AAC_ENCODE AV_SAMPLE_FMT_FLTP | 91 | #define PCM_FORMAT_FOR_AAC_ENCODE AV_SAMPLE_FMT_FLTP |
| @@ -126,7 +126,7 @@ void addinfo(float t, string name, bool bstart,media_role role,unsigned int uid) | @@ -126,7 +126,7 @@ void addinfo(float t, string name, bool bstart,media_role role,unsigned int uid) | ||
| 126 | } | 126 | } |
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | -void addinfo(const char * t, const char * name, const char * rotation){ | 129 | +void addinfo(const char * name, const char * rotation){ |
| 130 | int i = 0; | 130 | int i = 0; |
| 131 | for (; i < media_files.size(); i++) { | 131 | for (; i < media_files.size(); i++) { |
| 132 | if (media_files[i].name == name) { | 132 | if (media_files[i].name == name) { |
| @@ -739,14 +739,15 @@ void save_out_info(float start_time, char * outputfile) | @@ -739,14 +739,15 @@ void save_out_info(float start_time, char * outputfile) | ||
| 739 | } | 739 | } |
| 740 | } | 740 | } |
| 741 | 741 | ||
| 742 | -// parse the filename like 4165000_20180203013327202.aac | 742 | + |
| 743 | #define get_sub_str_to_x(x , source, len, result) strncpy(x, source, len); x[len] = 0; source += len; result = atoi(x); | 743 | #define get_sub_str_to_x(x , source, len, result) strncpy(x, source, len); x[len] = 0; source += len; result = atoi(x); |
| 744 | time_t time_sec_1970_base = 0; | 744 | time_t time_sec_1970_base = 0; |
| 745 | float get_uid_start_time_from_filename(const char * filename, unsigned int &uid) | 745 | float get_uid_start_time_from_filename(const char * filename, unsigned int &uid) |
| 746 | { | 746 | { |
| 747 | int year, month, day, hour, min, sec, minsec; | 747 | int year, month, day, hour, min, sec, minsec; |
| 748 | char buf[5]; | 748 | char buf[5]; |
| 749 | - const char * start = strstr(filename, "_"); | 749 | + //const char * start = strstr(filename, "_"); // used for parsing file name like uid_138471401_20181109095932880.txt |
| 750 | + const char * start = filename; //used for parsing file name like 138471401_20181109095932789.aac | ||
| 750 | const char * end = strstr(start + 1, "_"); | 751 | const char * end = strstr(start + 1, "_"); |
| 751 | if (end) {//get the next | 752 | if (end) {//get the next |
| 752 | *(char *)end = 0; | 753 | *(char *)end = 0; |
| @@ -797,7 +798,8 @@ int readfile(const char * filename, media_role role) | @@ -797,7 +798,8 @@ int readfile(const char * filename, media_role role) | ||
| 797 | } | 798 | } |
| 798 | 799 | ||
| 799 | unsigned int uid = 0; | 800 | unsigned int uid = 0; |
| 800 | - float start_time = get_uid_start_time_from_filename(filename , uid); | 801 | + float start_time = 0.0f; |
| 802 | + float start_time_offset = 0.0f; | ||
| 801 | 803 | ||
| 802 | const int LINE_LENGTH = 1000; | 804 | const int LINE_LENGTH = 1000; |
| 803 | char str[LINE_LENGTH]; | 805 | char str[LINE_LENGTH]; |
| @@ -807,16 +809,20 @@ int readfile(const char * filename, media_role role) | @@ -807,16 +809,20 @@ int readfile(const char * filename, media_role role) | ||
| 807 | split(str, " ", res); | 809 | split(str, " ", res); |
| 808 | if (res.size() >= 3) { | 810 | if (res.size() >= 3) { |
| 809 | if (res[2] == "create"){ | 811 | if (res[2] == "create"){ |
| 810 | - addinfo(start_time + atof(res[0].c_str()), res[1], true, role, uid); | 812 | + if (!uid){ |
| 813 | + start_time = get_uid_start_time_from_filename(res[1].c_str(), uid); | ||
| 814 | + start_time_offset = atof(res[0].c_str()); | ||
| 815 | + } | ||
| 816 | + addinfo(start_time + atof(res[0].c_str()) - start_time_offset, res[1], true, role, uid); | ||
| 811 | } | 817 | } |
| 812 | else if (res[2] == "close") { | 818 | else if (res[2] == "close") { |
| 813 | - addinfo(start_time + atof(res[0].c_str()), res[1], false, role, uid); | 819 | + addinfo(start_time + atof(res[0].c_str()) - start_time_offset, res[1], false, role, uid); |
| 814 | } | 820 | } |
| 815 | else if (res[2] == "info") { | 821 | else if (res[2] == "info") { |
| 816 | if (res.size() > 5) { | 822 | if (res.size() > 5) { |
| 817 | const char * pInfo = res[5].c_str(); | 823 | const char * pInfo = res[5].c_str(); |
| 818 | if (!strncmp(pInfo, "rotation=", 9)){ | 824 | if (!strncmp(pInfo, "rotation=", 9)){ |
| 819 | - addinfo(res[0].c_str(), res[1].c_str(), pInfo + 9); | 825 | + addinfo(res[1].c_str(), pInfo + 9); |
| 820 | } | 826 | } |
| 821 | } | 827 | } |
| 822 | } | 828 | } |
-
请 注册 或 登录 后发表评论