Keras-yolo3: Could not find encoder for codec id 27: Encoder not found

Created on 2 Nov 2018  路  4Comments  路  Source: qqwweee/keras-yolo3

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.

Most helpful comment

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

All 4 comments

Thanks for rising the issue. So I cannot work with mp4 videos , if I had installed openCV through pip ?

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

When I enter this command:

python yolo_video.py --input ele.mp4 --output eleout.mp4

after following your advice, I get get this error:

model_data/yolo.h5 model, anchors, and classes loaded. !!! TYPE: <class 'str'> <class 'int'> <class 'float'> <class 'tuple'> (416, 416, 3) Found 0 boxes for img 4.143806226958986 Traceback (most recent call last): File "yolo_video.py", line 75, in <module> detect_video(YOLO(**vars(FLAGS)), FLAGS.input, FLAGS.output) File "/home/fritzke/TENSORFLOW/keras-yolo3/yolo.py", line 210, in detect_video cv2.namedWindow("result", cv2.WINDOW_NORMAL) cv2.error: OpenCV(3.4.2) /tmp/build/80754af9/opencv-suite_1535558553474/work/modules/highgui/src/window.cpp:615: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvNamedWindow'

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

Was this page helpful?
0 / 5 - 0 ratings