Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV + FFMPEG encoding bitrate

Hi to all. I'm in stuck since 3 days on the following problem. I have a small project in Visual Studio using OpenCV with FFMPEG and I'm encoding a video coming from a capture device. I can encode it with various codecs using the VideoWriter class without problem, including H263 and so on. My problem is that the resulting file have a bitrate of more than 1 Mbps that is not acceptable in my application. I need to reduce it but I couldn't find any way to set the bitrate of the encoder. Also googling for this results only in unanswered questions.

Thanks

OpenCV + FFMPEG encoding bitrate

Hi to all. I'm in stuck since 3 days on the following problem. I have a small project in Visual Studio using OpenCV with FFMPEG and I'm encoding a video coming from a capture device. I can encode it with various codecs using the VideoWriter class without problem, including H263 and so on. My problem is that the resulting file have a bitrate of more than 1 Mbps that is not acceptable in my application. I need to reduce it but I couldn't find any way to set the bitrate of the encoder. Also googling for this results only in unanswered questions.

Thanks

OpenCV + FFMPEG encoding bitrate

Hi to all. I'm in stuck since 3 days on the following problem. I have a small project in Visual Studio using OpenCV with FFMPEG and I'm encoding a video coming from a capture device. I can encode it with various codecs using the VideoWriter class without problem, including H263 and so on. My problem is that the resulting file have a bitrate of more than 1 Mbps that is not acceptable in my application. I need to reduce it but I couldn't find any way to set the bitrate of the encoder. Also googling for this results only in unanswered questions.

Thanks

EDIT: After LBerger comment I did some tests and research about libopenh264. It's clear that it can handle easily the maximum bitrate (I did some test using directly ffmpeg.exe interface and it works) but when you create a VideoWriter from opencv you will obtain a writer with some defaults parameter that I can't figure out how to change. Also console logging, just after the writer instance is created says that bitrate can't be controlled:

[OpenH264] this = 0x046E2F90, Warning:bEnableFrameSkip = 0,bitrate can't be controlled for RC_QUALITY_MODE,RC_BITRATE_MODE and RC_TIMESTAMP_MODE without enablin g skip frame.

bEnableFrameSkip should be 1 but is initialized from a structure with default as zero.

The video writer is created by a proxy class named CvVideoWriter_FFMPEG_proxy that calls cvCreateVideoWriter_FFMPEG from the opencv_ffmpeg.dll Unfortunately it looks there is noway to compile the opencv_ffmpeg.dll by myself because it cames prebuilt. There is not any exported function from that dll that helps to change this.