From 078e97c9bcf9480bbbc5f55edb909e01dad47190 Mon Sep 17 00:00:00 2001 From: Jan Klemkow Date: Thu, 10 Jan 2013 17:31:15 +0100 Subject: mv struct and wip state --- src/advtime.c | 32 ++++++++++++++++++++++++++++---- src/video_decode.c | 8 -------- src/video_decode.h | 12 ++++++++++++ 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/src/advtime.c b/src/advtime.c index 265d18c..4c329da 100644 --- a/src/advtime.c +++ b/src/advtime.c @@ -4,6 +4,8 @@ #include #include +#include + #include "video_decode.h" #include "util.h" @@ -97,20 +99,42 @@ main(int argc, char **argv) if (ret < 0) return -ret; + printf("fps: %d\n", vd->fmt_ctx->fps_probe_size); + printf("streams: %d\n", vd->fmt_ctx->nb_streams); + printf("filename: %s\n", vd->fmt_ctx->filename); + printf("streams: %d\n", vd->fmt_ctx->streams[0]->duration); + printf("duration: %d\n", vd->fmt_ctx->streams[1]->duration); + printf("nb_frames: %d\n", vd->fmt_ctx->streams[0]->nb_frames); + printf("avg frame rate: %f\n", + av_q2d(vd->fmt_ctx->streams[0]->avg_frame_rate)); + printf("real frame rate: %f\n", + av_q2d(vd->fmt_ctx->streams[0]->r_frame_rate)); + printf("first: %ji\n", vd->fmt_ctx->streams[0]->first_dts); + printf("cur: %ji\n", vd->fmt_ctx->streams[0]->cur_dts); + printf("reference: %ji\n", vd->fmt_ctx->streams[0]->reference_dts); + for (int i = 0; video_decode_get_frame(vd, &frame_b) > 0; ++i) { - printf("%d\t", i); +// printf("first: %ji\t", vd->fmt_ctx->streams[0]->first_dts); +// printf("cur: %ji\t", vd->fmt_ctx->streams[0]->cur_dts); +// printf("reference: %ji\n", vd->fmt_ctx->streams[0]->reference_dts); + + +// printf("%d\t", i); if (average_flag == 1) printf("%f", frame_average(frame_a)); if (average_flag == 1 && diff_flag == 1) printf("\t"); - if (diff_flag == 1) - printf("%f", diff = frame_diff(frame_a, frame_b)); + if (diff_flag == 1) { + diff = frame_diff(frame_a, frame_b); +// printf("%f", diff); + } if (diff > 40.0) { + printf("cut: %d\n", i); snprintf(filename, BUFSIZ, "img/%04i.pgm", i); frame_mix(frame_a, frame_b); if (pgm_save(frame_a->data, frame_a->stride, @@ -119,7 +143,7 @@ main(int argc, char **argv) exit(EXIT_FAILURE); } - printf("\n"); +// printf("\n"); video_decode_free_frame(&frame_a); frame_a = frame_b; } diff --git a/src/video_decode.c b/src/video_decode.c index b3c8e4d..993fd14 100644 --- a/src/video_decode.c +++ b/src/video_decode.c @@ -10,14 +10,6 @@ #include #include - -struct video_decode { - AVFormatContext *fmt_ctx; - AVCodecContext *codec_ctx; - AVCodec *codec; - int stream; -}; - struct video_frame_priv { struct video_frame base; AVFrame *frame; diff --git a/src/video_decode.h b/src/video_decode.h index 2505b8b..9da7f63 100644 --- a/src/video_decode.h +++ b/src/video_decode.h @@ -2,6 +2,11 @@ #define _VIDEO_DECODE_H_ #include +#include +#include +#include +#include +#include struct video_decode; struct video_frame { @@ -9,6 +14,13 @@ struct video_frame { int width, height, stride; }; +struct video_decode { + AVFormatContext *fmt_ctx; + AVCodecContext *codec_ctx; + AVCodec *codec; + int stream; +}; + int video_decode_init(struct video_decode **vd, char *file, int64_t timestamp); -- cgit