supplierdeeply

Locking focus during video recording?

  • 10 Replies
  • 1745 Views
*

Offline Davo

  • ***
  • 143
Locking focus during video recording?
« on: 10 / March / 2013, 10:04:15 »
Advertisements
I am trying to lock my A810 lens at a fixed subject distance while recording videos. I have tried using set_focus() and set_aflock() in the script below. However, the camera seems to switch back to autofocus when it starts recording the video.

Is it possible to lock focus during video record?

Code: [Select]
--[[
@title Video focus
@param d Subject distance (cm)
@default d 20
--]]
subject_distance = 10 * d
sleep(2000)

print("Focus1 = " .. get_focus())
set_focus(subject_distance)
sleep(1000)
print("Focus2 = " .. get_focus())
press("shoot_half")
sleep(1000)
release("shoot_half")
set_aflock(1)
print("Focus3 = " .. get_focus())
press("video")
sleep(2000)
release("video")
print("Focus4 = " .. get_focus())
sleep(5000)
press("video")
sleep(2000)
release("video")
print("Focus5 = " .. get_focus())
set_aflock(0)

*

Offline lapser

  • *****
  • 1022
  • SX50_100b / SX260_101a / G1X_100g / D20_100b
Re: Locking focus during video recording?
« Reply #1 on: 10 / March / 2013, 13:21:14 »
My cameras have a manual focus mode, which works in video recordings too. There's a way to switch to manual focus mode in Lua that probably won't work on a camera without manual focus as an option, but it's worth a try. See what this code does on your camera:

  post_levent_for_npt("PressSw1AndMF") --toggles manual focus mode
  sleep(500)

*

Offline Davo

  • ***
  • 143
Re: Locking focus during video recording?
« Reply #2 on: 11 / March / 2013, 09:47:40 »
Quote
  post_levent_for_npt("PressSw1AndMF") --toggles manual focus mode
  sleep(500)

Thanks very much for the suggestion but I am afraid it crashed my camera - but it was worth a try.

Anyhoos, while trying your code I stumbled upon the solution. I noticed that in Canon mode I can record with AFL on but AFL clears when I start a new clip. What my code does now is perform the keypresses to turn on AFL before it starts each video. It's a bit clunky but it seems to work. Is there a CHDK command that turns on the Canon AFL?

This script will record a short video at subject distances of 100 to 500mm in steps of 100mm.

Code: [Select]
--[[
@title Video AFL
--]]

for i = 1,5 do
subject_distance = 100 * i
print("Focus1 = " .. get_focus())
set_focus(subject_distance)
sleep(500)
print("Focus2 = " .. get_focus())
press("shoot_half")
sleep(1000)
click("left")
sleep(1000)
release("shoot_half")
print("Focus3 = " .. get_focus())
press("video")
sleep(2000)
release("video")
print("Focus4 = " .. get_focus())
sleep(5000)
press("video")
sleep(2000)
release("video")
print("Focus5 = " .. get_focus())
end

*

Offline blackhole

  • ****
  • 441
  • A590IS 101b
    • Planetary astrophotography
Re: Locking focus during video recording?
« Reply #3 on: 11 / March / 2013, 10:02:52 »
Quote
Is there a CHDK command that turns on the Canon AFL?

http://chdk.wikia.com/wiki/Script_commands#set_aflock

EDIT:
just now I see that you're already used this.
« Last Edit: 11 / March / 2013, 10:13:52 by blackhole »


*

Offline Davo

  • ***
  • 143
Re: Locking focus during video recording?
« Reply #4 on: 11 / March / 2013, 10:14:35 »
Quote
http://chdk.wikia.com/wiki/Script_commands#set_aflock

Hi - I did try this function in my original script at top. However, the call to start video recording seems to cancel it and the autofocus steps back in. My second script fools the camera into the Canon AFL mode and the AFL text appears in the LCD. The Canon AFL is then not cancelled at the start of each clip.

I guess the CHDK and Canon AFLs are different in some way.

*

Offline blackhole

  • ****
  • 441
  • A590IS 101b
    • Planetary astrophotography
Re: Locking focus during video recording?
« Reply #5 on: 11 / March / 2013, 10:50:38 »
I just tried something similar, and the only way is to use a "click" command, perhaps someone has a better solution.

Re: Locking focus during video recording?
« Reply #6 on: 11 / March / 2013, 11:47:56 »
I guess the CHDK and Canon AFLs are different in some way.
Just the fact that Canon AFL causes something to appear on the display would seem to validate that guess.

*

Offline philmoz

  • *****
  • 2936
    • Photos
Re: Locking focus during video recording?
« Reply #7 on: 11 / March / 2013, 14:52:49 »
I am trying to lock my A810 lens at a fixed subject distance while recording videos. I have tried using set_focus() and set_aflock() in the script below. However, the camera seems to switch back to autofocus when it starts recording the video.

Is it possible to lock focus during video record?

Code: [Select]
--[[
@title Video focus
@param d Subject distance (cm)
@default d 20
--]]
subject_distance = 10 * d
sleep(2000)

print("Focus1 = " .. get_focus())
set_focus(subject_distance)
sleep(1000)
print("Focus2 = " .. get_focus())
press("shoot_half")
sleep(1000)
release("shoot_half")
set_aflock(1)
print("Focus3 = " .. get_focus())
press("video")
sleep(2000)
release("video")
print("Focus4 = " .. get_focus())
sleep(5000)
press("video")
sleep(2000)
release("video")
print("Focus5 = " .. get_focus())
set_aflock(0)

Try putting set_aflock(1) between press("shoot_half") and release("shoot_half").

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)


*

Offline Davo

  • ***
  • 143
Re: Locking focus during video recording?
« Reply #8 on: 12 / March / 2013, 07:53:24 »
Quote
Try putting set_aflock(1) between press("shoot_half") and release("shoot_half").

Magic - that works as well so I now have 2 options to lock focus for video clips like so:

Code: [Select]
set_focus(subject_distance)
sleep(500)
press("shoot_half")
sleep(1000)
--click("left") -- set Canon AFL or
set_aflock(1) -- set CHDK AFL
sleep(1000)
release("shoot_half")

The Canon AFL displays the AFL text in the LCD which is a good check for me. Also, you must remember to call set_aflock(0) before you start recording a new video clip using the CHDK AFL or the camera will crash.

Anyhoos, 2 solutions to my problem which is good. Thanks for all the help.

Re: Locking focus during video recording?
« Reply #9 on: 12 / March / 2013, 11:02:39 »
Try putting set_aflock(1) between press("shoot_half") and release("shoot_half").
@philmoz :  do you know if that is that just for video mode?   I'd like to  change the wiki link for set_aflock() to capture this but its not clear to me when you need it inside a half-press and when you can put it just about anywhere ?

 

Related Topics