Smogrify


Note: this document is currently being updated. The intention is to freeze the smogrify interface from 0.7.5 (the next release) onwards. After that, commands will only be added. The current development version is here.




LiVES is written as a client/server architecture. Smogrify (super mogrify) is the command line client for LiVES. It runs mostly in background mode.





Details

The following is a list of all the general purpose commands in smogrify. Below that are some examples of how to use smogrify.


Command
Parameters
Blocking/non blocking
Notes

key: int, float, string, boolean
Unless indicated otherwise, for non-blocking operations,
you must wait for the file
/tempdir/handle/.status
to be created.

This file is delimeted by "|". When the operation is finished, the first field will either be "completed" or "error".

Some operations return a progress count in this file, so you must also check that the file starts with 'completed|' or 'error|' .

Items in {} are optional parameters.

Unless specifed otherwise, all functions return 0 on success, 1 on failure.



Utility Functions

report
homedir
B
Reports temp directory and other details to file /tmp/.smogrify. Should be called first before any other directives since it also initialises the .lives file. Homedir should be the directory where the .lives file is to be stored (normally the user's home directory).

get_tempdir id
B
Writes the value of LiVES' temporary directory to the file /tmp/.smogrify.id

set_pref
key
value
B
Sets the preference identified by <key></key> to the value. Keys may not contain spaces, but values may.

get_pref
key
{id1 id2}
B
Writes the value associated with key to the file /tempdir/.smogval.id1.id2. If id1 and id2 are not specified, uid and gid are used.

get_pref_default key
{id1 id2}
B
Like get_pref, but returns a default value.

set_pref_if_not_set


key value B
Like set_pref, but will only set a value if the key does not exist already. A similar function is used extensively in report to create the config file.

(From 0.7.5 onwards)
list_plugins
id
directory


B
Lists plugins (files) in directory
Data is returned in the file /tempdir/.smogplugin.id, using the format: N|plugin1_name|plugin2_name...|pluginN_name

(From 0.7.5 onwards)
key_rpt_fast
-
NB
Set keyboard repeat rate to 25 and the delay to 1.
Does not return any info file.

key_rpt_slow
-
NB
Reset keyboard repeat rate.
Does not return any info file.

get_window_id
handle NB
Prompts the user to click on a window, then returns: window_id, height, width and colour depth (bpp).
Information is returned in the file: /tempdir/handle/.status, and is delimeted by "|"

version
-
B
Prints the version to stdout.

cleanup
-
B
Removes old temporary files. Should never be called whilst there are copies of lives-exe running.




File Operations

new
-






(id)
B
Create handle for new file.  On success : returns n_handle*256, on failure, returns 0.

Info file is created as /tempdir/.info.n_handle. This file contains handle, which is used as a key in all other functions below.


From 0.7.5 onwards, the syntax will be changing. New will take a parameter 'id', and will return the new handle in /tempdir/.info.id


get_details handle
filename

B
Returns: 
$handle,$count,$type,$hsize,$vsize,$bpp,$fps,$f_size,$arate,
$achans,$asamps,$signed,$endian,$af_size

Information is returned in the file: /tempdir/handle/.status, and is delimeted by "|"

open handle
filename
with_sound
{start_time}
{frames
}
NB
If the start_time and frames parameters are omitted, the entire file will be opened. If only the frames parameter is omitted, file will be opened to the end.

Returns:  $handle,$count,$type,$hsize,$vsize,$bpp,$fps,$f_size,$arate,
$achans,$asamps,$signed,$endian,$af_size

Information is returned in the file: /tempdir/handle/.status, and is delimeted by "|"

Filename can be a video file, a URL, or a directory.

open_image
handle
filename

B
Image will be resized to the default height and width.
save handle
fps
filename

start
end
rate
chans
samps
signed
NB
Output type can be changed using rc_set, e.g.
smogrify rc_set("encoder","ffmpeg")
smogrify rc_set("output_type","divx")
backup with_sound
start

end
filename
NB
Start and end are currently not fully implemented.
restore handle
filename

NB
Opens backup filename. A handle should be obtained first with new.
restore_details
handle
filename

B
Should be called immediately after restore. Returns backup file size, audio file size, and number of frames.

Information is returned in the file: /tempdir/handle/.status, and is delimeted by "|"

close handle
NB
Should be called on all handles obtained with new.
Does not return any info file.




Frame Operations

cut handle
start
end
cut_audio
frames
rate
chans
samps
NB
Frames is the total frames in the clip before cutting.
insert handle
where
start
end
from_handle
with_audio
frames
width
height
rate
chans
samps
{times}
NB
Where is the insertion point (frames are always inserted after this, so it can be 0). From frames is the number of frames in handle). Times is an optional paramter, if it is omitted, it defaults to 1.
reverse handle
start
end
NB
Reverses the order of frames in handle. Audio is unaffected.
reorder
handle
{endian}
NB
Endian is an optional parameter (0=big endian, 1=little-endian).
If this is omitted, the endianness of the backend is used.
Requires an event.frames file. Refer to the backup document.
deorder
handle
start
end
frames
NB
Undo a reorder operation. Frames should be the number of frames in the clip before it was reordered.
undo
handle
start
end
NB
Undoes the last effect. See below for effect commands.
redo handle
start
end
NB
Redoes the last effect. See below for effect commands.
undo_cut
See notes ->
NB
Undoes a cut operation. The parameters are as for insert; however the from_handle should be set to the value of handle, and start and end should be set to the section which was cut. Frames should be the current frame count.

save_frame
handle
frame
filename
B
Image type is auto-detected from the file extension.
fill_and_redo_frames
handle
start
end
{pre-cut}
NB
Removes gaps in frames and makes sure they begin with frame 1.
Pre-cut is an optional paramter. If set, frames up to and including pre-cut (before reordering) will be cut from the beginning.


Useful after operations where there may be gaps in frames (e.g. after capture).
merge_frames










NB



Audio Operations

mp3open handle
filename
NB
Opens an mp3. Audio is opened as 44100, stereo, 16 bit signed.
After this function completes, commit_audio or cancel_audio should be called.
oggopen handle
filename
NB
Opens an ogg. Audio is opened as 44100, stereo, 16 bit signed.
After this function completes, commit_audio or cancel_audio should be called.
wavopen handle
filename
NB
Opens a wav. Audio is opened as 44100, stereo, 16 bit signed.
After this function completes, commit_audio or cancel_audio should be called.
cdopen handle
track
NB
Opens a cd track. Audio is opened as 44100, stereo, 16 bit signed.
After this function completes, commit_audio or cancel_audio should be called.

CD device should be set first with set_pref cdplay_device
audioopen
handle
filename
NB
From 0.7.5 onwards. Autodetect audio type and open it.
commit_audio handle
B
Commits the result of an audio operation.
cancel_audio handle
B
Cancels the result of an audio operation.
undo_audio
handle B
Undoes the last audio change. Will not work if the preference conserve_space is set to 'true'.
export_audio
start_time
end_time
rate
chans
samps
signed
new rate
filename
NB

append_audio

NB

trim_audio

NB

resample_audio

NB

xmmsplay
B

xmmsstop
B

xmmsrandom
NB



Playback Operations

play
NB

play_preview

NB

fs_preview

NB

stop
B



Effects

charcoal
NB

colorize
NB

cycle
NB

edge
NB

flip

NB

flop

NB

monochrome
NB

negate
NB

randomzoom
NB

resize
NB

rotate
NB

solarize
NB

spin

NB

swirl

NB

wave

NB





cancel

B

pause

B

resume

B

keep

NB





Example of use:

To load in the file foo.avi, replace the audio with music.ogg, and then save the first 1000 frames:

smogrify report /home/user
smogrify get_tempdir myvalue

-----> store the contents of /tmp/.smogrify.myvalue              ----> this is the tempdir
-----> delete /tmp/smogrify.myvalue

smogrify new myvalue

----> get handle from /tempdir/smogrify.info.myvalue
----> delete /tmp/smogrify.info.myvalue

---> open the file with no sound:

smogrify open handle "foo.avi" 0                          

----> get field 8 (fps) from /tempdir/handle/.status
----> delete /tempdir/handle/.status

smogrify audioopen handle "music.ogg"

----> this is a non-blocking operation, so wait for /tempdir/handle/.status to be created, check it starts with 'completed|' or 'error|'
----> delete /tempdir/handle/.status

smogrify commit_audio handle

set the encoder and output type (optional):

smogrify set_pref("encoder","ffmpeg")
smogrify set_pref("output_type","divx")

smogrify save handle fps "bar.avi" 1 1000 44100 2 16 1

----> this is a non-blocking operation, so wait for /tempdir/handle/.status to be created, check it starts with 'completed|' or 'error|'

smogrify close handle