there are a lot of questions asked regarding opencv + H.264 butnone of them gave detailed explanation.i am using openh264(openh264-1.4.0-win32msvc.dll) along with opencv 3.1(custom build with cmake having ffmpeg enabled) in visual studio, i wanted to save video coming from webcam in mp4 format with H.264 compression VideoWriter写入= VideoWriter("D:/movie.mp4",CV_FOURCC('H','2', '6','4'),10.0,cv :: Size(192,144),true); VideoWriter write = VideoWriter("D:/movie.mp4", CV_FOURCC('H', '2', '6', '4'), 10.0, cv::Size(192, 144), true);在使用openh264之前,在控制台窗口中我看到一条警告消息无法加载openh264库:openh264-1.4.0-win32msvc.dll请检查您的环境和/或从此处下载: https://github.com/cisco/openh264/releases(视频也未保存)before using openh264, in console window i was seeing an warning message"Failed to load openh264 library : openh264-1.4.0-win32msvc.dllplease check your environment and/or download from here:https://github.com/cisco/openh264/releases"(also video was not been saved)所以我下载了dll&与我的程序文件(exe)放在一个文件夹中现在,当我运行程序时,我看到了不同的错误"[OpenH264]此= 0x0DE312C0,警告:bEnabledFrameSkip = 0,如果不启用跳过帧就无法控制RC_QUALITY_MODE和RC_TIMESTAMP_MODE的比特率"(现在已保存视频,但是大小非常高!比特率约为1200 Kbps)so i downloaded the dll & kept in a folder with my program file(exe)now when i run the program, i'm seeing different error"[OpenH264] this = 0x0DE312C0, warning: bEnabledFrameSkip=0, bitrate can't be controlled for RC_QUALITY_MODE and RC_TIMESTAMP_MODE without enabling skip frame"(now video is saved, but size is very high! bit rate is around 1200 Kbps)对我来说,使用h264的唯一目的是减小文件大小..我想我可能不得不自己进行一些更改来构建openh264才能消除此错误,任何人都可以指导我如何做?还是告诉我是否有一种方法可以通过代码降低比特率?for me, the sole purpose of using h264 is to reduce the file size.. i think i may have to build openh264 myself with some changes to remove this error, can anyone guide me how? or tell me if there is a way to reduce bit rate somehow through code? P.S:我尝试提供-1而不是CV_FOURCC(),但系统中显示了已安装的编解码器"窗口,即使我安装了各种编解码器包,我也找不到h264或x264或h264vfw.来自此处P.S: I tried giving -1 instead of CV_FOURCC(), 'installed codecs' window in my system showed up, i couldn't find h264 or x264 or h264vfw even though i have installed variety of codec packs & h264 from here感谢&问候推荐答案如果要控制比特率,则必须同时使用If you want to control bitrate, You have to use bothencoderParemeters.iRCMode = RC_OFF_MODE;encoderParemeters.bEnableFrameSkip = true; 在这里,我以示例显示所有Openh264编码参数: Here I am showing all the Openh264 Encoding parameters as an Example:long nReturnedValueFromEncoder = WelsCreateSVCEncoder(&m_pSVCVideoEncoder); m_nVideoWidth = 352; m_nVideoHeight = 288; SEncParamExt encoderParemeters; memset(&encoderParemeters, 0, sizeof(SEncParamExt)); m_pSVCVideoEncoder->GetDefaultParams(&encoderParemeters); encoderParemeters.iUsageType = CAMERA_VIDEO_REAL_TIME; encoderParemeters.iTemporalLayerNum = 0; encoderParemeters.uiIntraPeriod = 15; encoderParemeters.eSpsPpsIdStrategy = INCREASING_ID; encoderParemeters.bEnableSSEI = false; encoderParemeters.bEnableFrameCroppingFlag = true; encoderParemeters.iLoopFilterDisableIdc = 0; encoderParemeters.iLoopFilterAlphaC0Offset = 0; encoderParemeters.iLoopFilterBetaOffset = 0; encoderParemeters.iMultipleThreadIdc = 0; encoderParemeters.iRCMode = RC_BITRATE_MODE; encoderParemeters.iMinQp = 0; encoderParemeters.iMaxQp = 52; encoderParemeters.bEnableDenoise = false; encoderParemeters.bEnableSceneChangeDetect = false; encoderParemeters.bEnableBackgroundDetection = true; encoderParemeters.bEnableAdaptiveQuant = false; encoderParemeters.bEnableFrameSkip = true; encoderParemeters.bEnableLongTermReference = true; encoderParemeters.iLtrMarkPeriod = 20; encoderParemeters.bPrefixNalAddingCtrl = false; encoderParemeters.iSpatialLayerNum = 1; SSpatialLayerConfig *spartialLayerConfiguration = &encoderParemeters.sSpatialLayers[0]; spartialLayerConfiguration->uiProfileIdc = PRO_BASELINE;//; encoderParemeters.iPicWidth = spartialLayerConfiguration->iVideoWidth = m_nVideoWidth; encoderParemeters.iPicHeight = spartialLayerConfiguration->iVideoHeight = m_nVideoHeight; encoderParemeters.fMaxFrameRate = spartialLayerConfiguration->fFrameRate = (float)30; encoderParemeters.iTargetBitrate = spartialLayerConfiguration->iSpatialBitrate = 500000; encoderParemeters.iTargetBitrate = spartialLayerConfiguration->iMaxSpatialBitrate = 500000; spartialLayerConfiguration->iDLayerQp = 24; //spartialLayerConfiguration->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; spartialLayerConfiguration->sSliceArgument.uiSliceMode = SM_SINGLE_SLICE; nReturnedValueFromEncoder = m_pSVCVideoEncoder->InitializeExt(&encoderParemeters);希望它会对您有所帮助.Hope it will help you. 这篇关于openh264-bEnableFrameSkip = 0,无法控制比特率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 05-20 04:48