| | |
| | | |
| | | int ret = mux_hevc(fp, file_path_.c_str()); |
| | | fclose(fp); |
| | | if (ret == 0){ |
| | | if (remove(hevc_file.c_str()) != 0){ |
| | | logIt("mux hevc remove file %s failed", hevc_file.c_str()); |
| | | } |
| | | }else{ |
| | | logIt("mux hevc to mp4 error, use raw hevc"); |
| | | file_path_ = hevc_file; |
| | | } |
| | | |
| | | return ret; |
| | | return 0; |
| | | } |
| | | |
| | | static int read_buffer(void *opaque, uint8_t *buf, int buf_size){ |
| | | FILE *fp_open = (FILE*)opaque; |
| | | if (!fp_open) logIt("mux hevc open file error"); |
| | | |
| | | if(!feof(fp_open)){ |
| | | int true_size=fread(buf,1,buf_size,fp_open); |
| | | return true_size; |
| | |
| | | return -1; |
| | | } |
| | | |
| | | if (in->openWithCustomIO(fp, read_buffer) < 0) { |
| | | logIt("mux hevc open custom io error"); |
| | | int tryTime = 0; |
| | | while (in->openWithCustomIO(fp, read_buffer) < 0) { |
| | | usleep(10000); |
| | | if (tryTime++ < 100){ |
| | | logIt("mux hevc mux: %d failed open custom io %s, try again", tryTime, outfile); |
| | | continue; |
| | | } |
| | | logIt("mux hevc try %d time to open custom io, failed", tryTime); |
| | | return -2; |
| | | } |
| | | if (in->open(NULL, NULL) < 0){ |
| | |
| | | |
| | | void Recorder::end_writer(){ |
| | | |
| | | int ret = -1; |
| | | if (in_->IsHEVC()){ |
| | | ret = end_write_hevc(); |
| | | end_write_hevc(); |
| | | }else{ |
| | | ret = end_write_h264(); |
| | | } |
| | | if (ret < 0){ |
| | | logIt("end write file : %s, h265: %d, failed", file_path_.c_str(), in_->IsHEVC()); |
| | | end_write_h264(); |
| | | } |
| | | |
| | | logIt("finished record : %s frames: %d", file_path_.c_str(), cur_frame); |