MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / main

Function main

tools/pktdumper.c:53–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51}
52
53int main(int argc, char **argv)
54{
55 char fntemplate[FILENAME_BUF_SIZE];
56 char fntemplate2[FILENAME_BUF_SIZE];
57 char pktfilename[FILENAME_BUF_SIZE];
58 AVFormatContext *fctx = NULL;
59 AVPacket *pkt;
60 int64_t pktnum = 0;
61 int64_t maxpkts = 0;
62 int donotquit = 0;
63 int nowrite = 0;
64 int err;
65
66 if ((argc > 1) && !strncmp(argv[1], "-", 1)) {
67 if (strchr(argv[1], 'w'))
68 donotquit = 1;
69 if (strchr(argv[1], 'n'))
70 nowrite = 1;
71 argv++;
72 argc--;
73 }
74 if (argc < 2)
75 return usage(1);
76 if (argc > 2)
77 maxpkts = atoi(argv[2]);
78 av_strlcpy(fntemplate, argv[1], sizeof(fntemplate));
79 if (strrchr(argv[1], '/'))
80 av_strlcpy(fntemplate, strrchr(argv[1], '/') + 1, sizeof(fntemplate));
81 if (strrchr(fntemplate, '.'))
82 *strrchr(fntemplate, '.') = '\0';
83 if (strchr(fntemplate, '%')) {
84 fprintf(stderr, "cannot use filenames containing '%%'\n");
85 return usage(1);
86 }
87 if (strlen(fntemplate) + sizeof(PKTFILESUFF) >= sizeof(fntemplate) - 1) {
88 fprintf(stderr, "filename too long\n");
89 return usage(1);
90 }
91
92 err = avformat_open_input(&fctx, argv[1], NULL, NULL);
93 if (err < 0) {
94 fprintf(stderr, "cannot open input: error %d\n", err);
95 return 1;
96 }
97
98 err = avformat_find_stream_info(fctx, NULL);
99 if (err < 0) {
100 fprintf(stderr, "avformat_find_stream_info: error %d\n", err);
101 return 1;
102 }
103
104 pkt = av_packet_alloc();
105 if (!pkt) {
106 fprintf(stderr, "av_packet_alloc: error %d\n", AVERROR(ENOMEM));
107 return 1;
108 }
109
110 strcpy(fntemplate2, fntemplate);

Callers

nothing calls this directly

Calls 11

av_strlcpyFunction · 0.85
avformat_open_inputFunction · 0.85
av_packet_allocFunction · 0.85
closeFunction · 0.85
av_read_frameFunction · 0.85
av_packet_unrefFunction · 0.85
av_packet_freeFunction · 0.85
avformat_close_inputFunction · 0.85
av_usleepFunction · 0.85
usageFunction · 0.70

Tested by

no test coverage detected