Calculation of remaining time in video record mode - done - page 2 - General Discussion and Assistance - CHDK Forum

Poll

Do you think this feature would be useful?

Yes, i'd really like to have that feature
10 (66.7%)
Nice to have, not important though
4 (26.7%)
Don't need it
1 (6.7%)

Total Members Voted: 15

Calculation of remaining time in video record mode - done

  • 20 Replies
  • 12943 Views
*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Calculation of remaining time in video record mode
« Reply #10 on: 18 / February / 2008, 16:46:24 »
Advertisements
Code: (c) [Select]
// since this gets called in gui_osd_draw(), the main loop (?) in gui_osd.c,
// it should follow the appropiate naming convention, looks better ;)
// Note: Also needs an 'extern void gui_osd_draw_movie_time_left();' in gui_osd.h
 
void gui_osd_draw_movie_time_left()  {
 
static int locked = 0,card_used, init_space, elapsed, avg_use, time_left;
static long init_time;
static int movie_running = 0,started = 0;
static int init = 0;
static unsigned int skipcalls = 15;

int o=(mode_get() & MODE_MASK), m=(mode_get() & MODE_SHOOTING_MASK);
unsigned int hour=0, min=0, sec=0;
 
    // allow it to be turned on/off
    // if (!conf.show_movie_time_left) return;
 
    if ( (o != MODE_REC) || (m != MODE_VIDEO_STD) )  return;
 
    if (kbd_is_key_pressed(KEY_SHOOT_FULL) == 1) 
    {
    if (locked == 0)
    {
    movie_running = !movie_running;
    locked = 1;
   }
   }
    if (movie_running == 0)  {
        // it's off, reset init
        init = 0;
        started = 0;
        return;
        }
    else {
        //movie recording engaged
        if( !init )  {
            // initialize
            if (started == 0)
            {
            init_space = GetFreeCardSpaceKb();
            init_time  = get_tick_count();
            init = 1;
            started = 1;
            }
            }
        else {
            // already running
           // if (--skipcalls ==0) {
                // only calc at every 15 th interrupt (should equal every 1 sec for about 15 interupt calls/sec)
                card_used = init_space - GetFreeCardSpaceKb();
                // Note: there's 1000 ticks to a second
                elapsed = (int) ( get_tick_count() - init_time ) / 1000;
                if (elapsed>2)
                {
                locked = 0;
                }
                // End Note
            //    if (elapsed < 2) return;    // initially give it a minimum of say 10 secs to settle ...
                avg_use = card_used / elapsed;  // running average Kb/sec
                time_left = (GetFreeCardSpaceKb() / avg_use);
                hour = time_left / 3600;
                min = (time_left % 3600) / 60;
                sec = (time_left % 3600) % 60;
                //skipcalls = 15;
             //   }
            // called at every interrupt   
          //   sprintf(osd_buf, "%4d - %4d", card_used/1024,elapsed);
//              draw_string( 50, 50, osd_buf, conf.osd_color);
 sprintf(osd_buf, "Avg. %d KB/s ; %2d:%2d:%2d left", avg_use, hour, min, sec);
 draw_string( 50, 50, osd_buf, conf.osd_color);
            //sprintf(osd_buf, "Avg. %d KB/s ; %2d:%2d:%2d left", avg_use, hour, min, sec);
            // use this if we decide to make it configurable ....
            // draw_string(conf.mode_movie_time_left.x, conf.mode_movie_time_left.y, osd_buf, conf.osd_color);
            // for testing ...
//              sprintf(osd_buf, "%d - %u", init_space, ttm );
//            draw_string( 50, 50, osd_buf, conf.osd_color);
            // 689425
            }
        }
 
}


this kinda works.forget the commented stuff. it doesnt stop when you press button again. i think there was/is a problem with your skipcalls thingy.

edit: added locked variable. now you can stop recording. doesnt work right way though - you can't start it again.

by the way, this really works. i set the qualitiy to 0.25 and it calculates that there are about 30 minutes left to record. 800 megs free.about 450 kb/s.canon value (when stopped) says there is about 8 minutes left to record.
i call this progress! \o/

edit: now the value is drawn onto display from the beginning. of course it is not stable during the first seconds.
« Last Edit: 18 / February / 2008, 18:58:32 by PhyrePhoX »

*

Offline whim

  • ******
  • 2046
  • A495/590/620/630 ixus70/115/220/230/300/870 S95
Re: Calculation of remaining time in video record mode
« Reply #11 on: 18 / February / 2008, 17:03:08 »
@PhyrePhox
Sorry, haven't checked the forum for a couple of hours. I guess your right. This is not gonna be quick.
I think I'm gonna experiment with making the routine insensitive to over-long full-shoot keypresses,
maybe by making it abort out of the routine for say 10- 15 times after it detected a full-shoot.
Or do you have any better ideas ?

wim

BTW have you seen how many keyboard routines there are   kbd_is_key_pressed, kbd_is_key_clicked etc.


*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Calculation of remaining time in video record mode
« Reply #12 on: 18 / February / 2008, 17:07:37 »
the kbd routine is not the best solution anyway, since the S3is (and the other s series cams) have an extra button.
there MUST be another way for finding out if the film is rolling.

edit: my locked variable does just that , what you just proposed. mind you, i edited my above post.
if you press the button the first time, locked is set to 1. after 2 seconds it is set to 0, so you can press again.
« Last Edit: 18 / February / 2008, 17:09:48 by PhyrePhoX »

*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Calculation of remaining time in video record mode
« Reply #13 on: 18 / February / 2008, 17:31:17 »
new  post, cant edit the other one everytime i find out something new :D
i set video bitrate to 3x - recording started, however there was a Red exclamation mark every few seconds. i guess either my sdcard is too slow, or my a620 in general is too slow to write.
in 2x setting this still happens.
i have 2 sd cards, one significantly faster than the other, will test it now.

test with 1.5 setting.

canon value: 3 minutes 19 remaining.
my value after 1 minute: 1:12 left /about 3 megs /s)
after 2 minutes: 0:15 left (40 mb)

final length of movie: 2:06 (sd card was full).
that makes an estimated value of my function of about 2:12.
problem is that when recording is finished, camera writes some extra stuff, i guess avi header and container or something.

uh,. red exclamation mark all the time, gotta find out the meaning :D

edit: hm, gotta find out the video key for s3is so i can compile a testbuild for our main betatester barney :D

edit: 2nd test:
video setting: 1x bitrate (normal setting). 30 fps & 640+480 res.
mb left: 209.
time left (canon value): 1:49
my function;
after 30 secs: 1:31 left (about 1760 kb/s)
after 60 secs: 1:02 left (about 1754 kb/s)
after 90 secs:0:32 left (about 1750 kb/s)
final length of movie: 1:58.

this is quiete precise,imo, maybe we should subtract an extra 10 seconds from the output just to make sure.
« Last Edit: 18 / February / 2008, 18:26:21 by PhyrePhoX »

*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Calculation of remaining time in video record mode
« Reply #14 on: 20 / February / 2008, 07:21:20 »
by the way, ewavr let me know a few things:

Quote
in memory browser I can find many variables concerning current record time.
For example, in your A620 int variable at 0x73CF4 is current number of captured frames (and if interesting 0x73D0C is limit of frames for current video mode). If this variable changes, video record is in progress.

You can find this variables at top of sub_FFD2E0D8_my() in movie_rec.c for a620.
if we have these values for each camera, we might be able to circumvent catching key presses.
on the other hand, we also could check for changes in freediskspace to start our function, and end it when there is nothing written to disk anymore. lots of ideas :)

*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Calculation of remaining time in video record mode
« Reply #15 on: 03 / March / 2008, 18:01:37 »
i finally managed to add a poll to the thread (thanks barney!) to maybe get a feedback on this subject. the feature itself is almost done in theory, implementation will take some time and brains though (most of it is done already, see latest posts). thats why i added the poll. though eventually i will code it anyway :D
« Last Edit: 03 / March / 2008, 18:34:06 by PhyrePhoX »

*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Calculation of remaining time in video record mode
« Reply #16 on: 05 / April / 2008, 07:02:55 »
now that we finally have a way to find out if a movie record is in effect (no matter if s3is or AXXX model) i will make some progress here. the function in #10 basically worked, now i gotta integrate the check for movie_status (if bigger than 1, a movie recording is in effect), clean everything up, add a switch and a new osd item.

this kinda is a reminder to myself, but feel free to post ideas & suggestions if you feel so :)

Re: Calculation of remaining time in video record mode
« Reply #17 on: 05 / April / 2008, 07:18:44 »
Deleted
« Last Edit: 22 / April / 2008, 12:16:00 by Barney Fife »
[acseven/admin commented out: please refrain from more direct offensive language to any user. FW complaints to me] I felt it imperative to withdraw my TOTAL participation. Nobody has my permission, nor the right, to reinstate MY posts. Make-do with my quoted text in others' replies only. Bye

*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Calculation of remaining time in video record mode
« Reply #18 on: 05 / April / 2008, 10:16:22 »
Yeah you are right about this effect,i like it alot. Time will tell what the other practical uses of that finding by ewavr will be.funny,i get the feeling ewavr is a canon engineer,not a reverse engineer,i mean,look at the speed he is answering to my inquiries about the firmware with. :)

*

Offline ewavr

  • ****
  • 1057
  • A710IS
Re: Calculation of remaining time in video record mode
« Reply #19 on: 05 / April / 2008, 16:00:10 »
i get the feeling ewavr is a canon engineer,not a reverse engineer,i mean,look at the speed he is answering to my inquiries about the firmware with. :)
:D
Of course, I make this investigation some time ago. I know three methods to pause/resume movie recording, but all of them caused sound de-sync :(

 

Related Topics


SimplePortal © 2008-2014, SimplePortal