-
Notifications
You must be signed in to change notification settings - Fork 0
/
timelapse
executable file
·56 lines (48 loc) · 1.85 KB
/
timelapse
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/php
<?
// FIXME licencing? ;)
// NOTE see readme for detailed description
// TODO use some better way to parse options?
// TODO try to get rid of scrot (they say, that ImageMagick has a sceen capture utility)
if($argc < 2)
{
die("'compile' to compile, 'start [screenshot interval in seconds] [frame offset]' to start. ;)..\n");
}
//----------------------------------------------------------------
// compile
//----------------------------------------------------------------
if($argv[1] == "compile")
{
// `ffmpeg -shortest -qscale 3 -ab 192k -r 10 -i %04d.jpg -i music.mp3 video.mp4`; // <-- music version
$framerate = isset($argv[2]) ? $argv[2] : 10;
//TODO add framerate selection
`ffmpeg -shortest -qscale 3 -ab 192k -r $framerate -i %04d.jpg video.mp4`;
}
//----------------------------------------------------------------
// clean
//----------------------------------------------------------------
else if($argv[1] == "clean")
{
`rm -rf *.jpg`;
}
//----------------------------------------------------------------
// start
//----------------------------------------------------------------
else if($argv[1] == "start")
{
$interval = isset($argv[2]) ? $argv[2] : 10; //$argv[2] - frame spacing (not counting the time used to save and process the screenshot)
$frame = isset($argv[3]) ? $argv[3] : 0; //$argv[3] - frame offset - specify to continue recording from given frame
while(true)
{
echo "Beginning frame $frame\n";
`scrot screen.png`;
$filename = sprintf("%04d.jpg", $frame);
$date = '"' . `date` . '"';
// TODO find a better font... ;)
`convert -quality 100 -background black -splice 0x64 -pointsize 48 -fill red -annotate +24+48 $date -resize 1280x screen.png $filename`;
echo "Finished frame $frame\n";
`sleep $interval`;
++$frame;
}
}
?>