google / google/mobly-android-screen-recorder
The pip installed opencv-python package failed to initialize the H.264 video encoder, resulting in FileNotFoundError during screen recording. This is a common issue as pre-built opencv-python wheels often exclude H.264 due to licensing.
- Dominant language
- Python
- Stars
- 6
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
**H.264 Licensing and OpenCV**
H.264 is a patented video codec. The opencv-python package, as distributed via pip, intentionally omits H.264 encoding support due to associated licensing complexities and potential royalty obligations.
**Solutions**
To enable H.264 support for OpenCV, consider the following methods:
**Option 1: Utilize conda (Recommended)**
Employ the conda package manager, as the conda-forge channel reliably supplies an OpenCV package pre-compiled with H.264 support. Establish a new conda environment for the installation of a compatible OpenCV version, then proceed to install Mobly and Mobly Android Screen Recorder via pip within this environment.
**Option 2: Build OpenCV from Source for pip**
**It is your responsibility to ensure compliance with all applicable H.264 licensing requirements for your specific use case.**
Compile OpenCV directly from its source code on your system. Ensure that all necessary build dependencies, such as libx264-dev, are installed and that the cmake configuration explicitly includes the \-D WITH\_FFMPEG=ON flag. Following successful compilation and installation, manually transfer the generated cv2.so file into your pip virtual environment's site-packages directory.
Contributor guide
Assessment
This issue has not been assessed yet.