summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/findcut.c14
-rwxr-xr-xsrc/rmcut.sh2
2 files changed, 11 insertions, 5 deletions
diff --git a/src/findcut.c b/src/findcut.c
index b5b0976..816b27b 100644
--- a/src/findcut.c
+++ b/src/findcut.c
@@ -29,12 +29,12 @@ main(int argc, char **argv)
struct video_decode *cut_vd;
struct video_frame *cur_frame = NULL, *cut_frame = NULL;
int ret, ch;
- int diff_flag = 0, time_flag = 0, range_flag = 0;
+ int diff_flag = 0, time_flag = 0, range_flag = 0, last_flag = 0;
int64_t timestamp = 0;
int64_t threshold = 10;
double diff = 0.0;
- while ((ch = getopt(argc, argv, "dtThr")) != -1) {
+ while ((ch = getopt(argc, argv, "dtThrl")) != -1) {
switch (ch) {
case 'd':
diff_flag = 1; /* print diff of every frame */
@@ -48,6 +48,9 @@ main(int argc, char **argv)
case 'r':
range_flag = 1;
break;
+ case 'l':
+ last_flag = 1;
+ break;
case 'h':
default:
usage();
@@ -71,14 +74,16 @@ main(int argc, char **argv)
if (ret < 0)
return -ret;
+ int64_t last_time=0;
for (int i = 0; video_decode_get_frame(video_vd, &cur_frame) > 0; ++i) {
diff = frame_diff(cut_frame, cur_frame);
if (diff <= threshold || diff_flag) {
+ int64_t time = last_flag ? last_time : cur_frame->dts;
if (time_flag)
- printf("%" PRId64, cur_frame->dts);
+ printf("%" PRId64, time);
else
- print_time(cur_frame->dts);
+ print_time(time);
if (range_flag) {
printf(" ");
@@ -92,6 +97,7 @@ main(int argc, char **argv)
printf(" %f\n", diff);
fflush(stdout);
}
+ last_time=cur_frame->dts;
}
video_decode_free_frame(&cur_frame);
diff --git a/src/rmcut.sh b/src/rmcut.sh
index ee293bf..2d7e93c 100755
--- a/src/rmcut.sh
+++ b/src/rmcut.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-./cutint.sh $1 $3 `(echo 0; ./findcut -rT $1 $2) | \
+./cutint.sh $1 $3 `(echo 0; ./findcut -rlT $1 $2) | \
sed "s/ /\n/g" | while read time
do
read end