├── opencv-ffmpeg-h264.suo
├── opencv-ffmpeg-h264
├── EncodeObject.cpp
├── VideoFrame.h
├── main.cpp
├── opencv-ffmpeg-h264.vcxproj.user
├── VideoFrame.cpp
├── EncodeObject.h
├── opencv-ffmpeg-h264.vcxproj.filters
└── opencv-ffmpeg-h264.vcxproj
├── README.md
└── opencv-ffmpeg-h264.sln
/opencv-ffmpeg-h264.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gbmm/opencv-ffmpeg-Qt-h264/HEAD/opencv-ffmpeg-h264.suo
--------------------------------------------------------------------------------
/opencv-ffmpeg-h264/EncodeObject.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gbmm/opencv-ffmpeg-Qt-h264/HEAD/opencv-ffmpeg-h264/EncodeObject.cpp
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # opencv-ffmpeg-Qt-h264
2 |
win7下用opencv获取摄像头,ffmpeg录制h264,使用Qt的UI
3 |
4 |
vs2010
5 |
Qt4.8.4
6 |
opencv2.8.4
7 |
ffmpeg 开发库
8 |
opencv打开摄像头-》ffmpeg编码保存
9 |
--------------------------------------------------------------------------------
/opencv-ffmpeg-h264/VideoFrame.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | class VideoFrame:public QThread
11 | {
12 | Q_OBJECT
13 | public:
14 | VideoFrame(QObject*parent=0);
15 | ~VideoFrame(void);
16 | void run();
17 | void StartPreview();
18 | };
19 |
20 |
--------------------------------------------------------------------------------
/opencv-ffmpeg-h264/main.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include
3 | #include
4 | #include
5 | #include "VideoFrame.h"
6 | #include "EncodeObject.h"
7 | #include
8 |
9 | QList listImage;
10 | QMutex mutex;
11 |
12 | int main(int argc, char *argv[])
13 | {
14 | QCoreApplication a(argc, argv);
15 |
16 | cvNamedWindow("video");
17 | VideoFrame videoFrameObject;
18 | //videoFrameObject.StartPreview();
19 |
20 | EncodeObject encodeObject;
21 | videoFrameObject.start();
22 | encodeObject.start();
23 |
24 | return a.exec();
25 | }
26 |
--------------------------------------------------------------------------------
/opencv-ffmpeg-h264/opencv-ffmpeg-h264.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | D:\Qt\4.8.4
5 | PATH=$(QTDIR)\bin%3b$(PATH)
6 |
7 |
8 | D:\Qt\4.8.4
9 | PATH=$(QTDIR)\bin%3b$(PATH)
10 |
11 |
--------------------------------------------------------------------------------
/opencv-ffmpeg-h264/VideoFrame.cpp:
--------------------------------------------------------------------------------
1 | #include "VideoFrame.h"
2 |
3 | extern QList listImage;
4 | extern QMutex mutex;
5 | VideoFrame::VideoFrame(QObject *parent):QThread(parent)
6 | {
7 |
8 | }
9 |
10 |
11 | VideoFrame::~VideoFrame(void)
12 | {
13 |
14 | }
15 |
16 | void VideoFrame::run()
17 | {
18 | StartPreview();
19 | }
20 |
21 | void VideoFrame::StartPreview()
22 | {
23 |
24 | CvCapture* pCapture = cvCreateCameraCapture(-1);
25 | while(true)
26 | {
27 | IplImage *pFrame=cvQueryFrame( pCapture );
28 | if(pFrame==NULL)continue;
29 | IplImage *image = cvCreateImage(cvGetSize(pFrame),pFrame->depth,pFrame->nChannels);
30 | cvCopy(pFrame,image);
31 | mutex.lock();
32 | listImage.append(image);
33 | mutex.unlock();
34 | cvShowImage("video",pFrame);
35 | cvWaitKey(25);
36 | }
37 | }
--------------------------------------------------------------------------------
/opencv-ffmpeg-h264/EncodeObject.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #ifdef __cplusplus
6 | extern "C"{
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 | #include
17 | }
18 | #endif //__cplusplus
19 | #include
20 | #include
21 | #include
22 | #include
23 |
24 | class EncodeObject:public QThread
25 | {
26 | Q_OBJECT
27 | public:
28 | EncodeObject(QObject *parent=0);
29 | ~EncodeObject(void);
30 | void run();
31 | void EncodeIplimage();
32 | public:
33 | char *filename;
34 | };
35 |
36 |
--------------------------------------------------------------------------------
/opencv-ffmpeg-h264.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opencv-ffmpeg-h264", "opencv-ffmpeg-h264\opencv-ffmpeg-h264.vcxproj", "{957636B0-CBA3-4314-ACED-0EC1497C8B8F}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Win32 = Debug|Win32
9 | Release|Win32 = Release|Win32
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {957636B0-CBA3-4314-ACED-0EC1497C8B8F}.Debug|Win32.ActiveCfg = Debug|Win32
13 | {957636B0-CBA3-4314-ACED-0EC1497C8B8F}.Debug|Win32.Build.0 = Debug|Win32
14 | {957636B0-CBA3-4314-ACED-0EC1497C8B8F}.Release|Win32.ActiveCfg = Release|Win32
15 | {957636B0-CBA3-4314-ACED-0EC1497C8B8F}.Release|Win32.Build.0 = Release|Win32
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/opencv-ffmpeg-h264/opencv-ffmpeg-h264.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;cxx;c;def
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h
11 |
12 |
13 | {D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}
14 | qrc;*
15 | false
16 |
17 |
18 | {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}
19 | moc;h;cpp
20 | False
21 |
22 |
23 | {292a2212-8aaa-4a0c-b191-2591b777224e}
24 | cpp;moc
25 | False
26 |
27 |
28 | {26da2f3f-270a-4061-98b5-db45e7a53f10}
29 | cpp;moc
30 | False
31 |
32 |
33 |
34 |
35 | Source Files
36 |
37 |
38 | Source Files
39 |
40 |
41 | Source Files
42 |
43 |
44 | Generated Files\Debug
45 |
46 |
47 | Generated Files\Release
48 |
49 |
50 | Generated Files\Debug
51 |
52 |
53 | Generated Files\Release
54 |
55 |
56 |
57 |
58 | Header Files
59 |
60 |
61 | Header Files
62 |
63 |
64 |
--------------------------------------------------------------------------------
/opencv-ffmpeg-h264/opencv-ffmpeg-h264.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 |
14 | {957636B0-CBA3-4314-ACED-0EC1497C8B8F}
15 | Qt4VSv1.0
16 |
17 |
18 |
19 | Application
20 |
21 |
22 | Application
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 | <_ProjectFileVersion>10.0.40219.1
36 | AllRules.ruleset
37 |
38 |
39 | AllRules.ruleset
40 |
41 |
42 | $(SolutionDir)$(Platform)\$(Configuration)\
43 | $(SolutionDir)$(Platform)\$(Configuration)\
44 | D:\Qt\opencv\opencv\build\include\opencv;D:\Qt\opencv\opencv\build\include\opencv2;D:\Qt\opencv\opencv\build\include\;D:\Qt\ffmpeg\ffmpeg\include;$(IncludePath)
45 | D:\Qt\ffmpeg\ffmpeg\lib;D:\Qt\opencv\opencv\build\x86\vc10\lib;$(LibraryPath)
46 |
47 |
48 |
49 | UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_DLL;QT_CORE_LIB;%(PreprocessorDefinitions)
50 | Disabled
51 | ProgramDatabase
52 | MultiThreadedDebugDLL
53 | .;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;%(AdditionalIncludeDirectories)
54 | false
55 |
56 |
57 | Console
58 | $(OutDir)\$(ProjectName).exe
59 | $(QTDIR)\lib;%(AdditionalLibraryDirectories)
60 | true
61 | qtmaind.lib;QtCored4.lib;avcodec.lib;avdevice.lib;avfilter.lib;avformat.lib;avutil.lib;postproc.lib;swresample.lib;swscale.lib;opencv_calib3d244d.lib;opencv_contrib244d.lib;opencv_core244d.lib;opencv_features2d244d.lib;opencv_flann244d.lib;opencv_gpu244d.lib;opencv_highgui244d.lib;opencv_imgproc244d.lib;opencv_legacy244d.lib;opencv_ml244d.lib;opencv_objdetect244d.lib;opencv_ts244d.lib;opencv_video244d.lib;%(AdditionalDependencies)
62 |
63 |
64 |
65 |
66 | UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_DLL;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;%(PreprocessorDefinitions)
67 |
68 |
69 | MultiThreadedDLL
70 | .;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;%(AdditionalIncludeDirectories)
71 | false
72 |
73 |
74 | Console
75 | $(OutDir)\$(ProjectName).exe
76 | $(QTDIR)\lib;%(AdditionalLibraryDirectories)
77 | false
78 | qtmain.lib;QtCore4.lib;%(AdditionalDependencies)
79 |
80 |
81 |
82 |
83 |
84 | true
85 |
86 |
87 | true
88 |
89 |
90 | true
91 |
92 |
93 | true
94 |
95 |
96 |
97 |
98 |
99 |
100 | $(QTDIR)\bin\moc.exe;%(FullPath)
101 | Moc%27ing EncodeObject.h...
102 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp
103 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_CORE_LIB "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\QtCore"
104 | $(QTDIR)\bin\moc.exe;%(FullPath)
105 | Moc%27ing EncodeObject.h...
106 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp
107 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\QtCore"
108 |
109 |
110 | $(QTDIR)\bin\moc.exe;%(FullPath)
111 | Moc%27ing VideoFrame.h...
112 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp
113 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_CORE_LIB "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\QtCore"
114 | $(QTDIR)\bin\moc.exe;%(FullPath)
115 | Moc%27ing VideoFrame.h...
116 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp
117 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\QtCore"
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
--------------------------------------------------------------------------------