//NVCUVENC callback function to signal that the encoded bitstream is ready to be written to file static void _stdcall HandleReleaseBitStream(int nBytesInBuffer, unsigned char *cb,void *pUserData) { VideoEncoder *pCudaEncoder; if (pUserData) { pCudaEncoder = (VideoEncoder *)pUserData; } else { printf(">> VideoEncoder structure is invalid!\n"); return; } if (pCudaEncoder && pCudaEncoder->fileOut()) { fwrite(cb,1,nBytesInBuffer,pCudaEncoder->fileOut()); } return; }
//NVCUVENC callback function to signal that the encoded bitstream is ready to be written to file static void _stdcall HandleReleaseBitStream(int nBytesInBuffer, unsigned char *cb,void *pUserData) { VideoEncoder *pCudaEncoder; if (pUserData) { pCudaEncoder = (VideoEncoder *)pUserData; } else { printf(">> VideoEncoder structure is invalid!\n"); return; } if (pCudaEncoder && pCudaEncoder->fileOut()) { //fwrite(cb,1,nBytesInBuffer,pCudaEncoder->fileOut()); AVPacket packet; av_init_packet(&packet); //memcpy(packet.data, cb, nBytesInBuffer); packet.data = cb; packet.size = nBytesInBuffer; packet.stream_index = stream->index; packet.flags = AV_PKT_FLAG_KEY; //packet.pts = AV_NOPTS_VALUE; //packet.dts = AV_NOPTS_VALUE; int i = av_interleaved_write_frame(avfmtCtx, &packet); //printf("send status: %d\n", i); av_free_packet(&packet); } return; }