Opencv-python: Is that possible to use OpenH264 instead of x264?

Created on 7 May 2020  路  2Comments  路  Source: opencv/opencv-python

Expected behaviour

I know H.264 is under GPL license and opencv-python doesn't support H264 encoding.
And I've already found some closed issue about H264 like below.
https://github.com/skvark/opencv-python/issues/299
https://github.com/skvark/opencv-python/issues/100

Here is my question, how about using OpenH264 which is not under GPL license instead of x264?

I couldn't find any answer toward this way so far.
So, If there is any solution for using OpenH264 and make h264 encoding for cv2.VideoWriter effective.
Thank you.

Actual behaviour

failed log

Could not find encoder for codec id 27: Encoder not found

Steps to reproduce

code

import cv2
fourcc = cv2.VideoWriter_fourcc(*'H264')
video_out = cv2.VideoWriter('test.mp4', int(fourcc), 25.0, (640, 480))

system environment
OS: Ubuntu 16.4,
Opencv: 3.4.1

All 2 comments

Not planning to add any additional dependencies on top of the existings ones. Compile FFmpeg and OpenCV manually if you really need the encoding support through OpenCV.

Is there any way to change the codec in cv2.imencode?
I think by default it is using mjpeg codec, so is there any way to change it to H.264 encoding?

Because I am not seeing any such param. in opencv/modules/imgcodecs/src/loadsave.cpp and opencv/modules/imgcodecs/include/opencv2/imgcodecs.hpp

bool imencode( const String& ext, InputArray _image,
               std::vector<uchar>& buf, const std::vector<int>& params )
Was this page helpful?
0 / 5 - 0 ratings

Related issues

owend picture owend  路  7Comments

lgvaz picture lgvaz  路  3Comments

moneer88 picture moneer88  路  6Comments

ES-Alexander picture ES-Alexander  路  5Comments

gldraphael picture gldraphael  路  6Comments