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

See original GitHub issue

When attempting to output a video from the system (an mp4), on initialisation it prints the !!! TYPE message followed by Could not find encoder for codec id 27: Encoder not found then proceeds as normal.

At the end of processing it will error with AttributeError: 'NoneType' object has no attribute '__array_interface__'.

I believe this is caused by opencv-python pip package not being shipped with x264 (open-source h264 encoder), due to GPL issues? (see skvark/opencv-python#81)

Suggestion is to potentially catch this issue before processing lengthy videos. I did a search of the issues here and didn’t find anything related, so hopefully there’s enough here that others may find the reason for their issue.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:8
  • Comments:5

github_iconTop GitHub Comments

78reactions
michaelnation26commented, Jan 7, 2019

I had the same two problems. To fix it, I made the following changes to yolo.py:

On line 177, change: video_FourCC = int(vid.get(cv2.CAP_PROP_FOURCC)) to video_FourCC = cv2.VideoWriter_fourcc(*"mp4v") This definitely works with .mp4 and .mov file types, possibly other types too.

Immediately after line 190, add:

if not return_value:
    break
3reactions
sunnie-starcommented, Mar 31, 2021

I had the same two problems. To fix it, I made the following changes to yolo.py:

On line 177, change: video_FourCC = int(vid.get(cv2.CAP_PROP_FOURCC)) to video_FourCC = cv2.VideoWriter_fourcc(*"mp4v") This definitely works with .mp4 and .mov file types, possibly other types too.

Immediately after line 190, add:

if not return_value:
    break

Thanks. However, I want h264 encode, so mp4v cannot solve my problem

Read more comments on GitHub >

github_iconTop Results From Across the Web

Save video in opencv with H264 codec - python - Stack Overflow
I can solve my problem in the ubuntu:20.04 docker. The important thing you should notice is that you should install OpenCV via apt-get...
Read more >
Generating MP4's Using opencv-python With the AVC1 Codec
VideoWriter("movie.mp4", fourcc, 5, (5,5)) Could not find encoder for codec id 27: Encoder not found. For licensing reasons , opencv-python ...
Read more >
opencv: ffmpeg: tag 0x00000021/'!???' is not found (format ...
VideoWriter("movie.mp4", fourcc, 5, (5,5)) Could not find encoder for codec id 27: Encoder not found - For licensing reasons,opencv-python does not ship ...
Read more >
Output video using OpenCV h264 mp4s on Streamlit Sharing
The mp4v codec encodes the video properly, doesn't show the video ... open Could not find encoder for codec_id=27, error: Encoder not found...
Read more >
FFmpeg
The design and implementation is based on the snow video codec, which uses OBMC. ... The native FFmpeg AAC encoder has seen extensive...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found