diff options
author | Jan Klemkow <j.klemkow@wemelug.de> | 2013-02-01 15:20:31 +0100 |
---|---|---|
committer | Jan Klemkow <j.klemkow@wemelug.de> | 2013-02-01 15:32:27 +0100 |
commit | da738e82a0bdd1379efa0560c336f030a85f39a1 (patch) | |
tree | abaa7196e25156fb192cb6c6e21cb00c76805bd7 /src | |
parent | e3ad9b828d6faaa7c14e1aaae59a3fa2605710af (diff) | |
download | advtime-da738e82a0bdd1379efa0560c336f030a85f39a1.tar.gz advtime-da738e82a0bdd1379efa0560c336f030a85f39a1.tar.bz2 advtime-da738e82a0bdd1379efa0560c336f030a85f39a1.zip |
improve output posebilities
Diffstat (limited to 'src')
-rw-r--r-- | src/cuttime.c | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/src/cuttime.c b/src/cuttime.c index 29c8735..51b80f9 100644 --- a/src/cuttime.c +++ b/src/cuttime.c @@ -22,14 +22,17 @@ static void usage(void) { fprintf(stderr, - "cuttime [-adfhs] FILE\n" + "cuttime [-adDfhsT] FILE\n" "\n" "OPTIONS\n" "\t-a\tcalculate average color of a frame\n" - "\t-d\tcalculate difference betweenprev and next frame\n" - "\t-f\tprint frame number\n" + "\t-d\tcalculate difference between prev and next frame and\n" + "\t\tslope of this value\n" + "\t-D\tprint diff and slope of diff (implies -d)\n" + "\t-f\tprint frame number of every frame\n" "\t-h\tprint this help message\n" - "\t-s\tsave frame from detected cut\n"); + "\t-s\tsave frame from detected cut\n" + "\t-T\tprint timestamp of every frame\n"); exit(EXIT_FAILURE); } @@ -41,11 +44,12 @@ main(int argc, char **argv) struct video_frame *frame_a = NULL, *frame_b = NULL; int ret, ch; int diff_flag = 0, average_flag = 0, frame_flag = 0, showcut_flag = 0; + int print_diff_flag = 0, time_flag = 0; int64_t timestamp = 0; - double diff = 0.0, old_diff = 0.0; + double diff = 0.0, prev_diff = 0.0, diff_slope = 0.0; char filename[BUFSIZ]; - while ((ch = getopt(argc, argv, "adfsh")) != -1) { + while ((ch = getopt(argc, argv, "adDfsTh")) != -1) { switch (ch) { case 'a': average_flag = 1; @@ -53,12 +57,19 @@ main(int argc, char **argv) case 'd': diff_flag = 1; break; + case 'D': + print_diff_flag = 1; + diff_flag = 1; /* implies -d */ + break; case 'f': frame_flag = 1; break; case 's': showcut_flag = 1; break; + case 'T': + time_flag = 1; + break; case 'h': default: usage(); @@ -87,7 +98,10 @@ main(int argc, char **argv) if (frame_flag) /* print frame number */ printf("%d\t", i); - if (average_flag) /* print frame average */ + if (time_flag) + printf("%jd\t", frame_b->dts); + + if (average_flag) /* print frame average */ printf("%f", frame_average(frame_a)); if (average_flag && diff_flag) @@ -95,9 +109,11 @@ main(int argc, char **argv) if (diff_flag) { diff = frame_diff(frame_a, frame_b); -// printf("%f", diff); -// printf("\t%f", (diff - old_diff)); - old_diff = diff; + diff_slope = diff - prev_diff; + prev_diff = diff; + + if (print_diff_flag) + printf("%f\t%f\t", diff, diff_slope); } if (diff > 40.0) { |