python OpenCV中mp4视频的编解码器是什么 [英] what is the codec for mp4 videos in python OpenCV

查看:70
本文介绍了python OpenCV中mp4视频的编解码器是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

fourcc = cv2.cv.CV_FOURCC(*'XVID')

以上行用于 avi 视频.以同样的方式,我们在 Ubuntu 中使用哪种编解码器来处理 mp4 视频?

The above line is used for avi video. In the same fashion, which codec do we use for mp4 videos in Ubuntu?

推荐答案

您也可以使用mp4v

fourcc = cv2.VideoWriter_fourcc(*'mp4v')

视频作者应该像这样:

out = cv2.VideoWriter('output.mp4',fourcc, 15, size)

但是有更多可用于 mp4 的编解码器.您可以通过设置fourcc = -1 来查看它们的列表,它会显示如下列表:

But there are more codecs available for mp4. You can see the list of them by setting fourcc = -1, it will show a list like this:

OpenCV: FFMPEG: format mp4 / MP4 (MPEG-4 Part 14)
fourcc tag 0x7634706d/'mp4v' codec_id 000C
fourcc tag 0x31637661/'avc1' codec_id 001B
fourcc tag 0x33637661/'avc3' codec_id 001B
fourcc tag 0x31766568/'hev1' codec_id 00AD
fourcc tag 0x31637668/'hvc1' codec_id 00AD
fourcc tag 0x7634706d/'mp4v' codec_id 0002
fourcc tag 0x7634706d/'mp4v' codec_id 0001
fourcc tag 0x7634706d/'mp4v' codec_id 0007
fourcc tag 0x7634706d/'mp4v' codec_id 003D
....

它们都支持 mp4,但如果您想将视频提供给网络,则网络浏览器支持 h264.

All of them supports mp4 but h264 is supported by Web browsers if you want to serve the video into the web.

这篇关于python OpenCV中mp4视频的编解码器是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆