Waterwingz (talk | contribs) mNo edit summary |
(→Script 3: added down button for display on/off) Tag: sourceedit |
||
(28 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
+ | {| align="right" style="border-collapse:collapse; font-size: x-small;" |
||
⚫ | |||
+ | | __TOC__ |
||
+ | |} |
||
+ | [[File:Compress-files1.jpg]] |
||
⚫ | |||
⚫ | |||
+ | ===Script 1=== |
||
The first script is a simple uBASIC script that can be used to periodically restart video recording to get around this 4G file size limit. It repeatedly creates a new video file after a user defined interval, allowing recording until the SD card fills with only a brief gap between each video file. Save it to your SD card with a .bas extension (ex: video.bas). |
The first script is a simple uBASIC script that can be used to periodically restart video recording to get around this 4G file size limit. It repeatedly creates a new video file after a user defined interval, allowing recording until the SD card fills with only a brief gap between each video file. Save it to your SD card with a .bas extension (ex: video.bas). |
||
+ | (script 1a is for camera that do not have a video button) |
||
− | <pre> |
||
⚫ | |||
⚫ | |||
+ | <syntaxhighlight lang="xbasic"> |
||
+ | @title MultiMovie 1a |
||
@param x minutes per file |
@param x minutes per file |
||
@default x 10 |
@default x 10 |
||
Line 26: | Line 32: | ||
goto "loop" |
goto "loop" |
||
end |
end |
||
+ | </syntaxhighlight> |
||
− | </pre> |
||
+ | ---- |
||
+ | . |
||
+ | (script 1b is for camera with a seperate video button) |
||
+ | ---- |
||
+ | <syntaxhighlight lang="xbasic"> |
||
+ | @title MultiMovie 1b |
||
+ | @param x minutes per file |
||
+ | @default x 10 |
||
+ | press "shoot_half" |
||
+ | sleep 2000 |
||
+ | release "shoot_half" |
||
+ | :loop |
||
+ | print "segment started..." |
||
+ | press "video" |
||
+ | sleep 2000 |
||
+ | release "video" |
||
+ | s=get_tick_count |
||
⚫ | |||
⚫ | |||
+ | until x<=((get_tick_count-s)/60000 ) |
||
+ | press "video" |
||
+ | sleep 2000 |
||
+ | release "video" |
||
⚫ | |||
⚫ | |||
+ | until get_movie_status<2 |
||
+ | sleep 1000 |
||
+ | goto "loop" |
||
⚫ | |||
+ | </syntaxhighlight> |
||
+ | ---- |
||
+ | ===Script 2=== |
||
− | The second script is a slightly fancier version of the first script, with improved status messages, the ability to index to a new file by pressing the "SET" button and the ability to disable the backlight. |
+ | The second script is a slightly fancier version of the first script, with improved status messages, the ability to index to a new file by pressing the "SET" button and the ability to disable the backlight by pressing the "DISP" button. Note : when the LCD backlight is off, there is code to blink one of the camera LED's to indicate that the script is still running. You may have to change the LED number from 4 to something else for your camera in two places where it say '''set_led 4 0''' |
+ | The script only works on cameras ''without'' a dedicated video button. |
||
− | <pre> |
||
+ | ---- |
||
− | --- under construction - check back soon --- |
||
+ | <syntaxhighlight lang="xbasic"> |
||
− | </pre> |
||
⚫ | |||
+ | @param x minutes per file |
||
+ | @default x 15 |
||
+ | f=0 |
||
+ | print "recording started..." |
||
+ | press "shoot_half" |
||
+ | sleep 1500 |
||
+ | b=1 |
||
+ | l=0 |
||
+ | :new |
||
+ | f=f+1 |
||
+ | click "shoot_full" |
||
+ | if f=1 then release "shoot_half" |
||
+ | print "starting file :";f |
||
+ | e=get_tick_count+(x*60000) |
||
+ | p=get_tick_count+1000 |
||
+ | if b=0 then set_backlight 0 |
||
+ | :loop |
||
⚫ | |||
+ | if is_pressed "display" then |
||
+ | if b=0 then |
||
+ | b=1 |
||
+ | set_backlight 1 |
||
+ | sleep 1000 |
||
+ | else |
||
+ | b=0 |
||
+ | set_backlight 0 |
||
+ | sleep 1000 |
||
+ | endif |
||
+ | endif |
||
+ | t=get_tick_count |
||
+ | if t > e then goto "reload" |
||
+ | if t < p then goto "loop" |
||
+ | p=get_tick_count+1000 |
||
+ | m=(e-t)/60000 |
||
+ | s=((e-t)%60000)/1000 |
||
+ | cls |
||
+ | print "file:";f,"time left:";m;"m ";s;"s" |
||
⚫ | |||
+ | if l=0 then |
||
+ | set_led 4 0 |
||
+ | l=4 |
||
+ | else |
||
+ | l=l-1 |
||
+ | if l=0 then |
||
+ | set_led 4 1 |
||
+ | endif |
||
+ | endif |
||
+ | endif |
||
+ | goto "loop" |
||
+ | :reload |
||
⚫ | |||
+ | print "reloading..." |
||
+ | click "shoot_full" |
||
+ | do |
||
+ | sleep 100 |
||
+ | until get_movie_status=1 |
||
+ | goto "new" |
||
+ | :restore |
||
+ | if b=0 then set_backlight 1 |
||
+ | if get_movie_status=4 then click "shoot_full" |
||
+ | print "recording halted" |
||
+ | end |
||
+ | </syntaxhighlight> |
||
---- |
---- |
||
⚫ | |||
+ | . |
||
+ | ===Script 3=== |
||
⚫ | |||
⚫ | |||
− | This script allows you to turn the backlight on & off by pressing the DISP button, halt the script by pressing the MENU button and restart recording by pressing the SET button. |
||
+ | This script allows you to : |
||
+ | *<span style="font-size:14px;">turn the display on & off by pressing the DISP button or down button, </span> |
||
+ | *<span style="font-size:14px;">halt the script by pressing the MENU button</span> |
||
− | Save it to your SD card with a .lua extension (e.g. vid_ext.lua). Note : this script will only work with CHDK versions from the new development / unstable trunk. |
||
+ | *<span style="font-size:14px;">restart recording by pressing the SET button. </span> |
||
− | <pre> |
||
+ | *zoom in & out by moving the cameras zoom lever |
||
+ | *refocus by "half pressing" the shutter button |
||
+ | |||
+ | <span style="font-size:14px;">It works on cameras with and without a dedicated video button.</span> |
||
+ | |||
+ | Save it to your SD card with a .lua extension (e.g. vid_ext.lua). |
||
+ | ---- |
||
+ | <syntaxhighlight lang="lua"> |
||
--[[ |
--[[ |
||
******************************** |
******************************** |
||
Licence: GPL |
Licence: GPL |
||
− | (c) msl 2012 |
+ | (c) msl 2012 - 2014 |
******************************** |
******************************** |
||
− | @title |
+ | @title Extended Video r2 |
− | @param a Auto (re)start |
+ | @param a Auto (re)start |
@default a 1 |
@default a 1 |
||
+ | @range a 0 1 |
||
@param b Time in s 0=max |
@param b Time in s 0=max |
||
@default b 0 |
@default b 0 |
||
+ | @range b 0 1800 |
||
]] |
]] |
||
function StartStopVideo() |
function StartStopVideo() |
||
local rec, vid = get_mode() |
local rec, vid = get_mode() |
||
− | local vid_button = get_video_button() |
+ | local vid_button = get_video_button() |
− | if rec |
+ | if rec and vid and vid_button == 0 then |
press("shoot_full") |
press("shoot_full") |
||
sleep(300) |
sleep(300) |
||
release("shoot_full") |
release("shoot_full") |
||
− | elseif rec |
+ | elseif rec and vid_button == 1 then |
click("video") |
click("video") |
||
end |
end |
||
Line 78: | Line 192: | ||
end |
end |
||
− | if a<0 or a>1 then a=0 end |
||
⚫ | |||
restart = a |
restart = a |
||
record_time = b |
record_time = b |
||
Line 96: | Line 208: | ||
set_console_autoredraw(0) |
set_console_autoredraw(0) |
||
+ | repeat |
||
− | while true do |
||
if TC == false and record_time > 0 then |
if TC == false and record_time > 0 then |
||
time_start = get_tick_count() |
time_start = get_tick_count() |
||
Line 104: | Line 216: | ||
if restart ~= 1 then print("[SET] Start/Stop Video") end |
if restart ~= 1 then print("[SET] Start/Stop Video") end |
||
print("[DISP] On/Off Backlight") |
print("[DISP] On/Off Backlight") |
||
+ | print("[ZOOM] Zooming") |
||
print("[MENU] End") |
print("[MENU] End") |
||
console_redraw() |
console_redraw() |
||
wait_click(900) |
wait_click(900) |
||
− | if |
+ | if is_key("display") or is_key("down") then |
set_backlight(BL) |
set_backlight(BL) |
||
if BL == 1 then BL=0 else BL=1 end |
if BL == 1 then BL=0 else BL=1 end |
||
+ | elseif is_key("set") and restart ~= 1 then StartStopVideo() |
||
+ | elseif is_key("shoot_half") then set_aflock(1) |
||
+ | elseif is_key("zoom_in") then press("zoom_in") while is_pressed("zoom_in") do sleep(20) end release("zoom_in") |
||
+ | elseif is_key("zoom_out") then press("zoom_out") while is_pressed("zoom_out") do sleep(20) end release("zoom_out") |
||
end |
end |
||
− | if |
+ | if TC and record_time > 0 then |
− | StartStopVideo() |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | if TC == true and record_time > 0 then |
||
if get_tick_count() - time_start >= record_time * 1000 + 2000 then |
if get_tick_count() - time_start >= record_time * 1000 + 2000 then |
||
StartStopVideo() -- stop video |
StartStopVideo() -- stop video |
||
Line 133: | Line 243: | ||
if BL == 1 then set_backlight(0) end |
if BL == 1 then set_backlight(0) end |
||
end |
end |
||
+ | until is_key("menu") |
||
⚫ | |||
− | </pre> |
||
+ | restore() |
||
+ | </syntaxhighlight> |
||
+ | ---- |
||
Based on discussion in this forum thread : [http://chdk.setepontos.com/index.php?topic=8051.0 sx230, unlimited video, 4GB file limit] |
Based on discussion in this forum thread : [http://chdk.setepontos.com/index.php?topic=8051.0 sx230, unlimited video, 4GB file limit] |
||
+ | [[Category:Scripting]] |
Revision as of 12:56, 29 June 2015
Canon P&S cameras are limited to a 4G file size when saving video files on a FAT formatted SD card. Listed below are three scripts that will automatically restart the video recording process periodically to overcome this issue.
Script 1
The first script is a simple uBASIC script that can be used to periodically restart video recording to get around this 4G file size limit. It repeatedly creates a new video file after a user defined interval, allowing recording until the SD card fills with only a brief gap between each video file. Save it to your SD card with a .bas extension (ex: video.bas).
(script 1a is for camera that do not have a video button)
@title MultiMovie 1a
@param x minutes per file
@default x 10
press "shoot_half"
sleep 2000
release "shoot_half"
:loop
print "segment started..."
click "shoot_full"
s=get_tick_count
do
sleep 500
until x<=((get_tick_count-s)/60000 )
click "shoot_full"
do
sleep 100
until get_movie_status=1
goto "loop"
end
. (script 1b is for camera with a seperate video button)
@title MultiMovie 1b
@param x minutes per file
@default x 10
press "shoot_half"
sleep 2000
release "shoot_half"
:loop
print "segment started..."
press "video"
sleep 2000
release "video"
s=get_tick_count
do
sleep 500
until x<=((get_tick_count-s)/60000 )
press "video"
sleep 2000
release "video"
do
sleep 100
until get_movie_status<2
sleep 1000
goto "loop"
end
Script 2
The second script is a slightly fancier version of the first script, with improved status messages, the ability to index to a new file by pressing the "SET" button and the ability to disable the backlight by pressing the "DISP" button. Note : when the LCD backlight is off, there is code to blink one of the camera LED's to indicate that the script is still running. You may have to change the LED number from 4 to something else for your camera in two places where it say set_led 4 0
The script only works on cameras without a dedicated video button.
@title MultiMovie 2
@param x minutes per file
@default x 15
f=0
print "recording started..."
press "shoot_half"
sleep 1500
b=1
l=0
:new
f=f+1
click "shoot_full"
if f=1 then release "shoot_half"
print "starting file :";f
e=get_tick_count+(x*60000)
p=get_tick_count+1000
if b=0 then set_backlight 0
:loop
if is_pressed "set" then goto "reload"
if is_pressed "display" then
if b=0 then
b=1
set_backlight 1
sleep 1000
else
b=0
set_backlight 0
sleep 1000
endif
endif
t=get_tick_count
if t > e then goto "reload"
if t < p then goto "loop"
p=get_tick_count+1000
m=(e-t)/60000
s=((e-t)%60000)/1000
cls
print "file:";f,"time left:";m;"m ";s;"s"
if b=0 then
if l=0 then
set_led 4 0
l=4
else
l=l-1
if l=0 then
set_led 4 1
endif
endif
endif
goto "loop"
:reload
print "reloading..."
click "shoot_full"
do
sleep 100
until get_movie_status=1
goto "new"
:restore
if b=0 then set_backlight 1
if get_movie_status=4 then click "shoot_full"
print "recording halted"
end
Modified from a script written by outslider and posted on the CHDK forum by Vash11779
.
Script 3
Listed below is a more sophisticated script written in Lua by msl.
This script allows you to :
- turn the display on & off by pressing the DISP button or down button,
- halt the script by pressing the MENU button
- restart recording by pressing the SET button.
- zoom in & out by moving the cameras zoom lever
- refocus by "half pressing" the shutter button
It works on cameras with and without a dedicated video button.
Save it to your SD card with a .lua extension (e.g. vid_ext.lua).
--[[
********************************
Licence: GPL
(c) msl 2012 - 2014
********************************
@title Extended Video r2
@param a Auto (re)start
@default a 1
@range a 0 1
@param b Time in s 0=max
@default b 0
@range b 0 1800
]]
function StartStopVideo()
local rec, vid = get_mode()
local vid_button = get_video_button()
if rec and vid and vid_button == 0 then
press("shoot_full")
sleep(300)
release("shoot_full")
elseif rec and vid_button == 1 then
click("video")
end
end
function restore()
if get_movie_status() == 4 then StartStopVideo() end
cls()
set_console_layout(0,0,25,5)
set_console_autoredraw(1)
end
restart = a
record_time = b
BL=0
TC=false
time_start = 0
time_now = 0
set_console_layout(9,1,39,6)
if restart==1 then
cls()
print("Automatic Video (Re)Start")
if record_time > 0 then print("record time:", record_time, "s") end
sleep(2000)
end
set_console_autoredraw(0)
repeat
if TC == false and record_time > 0 then
time_start = get_tick_count()
TC = true
end
cls()
if restart ~= 1 then print("[SET] Start/Stop Video") end
print("[DISP] On/Off Backlight")
print("[ZOOM] Zooming")
print("[MENU] End")
console_redraw()
wait_click(900)
if is_key("display") or is_key("down") then
set_backlight(BL)
if BL == 1 then BL=0 else BL=1 end
elseif is_key("set") and restart ~= 1 then StartStopVideo()
elseif is_key("shoot_half") then set_aflock(1)
elseif is_key("zoom_in") then press("zoom_in") while is_pressed("zoom_in") do sleep(20) end release("zoom_in")
elseif is_key("zoom_out") then press("zoom_out") while is_pressed("zoom_out") do sleep(20) end release("zoom_out")
end
if TC and record_time > 0 then
if get_tick_count() - time_start >= record_time * 1000 + 2000 then
StartStopVideo() -- stop video
TC = false
end
end
status = get_movie_status()
if (status < 4 or status > 4) and restart == 1 then
StartStopVideo()
cls()
print("Start recording")
console_redraw()
sleep(5000)
if BL == 1 then set_backlight(0) end
end
until is_key("menu")
restore()
Based on discussion in this forum thread : sx230, unlimited video, 4GB file limit