void CMainDlg::updateSetting() { for (int i = 0;i<BLM_CHANNEL_MAX;i++) { if (m_channelHandle[i] != INVALID_HANDLE_VALUE) { if (m_settingDlg->m_encodeSetting[i].audio) { SetStreamType(m_channelHandle[i],STREAM_TYPE_AVSYNC); }else{ SetStreamType(m_channelHandle[i],STREAM_TYPE_VIDEO); } } } for (int i = 0;i<BLM_CHANNEL_MAX;i++) { if (m_channelHandle[i] != INVALID_HANDLE_VALUE) { //取值范围:12~30 //系统默认:16 int quant[5]={12,16,20,24,30}; SetDefaultQuant(m_channelHandle[i],quant[m_settingDlg->m_encodeSetting[i].quality],NULL,NULL); int format[4] = {1,2,5,6}; SetEncoderPictureFormat(m_channelHandle[i],(PictureFormat_t)format[m_settingDlg->m_encodeSetting[i].format]); //N 制:1,2,3,4,5,6,7,10,15,30; //P 制:1,2,3,4,5,6,8,12,25。 int frameRateP[10] ={1,2,3,4,5,6,7,10,15,30}; int frameRateN[9] ={1,2,3,4,5,6,8,12,25}; VideoStandard_t vs; int a,b,c,d;//useless GetVideoPara(m_channelHandle[i],&vs,&a,&b,&c,&d); if (vs==STANDARD_PAL) { SetIBPMode(m_channelHandle[i],25,0,0,frameRateP[m_settingDlg->m_encodeSetting[i].frameRate]); }else{ SetIBPMode(m_channelHandle[i],25,0,0,frameRateN[m_settingDlg->m_encodeSetting[i].frameRate]); } //todo int maxBits[5]; SetupBitrateControl(m_channelHandle[i],5*1024*1024); if (m_settingDlg->m_encodeSetting[i].sub) { SetSubEncoderPictureFormat(m_channelHandle[i],(PictureFormat_t)format[m_settingDlg->m_encodeSetting[i].format_sub]); SetupSubChannel(m_channelHandle[i],1); SetDefaultQuant(m_channelHandle[i],quant[m_settingDlg->m_encodeSetting[i].quality_sub],NULL,NULL); if (vs==STANDARD_PAL) { SetIBPMode(m_channelHandle[i],25,0,0,frameRateP[m_settingDlg->m_encodeSetting[i].frameRate_sub]); }else{ SetIBPMode(m_channelHandle[i],25,0,0,frameRateN[m_settingDlg->m_encodeSetting[i].frameRate_sub]); } SetupBitrateControl(m_channelHandle[i],5*1024*1024); SetupSubChannel(m_channelHandle[i],0); } } } }
void EncodedStream::start(){ if (m_channel_id >= 0){ if (m_g_real_handler != NULL || m_g_real_handler_ext != NULL){ SetStreamPackType(m_channel_handle, 3);//2:hikvision pack, 3:ps pack SetEncoderPictureFormat(m_channel_handle, ENC_DCIF_FORMAT); SetStreamType(m_channel_handle, STREAM_TYPE_VIDEO); SetDefaultQuant(m_channel_handle, 18, 18, 23);//use the default, the less the better (range:12-30) SetIBPMode(m_channel_handle, 100, 2, 0, FPS);//the last is framerate SetupBitrateControl(m_channel_handle, 2000000);//unit:bps SetBitrateControlMode(m_channel_handle, brCBR);//use cbr, or brVBR StartVideoCapture(m_channel_handle); } if (m_g_real_ori_handler != NULL){ m_yuv_buf_size = WIDTH * HEIGHT * 3 / 2; m_yuv_buf = new unsigned char[m_yuv_buf_size]; SetImageStream(m_channel_handle, true, 25, WIDTH, HEIGHT, m_yuv_buf); } } }