-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathavformat_context.cpp
More file actions
44 lines (31 loc) · 854 Bytes
/
avformat_context.cpp
File metadata and controls
44 lines (31 loc) · 854 Bytes
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
#include <stdio.h>
// libavformat deals with the capsule of video
// if your code c++, you can include c headers with an extern encapsulation
extern "C"
{
#include <libavformat/avformat.h>
}
int main()
{
AVFormatContext *fmt_ctx = NULL;
int ret;
const char *filename = "D:\\Wildlife.wmv";
//av_register_all();
//fill format context with file info
if ((ret = avformat_open_input(&fmt_ctx, filename, NULL, NULL)))
return ret;
// get streams info from format context
if ((ret = avformat_find_stream_info(fmt_ctx, NULL)) < 0) {
av_log(NULL, AV_LOG_ERROR, "Cannot find stream information\n");
return ret;
}
// loop streams and dump info
for (int i = 0; i < fmt_ctx->nb_streams; i++)
{
av_dump_format(fmt_ctx, i, filename, false);
}
// close format context
avformat_close_input(&fmt_ctx);
system("PAUSE");
return 0;
}