Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoding H264 not recognise after building open opencv manually #787

Open
ganeshram1232 opened this issue Aug 5, 2024 · 0 comments
Open

Comments

@ganeshram1232
Copy link

ganeshram1232 commented Aug 5, 2024

Dockerfile:

# Use an official Ubuntu as a parent image
FROM ubuntu:20.04
# Set environment variables to avoid user interaction during installation
ENV DEBIAN_FRONTEND=noninteractive
# Set environment variable to ensure Python output is not buffered
ENV PYTHONUNBUFFERED=1
# Install dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential cmake git gcc g++ wget unzip pkg-config libjpeg-dev libpng-dev libtiff-dev libavcodec-dev libavformat-dev \
    libswscale-dev libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev libv4l-dev libxvidcore-dev libx264-dev libfaac-dev libfaad-dev \
    libgtk-3-dev libatlas-base-dev gfortran python3-dev python3-pip ffmpeg \
    || apt-get install -y --no-install-recommends --fix-missing
# Clean up to reduce image size
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
ADD requirements.txt .
RUN pip3 install --upgrade pip && pip3 install --no-cache-dir -r requirements.txt
# Clone OpenCV and OpenCV contrib repositories
RUN git clone https://github.com/opencv/opencv.git && \
    git clone https://github.com/opencv/opencv_contrib.git
# Create a build directory
RUN mkdir -p /opencv/build
# Set the working directory
WORKDIR /opencv/build
# Configure the build with CMake
RUN cmake -D CMAKE_BUILD_TYPE=Release \
          -D CMAKE_INSTALL_PREFIX=/usr/local \
          -D OPENCV_EXTRA_MODULES_PATH=/opencv_contrib/modules \
          -D PYTHON3_EXECUTABLE=$(which python3) \
          -D BUILD_opencv_videoio_ffmpeg=ON \
          -D WITH_FFMPEG=ON \
          -D BUILD_EXAMPLES=OFF ..
# Compile and install OpenCV
RUN make -j$(nproc) && make install && ldconfig
# Clean up
RUN rm -rf /opencv /opencv_contrib

above is my dockerfile, when i use h264 as encoding error:

OpenCV: FFMPEG: tag 0x34363268/'h264' is not supported with codec id 27 and format 'mp4 / MP4 (MPEG-4 Part 14)'
OpenCV: FFMPEG: fallback to use tag 0x31637661/'avc1'
[h264_v4l2m2m @ 0xffff80a5a9d0] Could not find a valid device
[h264_v4l2m2m @ 0xffff80a5a9d0] can't configure encoder
[ERROR:[email protected]] global cap_ffmpeg_impl.hpp:3194 open Could not open codec h264_v4l2m2m, error: Unspecified error (-22)
[ERROR:[email protected]] global cap_ffmpeg_impl.hpp:3211 open VIDEOIO/FFMPEG: Failed to initialize VideoWriter
[ WARN:[email protected]] global cap.cpp:643 open VIDEOIO(CV_IMAGES): raised OpenCV exception:

OpenCV(4.10.0) /io/opencv/modules/videoio/src/cap_images.cpp:274: error: (-215:Assertion failed) number < max_number in function 'icvExtractPattern'

not sure how to fix it tried multiple ways but nothing working. Kindly help me here and suggest me any changes here how can i install opencv so that i can use h264. I need to use opencv because i need to play the output video in UI. also less in size

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant