PhyrePhoX
Global Moderator
Hero Member
   
Karma: +139/-37
Offline
Posts: 1818
Coders Humiliate DSLR Kiddies
|
 |
« on: 17 / February / 2008, 23:41:33 » |
|
edit: read remaining video time,overrides-cusomizations,no-raw@video,just _random_ stuff  - it is done Hi, as my other project ( Calculation of remaining shots with RAW - done  ) seems to be finished very soon, i want to start the second one, a small one. it's also having to do with calculating stuff, this time it is planned that there will be a new OSD item that tells you the remaining time when in video record mode. this feature is neccessary (in my eyes) for a few reasons: the built-in canon counter does only show the remaining time in idle mode, before shooting the movie. during recording you only see the time since the start of recording. even IF canon would show you everything while recording, it wouldnt make much sense if you choose to override the movie settings (quality, bitrate) via chdk. as a temporary workaround for finding out how long you can record a movie (DURING shooting) you can use my filespace icon or TXT (in megabyte) (from the thread mentioned above - soon to be in official trunk). I quickly searched the sourcecode, but i couldnt find anything i could use to find out if a movie recording is being made. i can only check if we are in playback mode or in rec mode (and WHICH rec mode, i.e. C, M or movie). i guess i can somehow circumvent this, but it will not be as accurate. whim already had an idea for implementing it, pseudo-code wise: // pseudo-code snippet for calc time left
if (video_recording_started) { original_space = GetFreeCardSpaceKb(); original_time = get_current_time();
while(video_recording) { space_eaten = original_space - GetFreeCardSpaceKb(); time_elapsed = get_current_time() - original_time;
avg_use = space_eaten / time_elapsed; // Kb/sec
time_left = GetFreeCardSpaceKb() / avg_use } } but if we lack a check for "if video_rec started/running" it will be difficult. devs - any ideas?
|
|
|
|
« Last Edit: 06 / April / 2008, 23:59:10 by PhyrePhoX »
|
Logged
|
|
|
|
whim
Hero Member
   
Karma: +83/-0
Online
Posts: 805
A620/A630/i70_sd1000
|
 |
« Reply #1 on: 18 / February / 2008, 00:14:48 » |
|
Hi PhyrePhox - some out-loud-thinking here:
To start a video, what do we do --> switch to video mode (we can detect that) then we press shoot full (we can detect that too)
wim
|
|
|
|
|
Logged
|
|
|
|
PhyrePhoX
Global Moderator
Hero Member
   
Karma: +139/-37
Offline
Posts: 1818
Coders Humiliate DSLR Kiddies
|
 |
« Reply #2 on: 18 / February / 2008, 01:11:09 » |
|
good idea! GeSHi (c): static void gui_space_draw_mb() { int o=mode_get(),m=(mode_get()&MODE_SHOOTING_MASK); static int a; if (((o&MODE_MASK) == MODE_REC) & ((m&MODE_SHOOTING_MASK)==MODE_VIDEO_STD)) { if (kbd_is_key_pressed(KEY_SHOOT_FULL) == 1) { a=!a; } if (a==1) { draw_string(100, 100, "SHOOT!", conf.osd_color); } else { draw_string(100,100, "NOT SHOOT", conf.osd_color); } }Created by GeSHI 1.0.7.20
you have to disable the check for kbd_is_key_pressed(KEY_SHOOT_HALF)!=1) down in that file when gui_space_draw_mb is called in order for that to work. this actually works, but: since this is checked about 12 times a second, a is overwritten again, because no human can press a button within a timeframe of 1/12 s. we can extend that time (like i did in the RAW icon function) but then we maybe miss that the button is being pressed. there has got to be a way to find out if vide_rec is running. but i guess i'd have to analyze firmware or something. propcases doesnt seem to help here either. edit: i will just add a timecheck...  edit2: hmm, i just patched gui_osd_draw_clock to show the seconds as well. might come in handy when you want to take a picture at an exact moment. edit3: hm, too tired to test it. but we're getting there 
|
|
|
|
« Last Edit: 18 / February / 2008, 01:38:51 by PhyrePhoX »
|
Logged
|
|
|
|
|
Barney Fife
|
 |
« Reply #3 on: 18 / February / 2008, 01:33:36 » |
|
Deleted
|
|
|
|
« Last Edit: 22 / April / 2008, 17:15:23 by Barney Fife »
|
Logged
|
[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
|
|
|
PhyrePhoX
Global Moderator
Hero Member
   
Karma: +139/-37
Offline
Posts: 1818
Coders Humiliate DSLR Kiddies
|
 |
« Reply #4 on: 18 / February / 2008, 01:54:56 » |
|
that indeed is a snafu. thanks for the input! i still have the feeling we will make it, somehow 
|
|
|
|
|
Logged
|
|
|
|
whim
Hero Member
   
Karma: +83/-0
Online
Posts: 805
A620/A630/i70_sd1000
|
 |
« Reply #5 on: 18 / February / 2008, 03:43:27 » |
|
@PhyrePhox Funny, i had gone to bed, couldn't fall asleep and dreamed up something very similar to your code, abstractly. Then saw your code and reworked it a bit: GeSHi (c): // 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 card_used, init_space, elapsed, avg_use, time_left; static long init_time; static int movie_running = 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) movie_running = !movie_running ; if (!movie_running) { // it's off, reset init init = 0; return; } else { //movie recording engaged if( !init ) { // initialize init_space = GetFreeCardSpaceKb(); init_time = get_tick_count(); init = 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; // End Note if (elapsed < 10) 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, "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 ... draw_string( 50, 50, osd_buf, conf.osd_color); } } } Created by GeSHI 1.0.7.20
unchecked of course ... talk to you later and now zzzzzzzzzzzzzz wim edit: code improved, we're getting there ... edit2: gone off to test it now edit3: compiles OK, but doesn't seem to function ...
|
|
|
|
« Last Edit: 18 / February / 2008, 18:05:27 by whim »
|
Logged
|
|
|
|
PhyrePhoX
Global Moderator
Hero Member
   
Karma: +139/-37
Offline
Posts: 1818
Coders Humiliate DSLR Kiddies
|
 |
« Reply #6 on: 18 / February / 2008, 12:18:11 » |
|
can't wait to try it this evening (i'm at work right now  ) 
|
|
|
|
|
Logged
|
|
|
|
PhyrePhoX
Global Moderator
Hero Member
   
Karma: +139/-37
Offline
Posts: 1818
Coders Humiliate DSLR Kiddies
|
 |
« Reply #7 on: 18 / February / 2008, 17:27:16 » |
|
heya whim, does this compile, does it work? will somehow test it right now.
|
|
|
|
|
Logged
|
|
|
|
whim
Hero Member
   
Karma: +83/-0
Online
Posts: 805
A620/A630/i70_sd1000
|
 |
« Reply #8 on: 18 / February / 2008, 18:03:27 » |
|
Hi Phox, I got it compile without errors, but running ? Can't tell - see nothing  I'll update previous post, because I haven't done that for almost 3 hours ... wim
|
|
|
|
|
Logged
|
|
|
|
PhyrePhoX
Global Moderator
Hero Member
   
Karma: +139/-37
Offline
Posts: 1818
Coders Humiliate DSLR Kiddies
|
 |
« Reply #9 on: 18 / February / 2008, 20:09:23 » |
|
yeah it compiles, you are right. and it shows the string with "avg ..." but the values are zero. hm. too bad there is no debugger  i think the problem is ,that when you press the button, the part where you set movie_running = !movie_running ; is called more than once. edit: doesnt seem to be the only problem. hm. tough.
|
|
|
|
« Last Edit: 18 / February / 2008, 20:16:57 by PhyrePhoX »
|
Logged
|
|
|
|
PhyrePhoX
Global Moderator
Hero Member
   
Karma: +139/-37
Offline
Posts: 1818
Coders Humiliate DSLR Kiddies
|
 |
« Reply #10 on: 18 / February / 2008, 21:46:24 » |
|
GeSHi (c): // 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 } } } Created by GeSHI 1.0.7.20
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, 23:58:32 by PhyrePhoX »
|
Logged
|
|
|
|
whim
Hero Member
   
Karma: +83/-0
Online
Posts: 805
A620/A630/i70_sd1000
|
 |
« Reply #11 on: 18 / February / 2008, 22: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.
|
|
|
|
|
Logged
|
|
|
|
PhyrePhoX
Global Moderator
Hero Member
   
Karma: +139/-37
Offline
Posts: 1818
Coders Humiliate DSLR Kiddies
|
 |
« Reply #12 on: 18 / February / 2008, 22: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, 22:09:48 by PhyrePhoX »
|
Logged
|
|
|
|
PhyrePhoX
Global Moderator
Hero Member
   
Karma: +139/-37
Offline
Posts: 1818
Coders Humiliate DSLR Kiddies
|
 |
« Reply #13 on: 18 / February / 2008, 22:31:17 » |
|
new post, cant edit the other one everytime i find out something new  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  edit: hm, gotta find out the video key for s3is so i can compile a testbuild for our main betatester barney  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, 23:26:21 by PhyrePhoX »
|
Logged
|
|
|
|
PhyrePhoX
Global Moderator
Hero Member
   
Karma: +139/-37
Offline
Posts: 1818
Coders Humiliate DSLR Kiddies
|
 |
« Reply #14 on: 20 / February / 2008, 12:21:20 » |
|
by the way, ewavr let me know a few things: 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 
|
|
|
|
|
Logged
|
|
|
|
|