Pre-recording feature (raw_rec)

#728 Merged at 800e1f4
Repository
Branch
pre-record
Repository
Branch
unified
Author
  1. Alex
Reviewers
Description

This looks simple enough to be included in main builds. To me, it looks like a pretty useful feature, so I think it's time to give it a little more testing (otherwise it may end up buried deep in the commit history).

http://www.magiclantern.fm/forum/index.php?topic=17069

Notes:

  • @Mathew Kelly requested a slightly different version - record a few seconds before AND after a trigger signal, then pause the recording. Maybe somebody has an idea how to implement it easily?

  • there is a merge conflict with mlv_lite (easy to fix)

  • if you want it in mlv_rec, you are welcome to port the implementation

Comments (6)

  1. Mathew Kelly

    Yeah, this works perfectly fine, it does what I need it to do that's for sure. And I was able to link it with bolt_rec to make it do what I wanted, but its ruff coding Im sure, so doubt it would be of any use here. Thank you for creating this update alex!

    If I do these changes it does what I want with halfshutter press, replace get_halfshutter_pressed() with bolt_rec_recording and !get_halfshutter_pressed() with !bolt_rec_recording and add an external int for bolt_rec_recording; it works with bolt trigger, and will record post frames according to what is set in bolt trigger post frame setting.

    This setup lets you press record to start recording, it gets to pre_record state for the number frames you set for.
    Then it waits for trigger from halfshutter or bolt trigger if you set it up that way.
    Then it records pre, current and post and resets to pre record state awaiting next trigger.
    You can press Record key anytime to stop to Idle state.

    Very ruff coding, but it works the way I hoped it would.

    @@ -1898,6 +1920,31 @@
         }
     }
    
    +static unsigned int raw_rec_stop_cbr(unsigned int unused)
    +{
    +   if(!raw_video_enabled)
    +   {
    +      return 1;
    +   }
    +
    +      if(raw_recording_state == RAW_PRE_RECORDING && get_halfshutter_pressed())
    +      {
    +         pre_record_triggered = 1;
    +      }
    +
    +      if(raw_recording_state == RAW_RECORDING && !get_halfshutter_pressed())
    +      {
    +         raw_start_stop();
    +      }
    +
    +      if(pre_record_triggered == 1 && !get_halfshutter_pressed())
    +      {
    +         raw_start_stop();
    +      }
    +
    +   return 0;
    +}
    +
     static MENU_SELECT_FUNC(raw_playback_start)
     {
         if (RAW_IS_IDLE)
    @@ -2060,11 +2103,8 @@
             {
                 case RAW_IDLE:
                 case RAW_RECORDING:
    -                raw_start_stop();
    -                break;
    -            
                 case RAW_PRE_RECORDING:
    -                pre_record_triggered = 1;
    +                 raw_start_stop();
                     break;
             }
             return 0;
    @@ -2255,6 +2295,7 @@
         MODULE_CBR(CBR_VSYNC, raw_rec_vsync_cbr, 0)
         MODULE_CBR(CBR_KEYPRESS, raw_rec_keypress_cbr, 0)
         MODULE_CBR(CBR_SHOOT_TASK, raw_rec_polling_cbr, 0)
    +    MODULE_CBR(CBR_SHOOT_TASK, raw_rec_stop_cbr, 0)
         MODULE_CBR(CBR_DISPLAY_FILTER, raw_rec_update_preview, 0)
     MODULE_CBRS_END()
    
  2. Alex author

    I'd merge this after mlv_lite, because I see no reason to force users go back to the old raw format to try this feature.

    1. David Milligan

      I tested it merged with mlv_lite, which will need a little more work than a simple merge conflict fix. Frame number is wrong in the 'pre' frames. All 'pre' frames had the same number. Will need some code added to go back and fixup the frame number metadata once recording starts (raw format doesn't require this).

      1. Alex author

        Ah, right, I should probably update the frame counters in vidf_hdr as well. I already decrement frame_number for all frames at every iteration.

    1. Alex author

      I'd say it's best to merge after mlv_lite. On that branch, I want to benchmark the latest changes and check file integrity when spanning.