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

Function main

tools/seek_print.c:44–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42}
43
44int main(int argc, char **argv)
45{
46 int opt, ret, stream, flags;
47 const char *filename;
48 AVFormatContext *avf = NULL;
49 int64_t min_ts, max_ts, ts;
50 AVPacket packet;
51
52 while ((opt = getopt(argc, argv, "h")) != -1) {
53 switch (opt) {
54 case 'h':
55 usage(0);
56 default:
57 usage(1);
58 }
59 }
60 argc -= optind;
61 argv += optind;
62 if (!argc)
63 usage(1);
64 filename = *argv;
65 argv++;
66 argc--;
67
68 if ((ret = avformat_open_input(&avf, filename, NULL, NULL)) < 0) {
69 fprintf(stderr, "%s: %s\n", filename, av_err2str(ret));
70 return 1;
71 }
72 if ((ret = avformat_find_stream_info(avf, NULL)) < 0) {
73 fprintf(stderr, "%s: could not find codec parameters: %s\n", filename,
74 av_err2str(ret));
75 return 1;
76 }
77
78 for (; argc; argc--, argv++) {
79 if (!strcmp(*argv, "read")) {
80 ret = av_read_frame(avf, &packet);
81 if (ret < 0) {
82 printf("read: %d (%s)\n", ret, av_err2str(ret));
83 } else {
84 AVRational *tb = &avf->streams[packet.stream_index]->time_base;
85 printf("read: %d size=%d stream=%d dts=%s (%s) pts=%s (%s)\n",
86 ret, packet.size, packet.stream_index,
87 av_ts2str(packet.dts), av_ts2timestr(packet.dts, tb),
88 av_ts2str(packet.pts), av_ts2timestr(packet.pts, tb));
89 av_packet_unref(&packet);
90 }
91 } else if (sscanf(*argv, "seek:%i:%"SCNi64":%"SCNi64":%"SCNi64":%i",
92 &stream, &min_ts, &ts, &max_ts, &flags) == 5) {
93 ret = avformat_seek_file(avf, stream, min_ts, ts, max_ts, flags);
94 printf("seek: %d (%s)\n", ret, av_err2str(ret));
95 } else {
96 fprintf(stderr, "'%s': unknown command\n", *argv);
97 return 1;
98 }
99 }
100
101 avformat_close_input(&avf);

Callers

nothing calls this directly

Calls 8

getoptFunction · 0.85
avformat_open_inputFunction · 0.85
av_read_frameFunction · 0.85
av_packet_unrefFunction · 0.85
avformat_seek_fileFunction · 0.85
avformat_close_inputFunction · 0.85
usageFunction · 0.70

Tested by

no test coverage detected