OpenCV: FFMPEG: tag 0x34363248/'H264' is not supported with codec id 27 and format 'mp4 / MP4 (MPEG-4 Part 14)'
OpenCV: FFMPEG: fallback to use tag 0x31637661/'avc1'
Could not find encoder for codec id 27: Encoder not found
And I'm unable to write frames to file. I've tried using X264 but I get the same error.
import cv2
fourcc = cv2.VideoWriter_fourcc(*'H264')
video_out = cv2.VideoWriter('test.mp4', int(fourcc), 25.0, (640, 480))
System setup:
Ubuntu 16.4,
FFMPEG 3.4.2 (upgraded from the default Ubuntu version due to this error, but it didn't solve it)
Opencv 3.4.1
Intel i7
alexcanepa, asanakoy, zaloogarcia, howawong, jpiabrantes, ErlanBazarov, JTHEN-DEV, anl13, serhiishtokal, shimatai-mobees, and 6 more reacted with thumbs up emoji
gobismarttechie reacted with hooray emoji
All reactions
If you installed this package via pip install opencv-python
then there's no encoding support for x264 because it's under GPL license. Upgrading FFmpeg won't help because opencv-python
ships with its own FFmpeg. See: #81
You'll have to compile OpenCV manually to get support for H264 encoding.
henzler, yiyang186, alexcanepa, asanakoy, Alyxion, twodoge, hao1939, hailigu, jpellman, FantasyJXF, and 17 more reacted with thumbs up emoji
jclevesque, jbohnslav, zaloogarcia, acodercat, twodoge, crazysnowboy, rajdeinno, yhling, astekardis, Sushanti99, and 22 more reacted with thumbs down emoji
All reactions
Sorry to bump this, but does anyone have any guidance on going about setting this up?
Whenever I try compiling the build with cmake
, my locally installed ffmpeg
implementation is not detected.
The opencv_thirdparty
page says that the build should auto-detect ffmpeg
if installed on UNIX systems...
If you installed this package via pip install opencv-python
then there's no encoding support for x264 because it's under GPL license. Upgrading FFmpeg won't help because opencv-python
ships with its own FFmpeg. See: #81
You'll have to compile OpenCV manually to get support for H264 encoding.
If you installed this package via pip install opencv-python
then there's no encoding support for x264 because it's under GPL license. Upgrading FFmpeg won't help because opencv-python
ships with its own FFmpeg. See: #81
You'll have to compile OpenCV manually to get support for H264 encoding.
https://docs.opencv.org/master/df/d65/tutorial_table_of_content_introduction.html
If you installed this package via pip install opencv-python
then there's no encoding support for x264 because it's under GPL license. Upgrading FFmpeg won't help because opencv-python
ships with its own FFmpeg. See: #81
You'll have to compile OpenCV manually to get support for H264 encoding.
If install opencv python in anaconda, I could encode MP4 video with fourcc avc1
, which let me get video format like this:
Video: h264 (High) (avc1 / 0x31637661), yuv420p
That's all right.
If you installed this package via pip install opencv-python
then there's no encoding support for x264 because it's under GPL license. Upgrading FFmpeg won't help because opencv-python
ships with its own FFmpeg. See: #81
You'll have to compile OpenCV manually to get support for H264 encoding.
I compile opencv with BUILD_opencv_python3=ON
and the opencv_python I get could use fourcc AVC1.
HAHAHA
Could you guide me through the procedure?
On Sun, 17 Nov 2019 at 9:44 PM, FantasyJXF ***@***.***> wrote:
If you installed this package via pip install opencv-python then there's
no encoding support for x264 because it's under GPL license. Upgrading
FFmpeg won't help because opencv-python ships with its own FFmpeg. See:
#81 <
#81>
You'll have to compile OpenCV manually to get support for H264 encoding.
I compile opencv with BUILD_opencv_python3=ON and the opencv_python I get
could use fourcc AVC1.
HAHAHA
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<
#100>,
or unsubscribe
<
https://github.com/notifications/unsubscribe-auth/AHJ6FQXMHILOUVXUP32S5YLQUFUW3ANCNFSM4FDAIIIA>
Yeah, if you link OpenCV against local build of FFmpeg you will most likely get support for encoding to h264.
To compile OpenCV locally with this repo's toolchain:
Clone this repository
Optional: set up ENABLE_CONTRIB and ENABLE_HEADLESS environment variables to 1 if needed
Optional: add additional Cmake arguments to CMAKE_ARGS environment variable
Run python setup.py bdist_wheel
Note: Anaconda package is different than the package provided by this repository: https://github.com/conda-forge/opencv-feedstock
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-3.4.6/modules \
-D PYTHON3_LIBRARY=/usr/local/python36/lib/libpython3.6m.a \
-D PYTHON3_INCLUDE_DIR=/usr/local/python36/include/python3.6m \
-D PYTHON3_EXECUTABLE=/usr/local/python36/bin/python3 \
-D PYTHON3_PACKAGES_PATH=/usr/local/python36/lib/python3.6/site-packages \
-D BUILD_opencv_python2=OFF \
-D BUILD_opencv_python3=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D OPENCV_ENABLE_NONFREE=ON \
-D WITH_FFMPEG=ON \
-D CMAKE_CXX_FLAGS="-std=c++11" ..
Test Code
import cv2 as cv
import numpy as np
vid = cv.VideoWriter('pyout1.mp4', cv.VideoWriter_fourcc(*'avc1'), 25, (300,300))
#vid = cv.VideoWriter('pyout.mp4', 0x00000021, 25, (300,300))
for i in range(250):
img = np.random.randint(0,255, (300,300,3), dtype=np.uint8)
vid.write(img)
vid.release()
And you would get the H264(AVC1) coded video.
If you installed this package via pip install opencv-python
then there's no encoding support for x264 because it's under GPL license. Upgrading FFmpeg won't help because opencv-python
ships with its own FFmpeg. See: #81
You'll have to compile OpenCV manually to get support for H264 encoding.
We all know it doesn't get shipped with the pip version. Yet on Windows and MacOS, OpenCV is able to use a codec stored in the same working directory. Windows OpenCV installed via pip will look for openh264-1.8.0-win64.dll
and MacOS looks for libopenh264-1.8.0-osx64.4.dylib
yet on Linux if libopenh264-1.8.0-linux64.4.so
is in the working directory we get Encoder not found
so where is the same functionality for Linux?
Another way is to use conda environment
Steps:
a) conda --version (should not be found at first)
b1) wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-aarch64.sh -O miniconda.sh (Jetson)
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
b2) bash miniconda.sh -b -p /opt/conda
c) rm miniconda.sh
d) export PATH="/opt/conda/bin:${PATH}"
e) conda --version (should show the version)
f) conda install -c conda-forge opencv
g) avc1 should work now/H264 should be supported
I'm trying to open a VideoWriter using H264 encoding.
Actual behaviour
I'm getting an error when trying to write H264 encoded files/
OpenCV: FFMPEG: tag 0x34363248/'H264' is not supported with codec id 27 and format 'mp4 / MP4 (MPEG-4 Part 14)'
OpenCV: FFMPEG: fallback to use tag 0x31637661/'avc1'
Could not find encoder for codec id 27: Encoder not found
And I'm unable to write frames to file. I've tried using X264 but I get the same error.
Steps to reproduce
Code:
import cv2
fourcc = cv2.VideoWriter_fourcc(*'H264')
video_out = cv2.VideoWriter('test.mp4', int(fourcc), 25.0, (640, 480))
System setup: Ubuntu 16.4, FFMPEG 3.4.2 (upgraded from the default Ubuntu version due to this error, but it didn't solve it) Opencv 3.4.1 Intel i7
https://blog.csdn.net/qq_43445782/article/details/135854380