当前位置:网站首页>OpenCV中cv2.VideoWriter_fourcc()函数和cv2.VideoWriter()函数的结合使用
OpenCV中cv2.VideoWriter_fourcc()函数和cv2.VideoWriter()函数的结合使用
2022-07-02 09:43:00 【处女座程序员的朋友】
一、VideoWriter_fourcc()常见的编码参数
参数列表
cv2.VideoWriter_fourcc('M', 'P', '4', 'V')
MPEG-4编码 .mp4 可指定结果视频的大小
cv2.VideoWriter_fourcc('X','2','6','4')
MPEG-4编码 .mp4 可指定结果视频的大小
cv2.VideoWriter_fourcc('I', '4', '2', '0')
该参数是YUV编码类型,文件名后缀为.avi 广泛兼容,但会产生大文件
cv2.VideoWriter_fourcc('P', 'I', 'M', 'I')
该参数是MPEG-1编码类型,文件名后缀为.avi
cv2.VideoWriter_fourcc('X', 'V', 'I', 'D')
该参数是MPEG-4编码类型,文件名后缀为.avi,可指定结果视频的大小
cv2.VideoWriter_fourcc('T', 'H', 'E', 'O')
该参数是Ogg Vorbis,文件名后缀为.ogv
cv2.VideoWriter_fourcc('F', 'L', 'V', '1')
该参数是Flash视频,文件名后缀为.flv
二、使用案例
import cv2
vid = cv2.VideoCapture('./ship.mp4')
video_frame_cnt = int(vid.get(7))
video_width = int(vid.get(3))
video_height = int(vid.get(4))
video_fps = int(vid.get(5))
f = cv2.VideoWriter_fourcc('M', 'P', '4', 'V')#VideoWriter_fourcc为视频编解码器
videoWriter = cv2.VideoWriter('./result.mp4', f, video_fps, (video_width, video_height))
边栏推荐
- Applet link generation
- CPU指令集介绍
- JZ63 股票的最大利润
- Jenkins voucher management
- SSH automatically disconnects (pretends to be dead) after a period of no operation
- 输入一个三位的数字,输出它的个位数,十位数、百位数。
- Leetcode topic [array] -540- single element in an ordered array
- conda常用命令汇总
- MySQL indexes and transactions
- Leetcode739 daily temperature
猜你喜欢
随机推荐
SCM power supply
MySQL and PostgreSQL methods to grab slow SQL
WSL 2 will not be installed yet? It's enough to read this article
记录一下MySql update会锁定哪些范围的数据
上传文件时,服务器报错:IOFileUploadException: Processing of multipart/form-data request failed. 设备上没有空间
Calculate the maximum path sum of binary tree
Sparkcontext: error initializing sparkcontext solution
[C language] Yang Hui triangle, customize the number of lines of the triangle
Initial JDBC programming
Natural language processing series (II) -- building character level language model using RNN
CONDA common command summary
Go learning notes - multithreading
Leetcode209 长度最小的子数组
输入一个三位的数字,输出它的个位数,十位数、百位数。
基于Arduino和ESP8266的Blink代码运行成功(包含错误分析)
Natural language processing series (I) -- RNN Foundation
lombok常用注解
CDH6之Sqoop添加数据库驱动
Jenkins voucher management
Uniapp uni list item @click, uniapp uni list item jump with parameters