B
B
Python

Python opencv2 fourcc codecs?

There is a code:

import cv2

v = cv2.VideoCapture("video.mp4")
o = cv2.VideoWriter('outpy.mp4',cv2.VideoWriter_fourcc('H','E','V','C'), 24, (int(v.get(3)),int(v.get(4))))

fs = int(v.get(cv2.CAP_PROP_FRAME_COUNT))
f = 0

print(fs)

while f < fs:
  _,n = v.read()	
  o.write(n)
  f += 1

v.release()
o.release()


error:
OpenCV: FFMPEG: tag 0x43564548/'HEVC' is not found (format 'mp4 / MP4 (MPEG-4 Part 14)')'

while I took different codes from the site

and all give an error except mjpg which is not effective at all.

so I tried mp4v, h264, h265, hevc, mpeg, avc1 and everything does not work, but the
file was recorded normally every time! I checked it on this site and it is encoded with mpeg4 part 10 (h264)
although when I put its code or its aliases there was this error:
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'

Failed to load OpenH264 library: openh264-1.8.0-win64.dll
        Please check environment and/or download library: https://github.com/cisco/openh264/releases


how the codec is not available, but is encoded anyway with its help?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question