Skip to content

Instantly share code, notes, and snippets.

@chrisidefix
Forked from takuma7/opencv-fourcc-on-mac-os-x.md
Last active September 27, 2022 08:54
Show Gist options
  • Save chrisidefix/9af4913ec1a0bdc220d1 to your computer and use it in GitHub Desktop.
Save chrisidefix/9af4913ec1a0bdc220d1 to your computer and use it in GitHub Desktop.
OpenCV Video Writer on Mac OS X

OpenCV Video Writer on Mac OS X

Fourcc tests:

  • x : not worked
  • o: worked (able to open in quicktime but need conversion)
  • oo: worked well (preview worked but wrong aspect ratio)
  • ooo: worked very well (preview worked, and aspect ratio’s right)

Size was measured by recording a static stream at 20fps over 6 seconds at a resolution of 640 x 360.

(Codecs are extracted from https://web.archive.org/web/20120722124832/http://opencv.willowgarage.com/wiki/QuickTimeCodecs )

FourCC OK .mov .avi .mp4 .mkv Codec Name Description
3IV2 x x x x x 3ivx D4 4.5.1 Compresses an image into 3ivx D4 format.
8BPS o 81.1 N/A N/A N/A Apple Planar RGB Compresses images in the Planar RGB format.
SVQ1 o 1.7 N/A N/A N/A Sorenson Video™ Compresavsor Compresses video using the Sorenson Video™ V2.30.302 compressor from Sorenson™ Media, Inc.
SVQ3 o 2.3 N/A N/A N/A Sorenson Video 3 Compressor Compresses video using the Sorenson Video® 3 SE V 3.3.302 compressor from Sorenson® Media, Inc.
WRLE o 86.5 N/A N/A N/A Apple BMP Compresses images in the BMP format.
XVID x x x x x XviD Decompresses video stored in XviD format.
avc1 ooo 1.4 1.6 1.5 1.6 H.264 Encoder Compresses video to the H.264 format.
cvid o 3.2 3.3 3.3 3.3 Apple Cinepak Compresses images using Apple Computer's Cinepak compression algorithm
dv5n oo 30.1 N/A N/A N/A Apple DVCPRO50 - NTSC Compresses an image to DVCPRO50 NTSC format.
dv5p oo 36.1 N/A N/A N/A Apple DVCPRO50 - PAL Compresses an image to DVCPRO50 PAL format.
dvc oo 14.8 15.1 15.1 15.1 Apple DV/DVCPRO - NTSC Compresses an image to DV/DVCPRO NTSC format.
dvcp oo 16.7 N/A N/A N/A Apple DV - PAL Compresses an image to DV PAL format.
dvpp oo 18.1 N/A N/A N/A Apple DVCPRO - PAL Compresses an image to DVCPRO PAL format.
h261 o^ 2.4 2.5 2.5 2.5 Apple H.261 Compresses images using H.261 compression algorithm
h263 ooo^ 1.4 1.6 1.6 1.5 H.263 Compresses images using H.263 compression algorithm
jpeg ooo 3.2 3.3 3.3 3.2 Apple Photo - JPEG Compresses images using the ISO standard baseline JPEG algorithm
mjp2 o 8.8 9.0 9.0 9.0 JPEG 2000 Encoder Compresses images to the JPEG 2000 JP2 format.
mjpa o 4.2 N/A N/A N/A Apple Motion JPEG A Compresses images compressed using Motion JPEG Format A
mjpb o 4.2 N/A N/A N/A Apple Motion JPEG B Compresses images compressed using Motion JPEG Format B
MJPG o x 7.2 x x Motion JPEG Compresses images compressed using Motion JPEG
mp4v ooo 1.5 1.6 1.6 1.6 Apple MPEG4 Compressor Compresses images using MPEG4 compression algorithm
png o 15.7 16.0 16.3 16.3 Apple PNG Compresses images in the PNG format.
pxlt o 3.5 N/A N/A N/A Apple Pixlet Video Apple Pixlet Video Info
raw ooo* 116.2 116.2 116.2 116.2 Apple None Stores images without any compression
rle o 32.3 31.8 31.9 N/A Apple Animation Compresses images using run length encoding
rpza o 6.7 7.0 6.9 6.9 Apple Video Compresses images using Apple Computer's Video compression algorithm
smc o 10.6 10.6 10.6 N/A Apple Graphics Compresses images using Sean's secret recipe (optimal for 8-bit dithered images)
tga o* 109.7 113.1 113.1 N/A Apple TGA Compresses images stored into the TGA format.
tiff o* 104.3 116.4 116.4 117.3 Apple TIFF Compresses images in the TIFF format.
yuv2 o 51.7 57.7 57.3 57.7 Apple Component Video - YUV422 Compresses an image into YUV format.

* preview did not work

^ codec forced reduced resolution (to 352 x 288)

Conclusion

Use 'mp4v' or 'avc1'

@liuziangexit
Copy link

thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment