赞
踩
注意:
读取mp4文件时,需要把opencv_videoio_ffmpeg动态库dll文件拷贝到可执行程序exe所在目录,
否则读取mp4文件时,读取的视频为空,宽高等参数都为0。
比如:
opencv_videoio_ffmpeg454_64.dll
读取视频保存mp4:
- #include <iostream>
- #include <opencv2/opencv.hpp>
-
- int main(int argc, const char ** argv){
- cv::String base_dir = "d:/data/shanghai/2019-09-21";
-
- cv::String video_id = "011400.mp4";
- cv::String video_save = "011400_save.mp4";
-
- double beg_, end_;
- double freq = cv::getTickFrequency();
-
- cv::String input_video = base_dir + "/" + video_id;
- cv::VideoCapture input_stream(input_video);
-
- float frame_width = input_stream.get(cv::CAP_PROP_FRAME_WIDTH);
- float frame_height = input_stream.get(cv::CAP_PROP_FRAME_HEIGHT);
- int frame_count = input_stream.get(cv::CAP_PROP_FRAME_COUNT);
-
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。