当前位置:网站首页>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

深入理解P-R曲线、ROC与AUC

Find the common ancestor of any two numbers in a binary tree

Jenkins user rights management

寻找二叉树中任意两个数的公共祖先

PyTorch搭建LSTM实现服装分类(FashionMNIST)

kubenetes中port、targetPort、nodePort、containerPort的区别与联系

Differences between nodes and sharding in ES cluster

mysql索引和事务

Multiply LCA (nearest common ancestor)
随机推荐
[old horse of industrial control] detailed explanation of Siemens PLC TCP protocol
Deep understanding of NN in pytorch Embedding
CDA数据分析——Excel数据处理的常见知识点归纳
深入理解P-R曲线、ROC与AUC
Leetcode209 长度最小的子数组
PyTorch搭建LSTM实现服装分类(FashionMNIST)
(C语言)八进制转换十进制
Leetcode122 买卖股票的最佳时机 II
二分刷题记录(洛谷题单)区间的甄别
堆(优先级队列)
Orb-slam2 data sharing and transmission between different threads
MySQL and PostgreSQL methods to grab slow SQL
单指令多数据SIMD的SSE/AVX指令集和API
Take you ten days to easily finish the finale of go micro services (distributed transactions)
ES集群中节点与分片的区别
记录一下MySql update会锁定哪些范围的数据
Discrimination of the interval of dichotomy question brushing record (Luogu question sheet)
Find the factorial of a positive integer within 16, that is, the class of n (0= < n < =16). Enter 1111 to exit.
Drools executes the specified rule
arcgis js 4. Add pictures to x map