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

查看:878
本文介绍了什么是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?

推荐答案

编解码器为H.264.

The codec is H.264.

其中一个应该为您工作:

One of these should work for you:

fourcc = cv2.cv.CV_FOURCC(*'H264')
#or 
#fourcc = cv2.cv.CV_FOURCC(*'X264')

但是,我应该警告您,您可能需要安装ffmpegx264库,因此由于您在Ubuntu中,请尝试在终端中执行以下命令:

However, I should warn you that you'll probably need to have ffmpeg and the x264 libraries installed so since you are in Ubuntu, try doing this command in the terminal:

sudo apt-get install ffmpeg x264 libx264-dev

还请查看

Also, check out this link from OpenCV tutorials for more details as to the kinds of FourCC codes available for your platform.

在上面的链接中,您说X264是您应该使用的FourCC代码,但是请在它们之间进行切换,直到您可以使用它为止.

In the above link, it says X264 is the FourCC code you should use, but switch between them until you get it to work.

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

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