I'm working on a python/pygame application, and i'm facing some difficulties when I try to capture a video from a usb camera (640x480) to a h264 encoded file, through OpenCV. Everything work fine with other codecs, DIVX or DX50, but I hope to achieve a better FPS using h264 harware encoding.

So i build ffmpeg from source with h264 support, with success (as shown here) :

ffmpeg --version

configuration: --arch=armel --target-os=linux --enable-gpl --enable-omx --enable-omx-rpi --enable-nonfree --enable-libx264

ffmpeg -codecs | grep "264"

DEV.LS h264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_vdpau ) (encoders: libx264 libx264rgb h264_omx h264_vaapi )

And then rebuild openCV 2.4.13 from sources. Sadly, I always get this error when I try to use VideoWriter with "H264" or "X264" fourcc :

[libx264 @ 0x1fd1250] broken ffmpeg default settings detected
[libx264 @ 0x1fd1250] use an encoding preset (e.g. -vpre medium)
[libx264 @ 0x1fd1250] preset usage: -vpre <speed> -vpre <profile>
[libx264 @ 0x1fd1250] speed presets are listed in x264 --help
[libx264 @ 0x1fd1250] profile is optional; x264 defaults to high
Could not open codec 'libx264': Unspecified error

Did someone see what I missed ?

  • 1
    I don't know what VideoWriter is, but the partial output you provided is from ffmpeg. You need to show your actual ffmpeg command, and the complete output. Unrelated and minor, but --enable-nonfree is not needed since you have no other configure options that require it. – llogan Jun 19 '17 at 16:30
  • In fact, OpenCV.VideoWriter launch FFmpeg in background, so i can't access nor modify the ffmpeg command-line, as far as I know. – Technico.top Jun 19 '17 at 21:34
  • It is using an invalid or outdated ffmpeg command, but you say it can't be changed, so there may be no proper solution. – llogan Jun 19 '17 at 22:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.