Magic Lantern Forum

Developing Magic Lantern => Scripting Corner => Scripting Q&A => Topic started by: spto on March 07, 2019, 03:31:58 AM

Title: Full-resolution silent mode with lua?
Post by: spto on March 07, 2019, 03:31:58 AM
Hi experts,

Just wondering whether it's possible to call the silent shooting mode with a lua script?
(The silent shooting function as described here, https://www.magiclantern.fm/forum/index.php?topic=12523.msg143510#msg143510)

Thank you!

Cheers
Title: Re: Full-resolution silent mode with lua?
Post by: Walter Schulz on March 07, 2019, 10:10:10 AM
https://www.magiclantern.fm/forum/index.php?topic=9741.msg212214#msg212214
Just change the silent menu item in script or use a dumb script running
lv.start()
in photo mode
and half-shutter key press in script after activating and configuring FRSP.
If an ML function is not covered in LUA API you can always use "menu.set" and "menu.get" to access its menu item.
Title: Re: Full-resolution silent mode with lua?
Post by: spto on March 08, 2019, 03:02:02 PM
Thank you!

I noticed that even in LV mode, the mirror will always go down after the shutter closes, and it takes at least 0.7 seconds for the mirror to go up again. Can we lock the mirror during LV mode?
Title: Re: Full-resolution silent mode with lua?
Post by: Walter Schulz on March 08, 2019, 03:20:31 PM
? That's what silent.mo is all about: Taking pics without shutter and mirror actuation. Maybe a short video showing cam's screen and what is happening would be helpful.
Title: Re: Full-resolution silent mode with lua?
Post by: spto on March 09, 2019, 01:21:13 PM
Thank you Walter! I decide to use Mirror Lockup in Shoot menu instead of silent.mo, because I still want to use the physical shutter.

I have written a mini-script for testing:



-- MLUtest

Aperture = 7.1
PrefISO = 400
ShutterSpeed = 0.125

function main()
menu.close()
console.show()

beep(1,50)

camera.iso.value = PrefISO
camera.shutter.value = ShutterSpeed
camera.aperture.value = Aperture

camera.shoot(false)

beep(1,50)

console.hide()
end

main()



I first manually turned on the Mirror Lockup in Shoot menu and set the "MLU mode" to "Handheld", set "Handheld Shutter" to "1/2...1/125", set "Handheld Delay" to "1s" and set "Normal MLU Delay" to "1s".

Then I run my testing script, MLU was not functioning during the testing. (When I press the shutter manually, MLU works well)

Should I call MLU from the lua script as well to make it work? If so, could you please give an example on how to use the menu module of lua API? Thank you!
Title: Re: Full-resolution silent mode with lua?
Post by: a1ex on March 09, 2019, 01:46:05 PM

-- MLU test - handheld
menu.set("Shoot", "Mirror Lockup", "ON")
menu.set("Mirror Lockup", "MLU mode", "Handheld")
menu.set("Mirror Lockup", "Handheld Shutter", "1/2...1/125")
menu.set("Mirror Lockup", "Handheld Delay", "1s")
sleep(2)
key.press(KEY.HALFSHUTTER)
key.press(KEY.FULLSHUTTER)
sleep(1)
key.press(KEY.UNPRESS_FULLSHUTTER)
key.press(KEY.UNPRESS_HALFSHUTTER)



-- MLU test - always on
menu.set("Shoot", "Mirror Lockup", "ON")
menu.set("Mirror Lockup", "MLU mode", "Always ON")
menu.set("Mirror Lockup", "Normal MLU Delay", "3s")
menu.close()
sleep(2)
camera.shoot()


Tested on 5D2 with latest lua_fix build.

TODO: merge the two delay entries under "MLU Delay" ?
Title: Re: Full-resolution silent mode with lua?
Post by: spto on March 09, 2019, 02:49:25 PM
That is so cool! It works on 550D (ML-lua-fix), thank you!!
Title: Re: Full-resolution silent mode with lua?
Post by: spto on March 09, 2019, 05:02:38 PM
Hi I made some further tests. It works well if I take only one shot, but hardly work when I try to take a series of shots.

Question: how did you choose sleep(1) between the press and unpress? What's the consideration for judging the waiting time?
Also, how to judge the waiting time needed between shots?

I cycled through such thing:

Quote
   key.press(KEY.HALFSHUTTER)
   key.press(KEY.FULLSHUTTER)
   msleep(1)
   key.press(KEY.UNPRESS_FULLSHUTTER)
   key.press(KEY.UNPRESS_HALFSHUTTER)
   task.yield(2000 + camera.shutter.ms)

It's weird that when I press the shutter button with my physical hand, 550D can take MLU shots at a rate of 1 shots / 2 seconds. But when I try the code above, it does not work at all (only 1 shot with MLU is taken).

Quote from: a1ex on March 09, 2019, 01:46:05 PM

-- MLU test - handheld
menu.set("Shoot", "Mirror Lockup", "ON")
menu.set("Mirror Lockup", "MLU mode", "Handheld")
menu.set("Mirror Lockup", "Handheld Shutter", "1/2...1/125")
menu.set("Mirror Lockup", "Handheld Delay", "1s")
sleep(2)
key.press(KEY.HALFSHUTTER)
key.press(KEY.FULLSHUTTER)
sleep(1)
key.press(KEY.UNPRESS_FULLSHUTTER)
key.press(KEY.UNPRESS_HALFSHUTTER)



-- MLU test - always on
menu.set("Shoot", "Mirror Lockup", "ON")
menu.set("Mirror Lockup", "MLU mode", "Always ON")
menu.set("Mirror Lockup", "Normal MLU Delay", "3s")
menu.close()
sleep(2)
camera.shoot()


Tested on 5D2 with latest lua_fix build.

TODO: merge the two delay entries under "MLU Delay" ?
Title: Re: Full-resolution silent mode with lua?
Post by: a1ex on March 10, 2019, 08:49:05 AM
1 second should be long enough to trigger a photo capture. If you press the shutter button for 1 millisecond... it's probably not.

My advice would be to stay away from multitasking features (such as task.yield), unless you know how to fix the code (I don't). Refer to docs and comments to see what's broken. For now, just keep the script single-threaded and stick with sleep/msleep.

Also, try large delays at first, to get something working, then decrease them until it stops working.
Title: Re: Full-resolution silent mode with lua?
Post by: garry23 on March 10, 2019, 10:13:32 AM
@a1ex/@spto

Just a thought. Could you also explicitly wait until you know the camera has written out the last image. Something like this:

count = dryos.shooting_card.file_number

-- MLU test - handheld
menu.set("Shoot", "Mirror Lockup", "ON")
menu.set("Mirror Lockup", "MLU mode", "Handheld")
menu.set("Mirror Lockup", "Handheld Shutter", "1/2...1/125")
menu.set("Mirror Lockup", "Handheld Delay", "1s")
sleep(2)
key.press(KEY.HALFSHUTTER)
key.press(KEY.FULLSHUTTER)
    repeat msleep(100) until dryos.shooting_card.file_number == (count + 1)
key.press(KEY.UNPRESS_FULLSHUTTER)
key.press(KEY.UNPRESS_HALFSHUTTER)


As I say, just a thought.