Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Implement progress reporting for commandline version #3

Open
wants to merge 1 commit into from

1 participant

@oaubert

Specifying -p will output information on stderr, in the form

progress current_position_in_ms total_duration_in_ms
shot current_position_in_ms total_duration_in_ms

@oaubert oaubert Implement progress information reporting for command line version
Specifying -p will output information on stderr, in the form

progress current_position_in_ms total_duration_in_ms
shot current_position_in_ms total_duration_in_ms
1fb145b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 14, 2013
  1. @oaubert

    Implement progress information reporting for command line version

    oaubert authored
    Specifying -p will output information on stderr, in the form
    
    progress current_position_in_ms total_duration_in_ms
    shot current_position_in_ms total_duration_in_ms
This page is out of date. Refresh to see the latest.
Showing with 27 additions and 4 deletions.
  1. +6 −1 src/commandline.cc
  2. +12 −3 src/film.cc
  3. +9 −0 src/film.h
View
7 src/commandline.cc
@@ -47,6 +47,7 @@ show_help (char **argv)
"Shotdetect (IRI - johmathe - $Id: main.cpp 164 2007-10-13 23:53:21Z johmathe $)\n"
"-h : show this help\n"
"-i file : input file path\n"
+ "-p : output progress report information\n"
"-o path : output path\n"
"-s threshold : threshold\n"
"-w : generate xml of waveform\n"
@@ -72,7 +73,7 @@ main (int argc, char **argv)
f.threshold=60;
for (;;) {
- int c = getopt (argc, argv, "?ht:i:o:s:flwvmr");
+ int c = getopt (argc, argv, "?ht:i:o:s:flpwvmr");
if (c < 0) {
break;
@@ -104,6 +105,10 @@ main (int argc, char **argv)
f.set_thumb(true);
break;
+ case 'p':
+ f.set_progress(true);
+ break;
+
/* generer le xml pour les donnees video */
case 'v':
f.set_video(true);
View
15 src/film.cc
@@ -36,6 +36,13 @@ extern "C" {
int film::idfilm = 0;
+void film::log_progress(string type, int position, int total)
+{
+ if (this->get_progress()) {
+ cerr << type << " " << position << " " << total << endl;
+ }
+}
+
void film::do_stats(int frame_number)
{
double perctmp = percent;
@@ -138,9 +145,7 @@ void film::CompareFrame (AVFrame * pFrame, AVFrame * pFramePrev)
s.msbegin = int ((frame_number * 1000) / fps);
s.myid = shots.back ().myid + 1;
-#ifdef DEBUG
- cerr << "Shot log :: " << s.msbegin << endl;
-#endif
+ this->log_progress("shot", s.msbegin, duration.mstotal);
/*
* Convert to ms
@@ -397,6 +402,10 @@ int film::process ()
if (frameFinished) {
frame_number = pCodecCtx->frame_number; // Current frame number
+ // Report progress information every 100 frames
+ if (frame_number % 100 == 0) {
+ this->log_progress("progress", int((frame_number * 1000) / fps), duration.mstotal);
+ }
// Convert the image into RGB24
if (! img_convert_ctx) {
img_convert_ctx = sws_getContext(width, height, pCodecCtx->pix_fmt,
View
9 src/film.h
@@ -187,6 +187,8 @@ class film
double percent;
/* Showing state started */
bool show_started;
+ /* Output progress information */
+ bool progress;
xml *x;
bool display;
@@ -194,6 +196,7 @@ class film
void process_audio ();
void shotlog(string message);
void create_main_dir(void);
+ void log_progress(string message, int position, int total);
/* Constructor */
film ();
@@ -241,6 +244,9 @@ class film
inline void set_title(string title) {
this->title = title;
};
+ inline void set_progress(bool progress) {
+ this->progress = progress;
+ };
inline bool get_first_img(void) {
return this->first_img_set ;
@@ -269,6 +275,9 @@ class film
inline double get_fps(void) {
return this->fps ;
};
+ inline bool get_progress(void) {
+ return this->progress ;
+ };
};
Something went wrong with that request. Please try again.