| 1 | #include <stdio.h>
|
|---|
| 2 | #include <libavformat/avformat.h>
|
|---|
| 3 |
|
|---|
| 4 | #define src_filename argv[1]
|
|---|
| 5 |
|
|---|
| 6 | int main (int argc, char **argv)
|
|---|
| 7 | {
|
|---|
| 8 | int r;
|
|---|
| 9 | AVFormatContext *fmt_ctx = NULL;
|
|---|
| 10 |
|
|---|
| 11 | /* register all formats and codecs */
|
|---|
| 12 | av_register_all();
|
|---|
| 13 |
|
|---|
| 14 | /* open input file, and allocate format context */
|
|---|
| 15 | if (avformat_open_input(&fmt_ctx, src_filename, NULL, NULL) < 0) {
|
|---|
| 16 | fprintf(stderr, "Could not open source file %s\n", src_filename);
|
|---|
| 17 | exit(1);
|
|---|
| 18 | }
|
|---|
| 19 |
|
|---|
| 20 | /* retrieve stream information */
|
|---|
| 21 | if (avformat_find_stream_info(fmt_ctx, NULL) < 0) {
|
|---|
| 22 | fprintf(stderr, "Could not find stream information\n");
|
|---|
| 23 | exit(1);
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | r = av_seek_frame(fmt_ctx, -1, fmt_ctx->start_time, AVSEEK_FLAG_BACKWARD/* | AVSEEK_FLAG_ANY*/);
|
|---|
| 27 | printf("av_seek_frame=%d\n", r);
|
|---|
| 28 |
|
|---|
| 29 | avformat_close_input(&fmt_ctx);
|
|---|
| 30 |
|
|---|
| 31 | return 0;
|
|---|
| 32 | };
|
|---|