HDR video experiments - General Discussion and Assistance - CHDK Forum

HDR video experiments

  • 23 Replies
  • 11458 Views
*

Offline funnel

  • ****
  • 349
HDR video experiments
« on: 16 / March / 2012, 08:18:11 »
Advertisements

I'd just like to share some HDR video experiments I was doing in the last few days.

I managed to locate the ram address (for sx220 0x8550+0x68) that counts the frames while recording. So I wrote an experimental lua script that changes the exposure for each video frame.

I'm using the same technique as Magic lantern users by recording at 30fps and overexpose and underexpose every frame.

The created HDR video has a framerate of 15fps so it has to be interpolated back to 30fps to get a smooth motion.

The post-processing steps are as follows:
-extract video frames as jpgs
-using Photomatix batch process to create HDR images from jpgs by combining the two over and underexposed images
-make a 15fps video from hdr images with Virtualdub
-interpolate video back to 30fps with MeGUI and Interframe avisynth script
-muxing audio/video with mkvmerge tool


A complete tutorial for interpolation can be found here http://www.spirton.com/convert-videos-to-60fps/ and some more info on magic lantern forums.

Here's a sample video I made yesterday


The lua script I'm using is this one and will work only on SX220. For other cameras you'll need to find the appropriate ram address that counts the number of frames. I found it with the memory browser while video recording starting at 0x8550 and going up. In sx220 movie_rec.c is located at
Code: [Select]
                "LDR     R0, [R8,#0x68]\n"              ------->frame counter 0x8550+0x68
                 "LDR     R3, =0x85D8\n"      //85d8 - 4
                 "ADD     R1, R0, #1\n"
                 "STR     R1, [R8,#0x68]\n"
                 "LDR     R0, [SP,#0x60]\n"
                 "SUB     R2, R3, #4\n"       //-4
                 "BL      sub_FF2F95A4\n"

                 "LDR       R0, =0x85D4 \n              "       // added. tested ok. 85d8 - 4
                 "BL        set_quality \n              "       // added


EDIT: updated lua script
« Last Edit: 28 / March / 2012, 14:22:26 by funnel »

Re: HDR video experiments
« Reply #1 on: 16 / March / 2012, 12:23:38 »
I'd just like to share some HDR video experiments I was doing in the last few days.
I'm using the same technique as Magic lantern

Interesting  .. I have not followed Magic Lantern.

Does that mean you can increase shutter speed and alter ISO to get normal exposure ?

I have a special application with a rotating camera where I need to set a higher shutter speed.

If I display shutter speed in movie mode and point camera at very bright light the speed can increase to 1/800 sec.

Normally, it seems to be set at about half the frame rate.

How have you decided minimum and maximum shutter speeds for your script ?


*

Offline funnel

  • ****
  • 349
Re: HDR video experiments
« Reply #2 on: 16 / March / 2012, 14:21:21 »
The minimum and maximum shutter speeds I got by using the Videoexp script http://chdk.setepontos.com/index.php?topic=5295.msg68622#msg68622. It returns 480 for minimum and gets stuck at max 1414, so  decided for this values. Also by looking at the shutter speeds table in platform/camera/shooting.c  480 is 1/30s which is the maximum exposure time for a frame when recording at 30fps.

Re: HDR video experiments
« Reply #3 on: 16 / March / 2012, 14:26:08 »
Yes, but can you increase shutter speed AND ISO to get correct exposure ?

*

Offline funnel

  • ****
  • 349
Re: HDR video experiments
« Reply #4 on: 16 / March / 2012, 14:32:12 »
Yes, I can change the ISO with call_event_proc("SetCDSGain",value) if I needed to. For know I'm just manipulating the shutter speed.

Re: HDR video experiments
« Reply #5 on: 16 / March / 2012, 20:14:39 »
Just to be clear, how do you start video recording AND apply the override ?
On my S95, if you start video recording and simply enter ALT mode then you cannot exit ALT mode or stop video recording or turn-off the camera.
« Last Edit: 16 / March / 2012, 21:13:14 by Microfunguy »

*

Offline funnel

  • ****
  • 349
Re: HDR video experiments
« Reply #6 on: 17 / March / 2012, 04:48:20 »
I go out of alt mode and start the recording.

This script I posted is just a rough draft and I'm still improving it. You should add a line to press the record button before the while loop if it doesn't work for you.

In the future I'll also add the formula to calculate the ISO for a correct exposure.

Re: HDR video experiments
« Reply #7 on: 17 / March / 2012, 10:33:16 »
In wrappers.c, I already have function synch_led() that is called every frame.

I have modified it as follows :-

Code: [Select]
int synch_led(int x)
{
 static int movieTv,prevFrame,registered;
 static unsigned buf;

 gFrameCount++;
if(gFrameCount==1)
 {
  movieTv = shooting_get_prop(PROPCASE_CAMERA_TV);
  if(_ExecuteEventProcedure("FA.Create")== -1)return x;
  if(_ExecuteEventProcedure("InitializeAdjustmentSystem")== -1)return x;
  if(_ExecuteEventProcedure("SS.Create")== -1)return x;
  _ExecuteEventProcedure("PT_DoAELock");
  registered = 1;
 }
if(registered && (gFrameCount>1)&& (gFrameCount != prevFrame))
 {
  if(!(gFrameCount%2))buf= movieTv;
  else buf= movieTv+192;
  _ExecuteEventProcedure("SetAE_ShutterSpeed",&buf);
  prevFrame = gFrameCount;
 }
 return x;                           //preserve R0 if called from assembler
}

My PROPCASE_CAMERA_TV is the same as your PROPCASE_TV.
Unlocking AE will be dealt with elsewhere.

Strangely, the image becomes far brighter and camera crashes after fifteen frames.

I am able to see that PROPCASE_CAMERA_TV changes to four seconds !

No matter what value I write, it always seems to be four seconds.

I have tried passing 'buf' and '&buf'.
« Last Edit: 17 / March / 2012, 17:41:29 by Microfunguy »

*

Offline funnel

  • ****
  • 349
Re: HDR video experiments
« Reply #8 on: 18 / March / 2012, 08:51:50 »
For me this code works without crashing
Code: [Select]
int hdr_video(int x)
{
static int framecount;
int min=480;
int max=1200;
framecount++;

_ExpCtrlTool_StopContiAE(0,0);

if((framecount%2)==0)
{
_SetAE_ShutterSpeed((short*)&min);
}
else
{
_SetAE_ShutterSpeed((short*)&max);
}
return x; 
}

I'm calling ExpCtrlTool_StopContiAE for every frame, otherwise it doesn't work correctly on my camera. Doesn't seem to be a problem.

*

Offline Lebeau

  • ***
  • 187
Re: HDR video experiments
« Reply #9 on: 18 / March / 2012, 10:18:55 »
I will follow this thread with an enormous attention. Thanks guys :)

 

Related Topics


SimplePortal © 2008-2014, SimplePortal