diff --git a/src/FFNvDecoder.cpp b/src/FFNvDecoder.cpp index 657f46b..b9885cc 100644 --- a/src/FFNvDecoder.cpp +++ b/src/FFNvDecoder.cpp @@ -233,13 +233,13 @@ void FFNvDecoder::decode_thread() if (stream_index == pkt->stream_index){ result = avcodec_send_packet(avctx, pkt); if (result < 0){ - av_log(nullptr, AV_LOG_ERROR, "Failed to send pkt: %d \n",result); + av_log(nullptr, AV_LOG_ERROR, "%s - Failed to send pkt: %d \n",name,result); continue; } result = avcodec_receive_frame(avctx, gpuFrame); if ((result == AVERROR(EAGAIN) || result == AVERROR_EOF) || result < 0){ - av_log(nullptr, AV_LOG_ERROR, "Failed to receive frame: %d \n",result); + av_log(nullptr, AV_LOG_ERROR, "%s - Failed to receive frame: %d \n",name,result); continue; } @@ -271,7 +271,7 @@ void FFNvDecoder::decode_thread() decode_finished(); - av_log(nullptr, AV_LOG_INFO, "decode thread exited. \n"); + av_log(nullptr, AV_LOG_INFO, "%s - decode thread exited. \n",name); } void FFNvDecoder::decode_finished() diff --git a/src/main.cpp b/src/main.cpp index 7347f97..1df4833 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -94,14 +94,10 @@ int count_std = 100; static long long get_cur_time(){ // 获取操作系统当前时间点(精确到微秒) - chrono::time_point tpMicro - = chrono::time_point_cast(chrono::system_clock::now()); + chrono::time_point tpMicro + = chrono::time_point_cast(chrono::system_clock::now()); // (微秒精度的)时间点 => (微秒精度的)时间戳 - time_t totalMicroSeconds = tpMicro.time_since_epoch().count(); - - long long currentTime = ((long long)totalMicroSeconds)/1000; - - return currentTime; + return tpMicro.time_since_epoch().count(); } static int sum = 0; @@ -160,6 +156,10 @@ void postDecoded0(const void * userPtr, AVFrame * gpuFrame){ } } +void decode_finished_cbk(const void* userPtr){ + cout << "decode_finish timestamp: " << get_cur_time() << endl; +} + // string test_uri = "rtmp://192.168.10.56:1935/objecteye/1"; // string test_uri = "/home/cmhu/data/output_800x480.mp4"; // string test_uri = "/home/cmhu/data/output_1920x1080.mp4"; @@ -173,15 +173,16 @@ void createDecode(int index){ config.name = "dec" + to_string(index); config.cfg.uri = test_uri; config.cfg.post_decoded_cbk = postDecoded; + config.cfg.decode_finished_cbk = decode_finished_cbk; config.cfg.force_tcp = true; if (index % 2 == 0) { - config.cfg.gpuid = "2"; + config.cfg.gpuid = "0"; } else { - config.cfg.gpuid = "1"; + config.cfg.gpuid = "0"; } FFNvDecoder* decoder = pDecManager->createDecoder(config); @@ -253,6 +254,7 @@ int main(){ config.name = "dec"; config.cfg.uri = test_uri; config.cfg.post_decoded_cbk = postDecoded0; + config.cfg.decode_finished_cbk = decode_finished_cbk; config.cfg.force_tcp = true; config.cfg.gpuid = "0"; FFNvDecoder* dec2 = pDecManager->createDecoder(config);