-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathVideoExample_1.cpp
More file actions
66 lines (51 loc) · 2.07 KB
/
VideoExample_1.cpp
File metadata and controls
66 lines (51 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* Created (25/04/2017) by Paolo-Pr.
* This file is part of Live Asynchronous Audio Video Library.
*
* Live Asynchronous Audio Video Library is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* Live Asynchronous Audio Video Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Live Asynchronous Audio Video Library. If not, see <http://www.gnu.org/licenses/>.
* --------------------------------------------
*
* This example shows how to grab video from a V4L camera,
* encode (H264) and stream it through HTTP with a MPEGTS container.
* The stream's address is printed in the output log.
*
*/
#include "LAAV.hpp"
using namespace laav;
typedef UnsignedConstant<640> WIDTH;
typedef UnsignedConstant<480> HEIGHT;
int main(int argc, char** argv)
{
if (argc < 2)
{
std::cout << "Usage: " << argv[0] << " /path/to/v4l/device" << std::endl;
return 1;
}
LAAVLogLevel = 1;
SharedEventsCatcher eventsCatcher = EventsManager::createSharedEventsCatcher();
V4L2Grabber <YUYV422_PACKED, WIDTH, HEIGHT>
vGrab(eventsCatcher, argv[1], DEFAULT_FRAMERATE);
// Needed for the H264 encoder (it accepts only PLANAR formats)
FFMPEGVideoConverter <YUYV422_PACKED, WIDTH, HEIGHT, YUV422_PLANAR, WIDTH, HEIGHT>
vConv;
FFMPEGH264Encoder <YUV422_PLANAR, WIDTH, HEIGHT>
vEnc(DEFAULT_BITRATE, 5, H264_ULTRAFAST, H264_DEFAULT_PROFILE, H264_DEFAULT_TUNE);
HTTPVideoStreamer <MPEGTS, H264, WIDTH, HEIGHT>
vStream(eventsCatcher, "127.0.0.1", 8080);
while (!LAAVStop)
{
vGrab >> vConv >> vEnc >> vStream;
eventsCatcher->catchNextEvent();
}
return 0;
}