diff --git a/videoRecord/videoRecordH264/get_device_info.c b/videoRecord/videoRecordH264/get_device_info.c index 6a1be2d..ffa1a01 100644 --- a/videoRecord/videoRecordH264/get_device_info.c +++ b/videoRecord/videoRecordH264/get_device_info.c @@ -31,11 +31,11 @@ void* monitor_mem_thread_proc(void* arg) { ret = commandDfResult(); // printf("ret is %d \n",ret); if (ret == 0) { - bCapture=1; + bCapture = true; } else{ - bCapture=0; + bCapture = false; printf("SD card or usb disk is not mount,NOT RECORD video \n"); log_error("SD card or usb disk is not mount,NOT RECORD video ###\n"); sleep(10); @@ -64,9 +64,9 @@ int commandDfResult() pclose(fp); double ratio; ratio=atof(buf); - if(ratio>95) + if(ratio >= 98) { - printf("storage is %f,FULL!\n",ratio); + printf("storage is %f,FULL!\n",ratio); return -1; } diff --git a/videoRecord/videoRecordH264/video_Record_h264.cpp b/videoRecord/videoRecordH264/video_Record_h264.cpp index f9d166a..812c4af 100644 --- a/videoRecord/videoRecordH264/video_Record_h264.cpp +++ b/videoRecord/videoRecordH264/video_Record_h264.cpp @@ -18,23 +18,23 @@ yyjqr789@sina.com 原创,如有bug,联系上述邮箱。 2019--->202004 #include "log.h" -#include "log.h" #define STR_OK "[\x1b[1;32m OK \x1b[0m]" #define STR_FAIL "[\x1b[1;31mFAIL\x1b[0m]" -#define VIDEO_LOG_FILE "./video_cap.log" +#define VIDEO_LOG_FILE "/var/log/video_cap.log" using namespace cv; using namespace std; char buf[50] = {0}; //全局变量,用于获取文件名的时间 -int recordFlag = 0; void *record_thread(void *args); extern void *monitor_mem_thread_proc(void *arg); //ADD 0427 static int program_para(int argc, char **argv, int *fps); void printHelp(void); -int bCapture = 1; +bool bCapture = true; +bool gb_recordFlag = true; + int MSG_LEVEL_OFF = 0; int MSG_LEVEL_MAX =5; int trace_level = MSG_LEVEL_OFF; @@ -53,7 +53,7 @@ int main(int argc, char **argv) { time_t timep, t, NOW; - struct tm *local; + tm *local; char stop_cmd[30] = {0}; double elapsedseconds; VideoCapture videoCapturer(-1); // Numerical value 0 cv::CAP_ANY @@ -81,17 +81,21 @@ int main(int argc, char **argv) if (b_dump) { - log_set_level(LOG_INFO); + log_set_level(LOG_DEBUG); log_set_quiet(0); } else { - log_set_level(LOG_ERROR); + log_set_level(LOG_INFO); //将info 信息记录 202309 log_set_quiet(1); } log_info("Open log file success"); } + else + { + printf("open log file error\n"); + } /** * Get some information of the video and print them @@ -116,6 +120,7 @@ int main(int argc, char **argv) else { cout << " " STR_FAIL " Capture not OK"; + log_error(" " STR_FAIL " Capture not OK"); return -1; } @@ -140,26 +145,27 @@ int main(int argc, char **argv) pVideoFileName = str[0]; cout << str[0] << endl; cout << "FileName:" << pVideoFileName << endl; + //VideoWriter writer(pVideoFileName, CV_FOURCC('M', 'P','4', '2'), videoCapturer.get(CAP_PROP_FPS),Size(videoCapturer.get(CAP_PROP_FRAME_WIDTH),videoCapturer.get(CAP_PROP_FRAME_HEIGHT)));//AVI 0901 avi格式 MJPG编码 // VideoWriter writer(pVideoFileName, VideoWriter::fourcc('M', 'P', '4', '2'), videoCapturer.get(CAP_PROP_FPS), // Size(videoCapturer.get(CAP_PROP_FRAME_WIDTH), videoCapturer.get(CAP_PROP_FRAME_HEIGHT))); // X,V,I,D --- H264 DIVX -mp4 VideoWriter writer(pVideoFileName, VideoWriter::fourcc('H', '2', '6', '4'), videoCapturer.get(CAP_PROP_FPS), Size(videoCapturer.get(CAP_PROP_FRAME_WIDTH), videoCapturer.get(CAP_PROP_FRAME_HEIGHT))); - recordFlag = 1; pthread_create(&record_thread_t, NULL, record_thread, NULL); pthread_t card_monitor_thread; pthread_create(&card_monitor_thread, NULL, monitor_mem_thread_proc, NULL); - //namedWindow("Capture", WINDOW_AUTOSIZE); + namedWindow("RobotCam", WINDOW_NORMAL); Mat frame; while (videoCapturer.isOpened()) { //frame=cvQueryFrame(capture); //首先取得摄像头中的一帧 add - if (bCapture == 1) + if (bCapture) { - elapsedseconds = difftime(time(&NOW), t); //比较前后时间差 0912 + gb_recordFlag = true; + elapsedseconds = difftime(time(&NOW), t); //比较前后时间差 0912 videoCapturer >> frame; /*if ((frame.rows==0)||(frame.cols==0)) @@ -174,11 +180,11 @@ int main(int argc, char **argv) //这里运行提示捕获失败!! writer << frame; - //imshow("EangelUSBVideo", frame); + //imshow("RobotCam", frame); if (elapsedseconds > 10 * 60) //录制10分钟左右的视频 { //cout<<"recording time is over"<