MCPcopy Create free account
hub / github.com/davisking/dlib / main

Function main

examples/ffmpeg_video_decoding_ex.cpp:46–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44using namespace dlib::ffmpeg;
45
46int main(const int argc, const char** argv)
47try
48{
49 command_line_parser parser;
50 parser.add_option("i", "input video encoded stream. e.g. dlib/test/ffmpeg_data/MOT20-08-raw.h264", 1);
51 parser.add_option("codec", "codec name. e.g. h264", 1);
52 parser.set_group_name("Help Options");
53 parser.add_option("h", "alias of --help");
54 parser.add_option("help", "display this message and exit");
55
56 parser.parse(argc, argv);
57 const char* one_time_opts[] = {"i"};
58 parser.check_one_time_options(one_time_opts);
59
60 if (parser.option("h") || parser.option("help"))
61 {
62 parser.print_options();
63 return 0;
64 }
65
66 const std::string filepath = parser.option("i").argument();
67 const std::string codec = parser.option("codec").argument();
68
69 decoder dec([&] {
70 decoder::args args;
71 args.codec_name = codec;
72 return args;
73 }());
74
75 if (!dec.is_open())
76 {
77 printf("Failed to create decoder.\n");
78 return EXIT_FAILURE;
79 }
80
81 image_window win;
82
83 const auto callback = [&](array2d<rgb_pixel>& img)
84 {
85 win.set_image(img);
86 };
87
88 ifstream fin{filepath, std::ios::binary};
89 std::vector<char> buf(1024);
90
91 while (fin)
92 {
93 fin.read(buf.data(), buf.size());
94 size_t ret = fin.gcount();
95 dec.push((const uint8_t*)buf.data(), ret, wrap(callback));
96 }
97
98 dec.flush(wrap(callback));
99
100 return EXIT_SUCCESS;
101}
102catch (const std::exception& e)
103{

Callers

nothing calls this directly

Calls 11

parseMethod · 0.80
print_optionsMethod · 0.80
readMethod · 0.80
wrapFunction · 0.50
is_openMethod · 0.45
set_imageMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
pushMethod · 0.45
flushMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected