head	1.235;
access;
symbols
	start:1.1.1.1
	salsaman:1.1.1;
locks; strict;
comment	@# @;


1.235
date	2009.07.28.15.10.20;	author gfinch;	state Exp;
branches;
next	1.234;

1.234
date	2009.07.22.22.23.32;	author gfinch;	state Exp;
branches;
next	1.233;

1.233
date	2009.07.22.00.53.15;	author gfinch;	state Exp;
branches;
next	1.232;

1.232
date	2009.07.18.20.55.19;	author gfinch;	state Exp;
branches;
next	1.231;

1.231
date	2009.07.12.04.15.47;	author gfinch;	state Exp;
branches;
next	1.230;

1.230
date	2009.07.09.21.15.12;	author gfinch;	state Exp;
branches;
next	1.229;

1.229
date	2009.07.07.17.27.54;	author gfinch;	state Exp;
branches;
next	1.228;

1.228
date	2009.06.28.16.05.55;	author gfinch;	state Exp;
branches;
next	1.227;

1.227
date	2009.06.24.16.34.31;	author gfinch;	state Exp;
branches;
next	1.226;

1.226
date	2009.06.19.02.52.23;	author gfinch;	state Exp;
branches;
next	1.225;

1.225
date	2009.06.14.02.48.33;	author gfinch;	state Exp;
branches;
next	1.224;

1.224
date	2009.06.13.20.37.29;	author gfinch;	state Exp;
branches;
next	1.223;

1.223
date	2009.06.06.19.07.15;	author gfinch;	state Exp;
branches;
next	1.222;

1.222
date	2009.06.06.11.06.36;	author gfinch;	state Exp;
branches;
next	1.221;

1.221
date	2009.06.02.01.05.00;	author gfinch;	state Exp;
branches;
next	1.220;

1.220
date	2009.05.27.04.04.47;	author gfinch;	state Exp;
branches;
next	1.219;

1.219
date	2009.05.03.04.29.48;	author gfinch;	state Exp;
branches;
next	1.218;

1.218
date	2009.05.01.14.09.02;	author gfinch;	state Exp;
branches;
next	1.217;

1.217
date	2009.04.29.02.45.22;	author gfinch;	state Exp;
branches;
next	1.216;

1.216
date	2009.04.16.01.56.23;	author gfinch;	state Exp;
branches;
next	1.215;

1.215
date	2009.04.11.13.36.34;	author gfinch;	state Exp;
branches;
next	1.214;

1.214
date	2009.03.20.20.50.05;	author gfinch;	state Exp;
branches;
next	1.213;

1.213
date	2009.02.04.19.14.58;	author gfinch;	state Exp;
branches;
next	1.212;

1.212
date	2009.01.21.17.49.38;	author gfinch;	state Exp;
branches;
next	1.211;

1.211
date	2009.01.17.21.22.43;	author gfinch;	state Exp;
branches;
next	1.210;

1.210
date	2009.01.07.23.06.20;	author gfinch;	state Exp;
branches;
next	1.209;

1.209
date	2009.01.06.12.32.46;	author gfinch;	state Exp;
branches;
next	1.208;

1.208
date	2008.12.06.01.43.32;	author gfinch;	state Exp;
branches;
next	1.207;

1.207
date	2008.12.01.00.43.43;	author gfinch;	state Exp;
branches;
next	1.206;

1.206
date	2008.11.30.00.59.33;	author gfinch;	state Exp;
branches;
next	1.205;

1.205
date	2008.11.29.20.52.50;	author gfinch;	state Exp;
branches;
next	1.204;

1.204
date	2008.11.28.03.32.25;	author gfinch;	state Exp;
branches;
next	1.203;

1.203
date	2008.11.27.22.52.59;	author gfinch;	state Exp;
branches;
next	1.202;

1.202
date	2008.11.26.16.45.06;	author gfinch;	state Exp;
branches;
next	1.201;

1.201
date	2008.11.25.19.19.07;	author gfinch;	state Exp;
branches;
next	1.200;

1.200
date	2008.11.22.23.51.16;	author gfinch;	state Exp;
branches;
next	1.199;

1.199
date	2008.11.11.17.12.56;	author gfinch;	state Exp;
branches;
next	1.198;

1.198
date	2008.11.10.03.19.19;	author gfinch;	state Exp;
branches;
next	1.197;

1.197
date	2008.11.04.10.25.54;	author gfinch;	state Exp;
branches;
next	1.196;

1.196
date	2008.10.31.15.09.18;	author gfinch;	state Exp;
branches;
next	1.195;

1.195
date	2008.09.29.06.20.14;	author gfinch;	state Exp;
branches;
next	1.194;

1.194
date	2008.09.13.23.47.11;	author gfinch;	state Exp;
branches;
next	1.193;

1.193
date	2008.08.17.09.26.59;	author gfinch;	state Exp;
branches;
next	1.192;

1.192
date	2008.08.12.17.20.08;	author gfinch;	state Exp;
branches;
next	1.191;

1.191
date	2008.07.23.00.04.25;	author gfinch;	state Exp;
branches;
next	1.190;

1.190
date	2008.07.22.22.20.43;	author gfinch;	state Exp;
branches;
next	1.189;

1.189
date	2008.07.22.21.55.52;	author gfinch;	state Exp;
branches;
next	1.188;

1.188
date	2008.07.15.05.26.11;	author gfinch;	state Exp;
branches;
next	1.187;

1.187
date	2008.07.13.23.14.58;	author gfinch;	state Exp;
branches;
next	1.186;

1.186
date	2008.07.12.07.37.37;	author gfinch;	state Exp;
branches;
next	1.185;

1.185
date	2008.07.10.07.24.01;	author gfinch;	state Exp;
branches;
next	1.184;

1.184
date	2008.07.09.23.11.33;	author gfinch;	state Exp;
branches;
next	1.183;

1.183
date	2008.07.08.16.07.27;	author gfinch;	state Exp;
branches;
next	1.182;

1.182
date	2008.07.05.23.04.23;	author gfinch;	state Exp;
branches;
next	1.181;

1.181
date	2008.07.04.16.54.25;	author gfinch;	state Exp;
branches;
next	1.180;

1.180
date	2008.06.20.12.33.53;	author gfinch;	state Exp;
branches;
next	1.179;

1.179
date	2008.06.20.08.21.21;	author gfinch;	state Exp;
branches;
next	1.178;

1.178
date	2008.06.17.00.07.15;	author gfinch;	state Exp;
branches;
next	1.177;

1.177
date	2008.06.11.08.08.37;	author gfinch;	state Exp;
branches;
next	1.176;

1.176
date	2008.06.09.03.43.16;	author gfinch;	state Exp;
branches;
next	1.175;

1.175
date	2008.06.06.07.55.22;	author gfinch;	state Exp;
branches;
next	1.174;

1.174
date	2008.05.13.17.10.33;	author gfinch;	state Exp;
branches;
next	1.173;

1.173
date	2008.05.06.06.12.00;	author gfinch;	state Exp;
branches;
next	1.172;

1.172
date	2008.04.28.05.09.26;	author gfinch;	state Exp;
branches;
next	1.171;

1.171
date	2008.04.26.07.37.27;	author gfinch;	state Exp;
branches;
next	1.170;

1.170
date	2008.04.25.07.58.57;	author gfinch;	state Exp;
branches;
next	1.169;

1.169
date	2008.04.25.07.46.44;	author gfinch;	state Exp;
branches;
next	1.168;

1.168
date	2008.03.30.16.57.21;	author gfinch;	state Exp;
branches;
next	1.167;

1.167
date	2008.03.21.19.58.02;	author gfinch;	state Exp;
branches;
next	1.166;

1.166
date	2008.03.11.00.01.04;	author gfinch;	state Exp;
branches;
next	1.165;

1.165
date	2008.03.10.16.50.05;	author gfinch;	state Exp;
branches;
next	1.164;

1.164
date	2008.03.10.07.21.09;	author gfinch;	state Exp;
branches;
next	1.163;

1.163
date	2008.03.05.17.22.52;	author gfinch;	state Exp;
branches;
next	1.162;

1.162
date	2008.03.04.06.14.58;	author gfinch;	state Exp;
branches;
next	1.161;

1.161
date	2008.03.04.05.21.59;	author gfinch;	state Exp;
branches;
next	1.160;

1.160
date	2008.03.02.21.05.17;	author gfinch;	state Exp;
branches;
next	1.159;

1.159
date	2008.03.01.22.47.46;	author gfinch;	state Exp;
branches;
next	1.158;

1.158
date	2008.02.26.07.33.03;	author gfinch;	state Exp;
branches;
next	1.157;

1.157
date	2008.02.24.08.02.38;	author gfinch;	state Exp;
branches;
next	1.156;

1.156
date	2008.02.20.07.29.44;	author gfinch;	state Exp;
branches;
next	1.155;

1.155
date	2008.02.18.05.53.30;	author gfinch;	state Exp;
branches;
next	1.154;

1.154
date	2008.02.14.23.25.28;	author gfinch;	state Exp;
branches;
next	1.153;

1.153
date	2008.02.12.07.32.55;	author gfinch;	state Exp;
branches;
next	1.152;

1.152
date	2008.01.31.21.57.19;	author gfinch;	state Exp;
branches;
next	1.151;

1.151
date	2008.01.25.22.06.17;	author gfinch;	state Exp;
branches;
next	1.150;

1.150
date	2008.01.22.16.04.21;	author gfinch;	state Exp;
branches;
next	1.149;

1.149
date	2007.08.01.19.20.15;	author gfinch;	state Exp;
branches;
next	1.148;

1.148
date	2007.07.08.17.09.22;	author gfinch;	state Exp;
branches;
next	1.147;

1.147
date	2007.07.02.01.11.43;	author gfinch;	state Exp;
branches;
next	1.146;

1.146
date	2007.06.29.17.18.14;	author gfinch;	state Exp;
branches;
next	1.145;

1.145
date	2007.06.26.02.05.41;	author gfinch;	state Exp;
branches;
next	1.144;

1.144
date	2007.06.22.07.32.34;	author gfinch;	state Exp;
branches;
next	1.143;

1.143
date	2007.06.09.07.54.22;	author gfinch;	state Exp;
branches;
next	1.142;

1.142
date	2007.06.09.02.00.16;	author gfinch;	state Exp;
branches;
next	1.141;

1.141
date	2007.06.08.20.04.26;	author gfinch;	state Exp;
branches;
next	1.140;

1.140
date	2007.06.08.18.20.38;	author gfinch;	state Exp;
branches;
next	1.139;

1.139
date	2007.06.08.17.25.46;	author gfinch;	state Exp;
branches;
next	1.138;

1.138
date	2007.06.05.04.33.54;	author gfinch;	state Exp;
branches;
next	1.137;

1.137
date	2007.06.04.02.19.30;	author gfinch;	state Exp;
branches;
next	1.136;

1.136
date	2007.06.02.19.09.48;	author gfinch;	state Exp;
branches;
next	1.135;

1.135
date	2007.06.02.08.33.59;	author gfinch;	state Exp;
branches;
next	1.134;

1.134
date	2007.05.31.21.49.02;	author gfinch;	state Exp;
branches;
next	1.133;

1.133
date	2007.05.31.19.15.16;	author gfinch;	state Exp;
branches;
next	1.132;

1.132
date	2007.05.29.07.05.33;	author gfinch;	state Exp;
branches;
next	1.131;

1.131
date	2007.05.28.06.29.44;	author gfinch;	state Exp;
branches;
next	1.130;

1.130
date	2007.05.26.07.23.37;	author gfinch;	state Exp;
branches;
next	1.129;

1.129
date	2007.05.23.21.35.26;	author gfinch;	state Exp;
branches;
next	1.128;

1.128
date	2007.05.18.20.54.56;	author gfinch;	state Exp;
branches;
next	1.127;

1.127
date	2007.04.21.16.10.54;	author gfinch;	state Exp;
branches;
next	1.126;

1.126
date	2007.03.26.05.21.27;	author gfinch;	state Exp;
branches;
next	1.125;

1.125
date	2007.03.22.06.16.28;	author gfinch;	state Exp;
branches;
next	1.124;

1.124
date	2007.03.11.01.38.24;	author gfinch;	state Exp;
branches;
next	1.123;

1.123
date	2007.03.07.06.38.20;	author gfinch;	state Exp;
branches;
next	1.122;

1.122
date	2006.12.21.18.09.34;	author gfinch;	state Exp;
branches;
next	1.121;

1.121
date	2006.12.20.23.07.13;	author gfinch;	state Exp;
branches;
next	1.120;

1.120
date	2006.12.19.03.16.22;	author gfinch;	state Exp;
branches;
next	1.119;

1.119
date	2006.12.19.01.38.29;	author gfinch;	state Exp;
branches;
next	1.118;

1.118
date	2006.12.18.01.44.41;	author gfinch;	state Exp;
branches;
next	1.117;

1.117
date	2006.12.10.17.33.30;	author gfinch;	state Exp;
branches;
next	1.116;

1.116
date	2006.12.09.12.54.55;	author gfinch;	state Exp;
branches;
next	1.115;

1.115
date	2006.12.08.19.10.38;	author gfinch;	state Exp;
branches;
next	1.114;

1.114
date	2006.12.07.02.24.19;	author gfinch;	state Exp;
branches;
next	1.113;

1.113
date	2006.12.06.19.30.19;	author gfinch;	state Exp;
branches;
next	1.112;

1.112
date	2006.11.30.18.04.57;	author gfinch;	state Exp;
branches;
next	1.111;

1.111
date	2006.11.30.01.42.25;	author gfinch;	state Exp;
branches;
next	1.110;

1.110
date	2006.11.29.03.43.11;	author gfinch;	state Exp;
branches;
next	1.109;

1.109
date	2006.11.07.18.51.18;	author gfinch;	state Exp;
branches;
next	1.108;

1.108
date	2006.10.29.21.18.14;	author gfinch;	state Exp;
branches;
next	1.107;

1.107
date	2006.10.27.21.12.09;	author gfinch;	state Exp;
branches;
next	1.106;

1.106
date	2006.10.26.18.15.51;	author gfinch;	state Exp;
branches;
next	1.105;

1.105
date	2006.10.13.12.46.30;	author gfinch;	state Exp;
branches;
next	1.104;

1.104
date	2006.10.10.20.47.23;	author gfinch;	state Exp;
branches;
next	1.103;

1.103
date	2006.09.28.02.36.45;	author gfinch;	state Exp;
branches;
next	1.102;

1.102
date	2006.09.18.05.07.21;	author gfinch;	state Exp;
branches;
next	1.101;

1.101
date	2006.09.04.07.41.23;	author gfinch;	state Exp;
branches;
next	1.100;

1.100
date	2006.08.30.13.20.53;	author gfinch;	state Exp;
branches;
next	1.99;

1.99
date	2006.08.26.23.36.15;	author gfinch;	state Exp;
branches;
next	1.98;

1.98
date	2006.08.22.04.46.58;	author gfinch;	state Exp;
branches;
next	1.97;

1.97
date	2006.08.20.08.41.37;	author gfinch;	state Exp;
branches;
next	1.96;

1.96
date	2006.08.18.04.37.11;	author gfinch;	state Exp;
branches;
next	1.95;

1.95
date	2006.08.18.04.23.56;	author gfinch;	state Exp;
branches;
next	1.94;

1.94
date	2006.08.17.06.01.45;	author gfinch;	state Exp;
branches;
next	1.93;

1.93
date	2006.08.16.23.09.42;	author gfinch;	state Exp;
branches;
next	1.92;

1.92
date	2006.07.24.04.50.16;	author gfinch;	state Exp;
branches;
next	1.91;

1.91
date	2006.07.21.17.18.01;	author gfinch;	state Exp;
branches;
next	1.90;

1.90
date	2006.07.10.07.26.54;	author gfinch;	state Exp;
branches;
next	1.89;

1.89
date	2006.07.09.17.46.06;	author gfinch;	state Exp;
branches;
next	1.88;

1.88
date	2006.07.01.07.33.45;	author gfinch;	state Exp;
branches;
next	1.87;

1.87
date	2006.06.01.23.25.56;	author gfinch;	state Exp;
branches;
next	1.86;

1.86
date	2006.05.13.03.03.09;	author gfinch;	state Exp;
branches;
next	1.85;

1.85
date	2006.05.13.02.45.35;	author gfinch;	state Exp;
branches;
next	1.84;

1.84
date	2006.05.03.00.04.28;	author gfinch;	state Exp;
branches;
next	1.83;

1.83
date	2006.05.01.00.34.15;	author gfinch;	state Exp;
branches;
next	1.82;

1.82
date	2006.05.01.00.02.06;	author gfinch;	state Exp;
branches;
next	1.81;

1.81
date	2006.04.30.20.09.15;	author gfinch;	state Exp;
branches;
next	1.80;

1.80
date	2006.04.28.01.59.03;	author gfinch;	state Exp;
branches;
next	1.79;

1.79
date	2006.04.27.01.48.48;	author gfinch;	state Exp;
branches;
next	1.78;

1.78
date	2006.04.24.17.55.06;	author gfinch;	state Exp;
branches;
next	1.77;

1.77
date	2006.04.22.17.31.07;	author gfinch;	state Exp;
branches;
next	1.76;

1.76
date	2006.04.09.00.38.33;	author gfinch;	state Exp;
branches;
next	1.75;

1.75
date	2006.04.05.01.24.28;	author gfinch;	state Exp;
branches;
next	1.74;

1.74
date	2006.03.28.23.38.18;	author gfinch;	state Exp;
branches;
next	1.73;

1.73
date	2006.03.28.23.32.21;	author gfinch;	state Exp;
branches;
next	1.72;

1.72
date	2006.03.28.22.53.57;	author gfinch;	state Exp;
branches;
next	1.71;

1.71
date	2006.03.16.05.38.20;	author gfinch;	state Exp;
branches;
next	1.70;

1.70
date	2006.03.15.01.54.39;	author gfinch;	state Exp;
branches;
next	1.69;

1.69
date	2006.03.12.12.18.49;	author gfinch;	state Exp;
branches;
next	1.68;

1.68
date	2006.02.28.01.39.31;	author gfinch;	state Exp;
branches;
next	1.67;

1.67
date	2006.02.17.03.38.53;	author gfinch;	state Exp;
branches;
next	1.66;

1.66
date	2006.02.15.13.37.29;	author gfinch;	state Exp;
branches;
next	1.65;

1.65
date	2006.02.12.03.39.31;	author gfinch;	state Exp;
branches;
next	1.64;

1.64
date	2006.02.10.21.05.44;	author gfinch;	state Exp;
branches;
next	1.63;

1.63
date	2006.02.10.15.19.22;	author gfinch;	state Exp;
branches;
next	1.62;

1.62
date	2006.01.30.01.54.56;	author gfinch;	state Exp;
branches;
next	1.61;

1.61
date	2006.01.28.20.58.15;	author gfinch;	state Exp;
branches;
next	1.60;

1.60
date	2006.01.24.16.42.57;	author gfinch;	state Exp;
branches;
next	1.59;

1.59
date	2006.01.24.03.47.38;	author gfinch;	state Exp;
branches;
next	1.58;

1.58
date	2006.01.19.03.43.36;	author gfinch;	state Exp;
branches;
next	1.57;

1.57
date	2005.12.31.16.17.34;	author gfinch;	state Exp;
branches;
next	1.56;

1.56
date	2005.12.31.01.16.00;	author gfinch;	state Exp;
branches;
next	1.55;

1.55
date	2005.12.30.03.39.50;	author gfinch;	state Exp;
branches;
next	1.54;

1.54
date	2005.12.29.04.49.27;	author gfinch;	state Exp;
branches;
next	1.53;

1.53
date	2005.12.21.23.10.03;	author gfinch;	state Exp;
branches;
next	1.52;

1.52
date	2005.12.21.00.07.25;	author gfinch;	state Exp;
branches;
next	1.51;

1.51
date	2005.12.20.02.04.17;	author gfinch;	state Exp;
branches;
next	1.50;

1.50
date	2005.10.01.16.27.10;	author gfinch;	state Exp;
branches;
next	1.49;

1.49
date	2005.08.10.13.44.05;	author gfinch;	state Exp;
branches;
next	1.48;

1.48
date	2005.08.05.23.23.51;	author gfinch;	state Exp;
branches;
next	1.47;

1.47
date	2005.08.04.20.45.51;	author gfinch;	state Exp;
branches;
next	1.46;

1.46
date	2005.08.02.18.34.16;	author gfinch;	state Exp;
branches;
next	1.45;

1.45
date	2005.08.02.17.35.10;	author gfinch;	state Exp;
branches;
next	1.44;

1.44
date	2005.08.01.22.36.39;	author gfinch;	state Exp;
branches;
next	1.43;

1.43
date	2005.07.31.15.47.48;	author gfinch;	state Exp;
branches;
next	1.42;

1.42
date	2005.07.26.18.42.31;	author gfinch;	state Exp;
branches;
next	1.41;

1.41
date	2005.07.23.17.08.46;	author gfinch;	state Exp;
branches;
next	1.40;

1.40
date	2005.07.22.17.38.59;	author gfinch;	state Exp;
branches;
next	1.39;

1.39
date	2005.05.26.15.39.35;	author gfinch;	state Exp;
branches;
next	1.38;

1.38
date	2005.04.12.00.17.15;	author gfinch;	state Exp;
branches;
next	1.37;

1.37
date	2005.04.06.23.07.28;	author gfinch;	state Exp;
branches;
next	1.36;

1.36
date	2005.04.06.22.54.19;	author gfinch;	state Exp;
branches;
next	1.35;

1.35
date	2005.03.26.20.25.34;	author gfinch;	state Exp;
branches;
next	1.34;

1.34
date	2005.03.23.15.33.31;	author gfinch;	state Exp;
branches;
next	1.33;

1.33
date	2005.02.22.22.35.58;	author gfinch;	state Exp;
branches;
next	1.32;

1.32
date	2005.02.22.21.22.11;	author gfinch;	state Exp;
branches;
next	1.31;

1.31
date	2005.02.20.18.08.44;	author gfinch;	state Exp;
branches;
next	1.30;

1.30
date	2005.02.11.03.26.03;	author gfinch;	state Exp;
branches;
next	1.29;

1.29
date	2005.02.07.16.12.06;	author gfinch;	state Exp;
branches;
next	1.28;

1.28
date	2005.02.07.02.56.39;	author gfinch;	state Exp;
branches;
next	1.27;

1.27
date	2005.02.01.02.52.15;	author gfinch;	state Exp;
branches;
next	1.26;

1.26
date	2005.01.19.20.42.23;	author gfinch;	state Exp;
branches;
next	1.25;

1.25
date	2005.01.19.19.37.05;	author gfinch;	state Exp;
branches;
next	1.24;

1.24
date	2004.12.18.01.02.20;	author gfinch;	state Exp;
branches;
next	1.23;

1.23
date	2004.12.17.23.15.44;	author gfinch;	state Exp;
branches;
next	1.22;

1.22
date	2004.12.06.21.22.14;	author gfinch;	state Exp;
branches;
next	1.21;

1.21
date	2004.12.06.03.48.42;	author gfinch;	state Exp;
branches;
next	1.20;

1.20
date	2004.12.03.00.54.00;	author gfinch;	state Exp;
branches;
next	1.19;

1.19
date	2004.12.02.05.00.04;	author gfinch;	state Exp;
branches;
next	1.18;

1.18
date	2004.12.01.04.33.25;	author gfinch;	state Exp;
branches;
next	1.17;

1.17
date	2004.12.01.02.16.32;	author gfinch;	state Exp;
branches;
next	1.16;

1.16
date	2004.11.30.07.41.26;	author gfinch;	state Exp;
branches;
next	1.15;

1.15
date	2004.11.29.16.13.06;	author gfinch;	state Exp;
branches;
next	1.14;

1.14
date	2004.11.22.03.18.03;	author gfinch;	state Exp;
branches;
next	1.13;

1.13
date	2004.11.18.04.08.33;	author gfinch;	state Exp;
branches;
next	1.12;

1.12
date	2004.11.17.02.54.45;	author gfinch;	state Exp;
branches;
next	1.11;

1.11
date	2004.11.09.02.21.56;	author gfinch;	state Exp;
branches;
next	1.10;

1.10
date	2004.10.25.16.28.26;	author gfinch;	state Exp;
branches;
next	1.9;

1.9
date	2004.10.24.00.54.55;	author gfinch;	state Exp;
branches;
next	1.8;

1.8
date	2004.10.11.13.38.16;	author gfinch;	state Exp;
branches;
next	1.7;

1.7
date	2004.10.05.12.40.50;	author gfinch;	state Exp;
branches;
next	1.6;

1.6
date	2004.10.04.16.36.21;	author gfinch;	state Exp;
branches;
next	1.5;

1.5
date	2004.10.01.17.38.34;	author gfinch;	state Exp;
branches;
next	1.4;

1.4
date	2004.09.30.10.05.25;	author gfinch;	state Exp;
branches;
next	1.3;

1.3
date	2004.09.25.09.49.06;	author gfinch;	state Exp;
branches;
next	1.2;

1.2
date	2004.09.21.12.04.23;	author gfinch;	state Exp;
branches;
next	1.1;

1.1
date	2004.09.19.04.06.54;	author gfinch;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2004.09.19.04.06.54;	author gfinch;	state Exp;
branches;
next	;


desc
@@


1.235
log
@fix for loop cont crash
@
text
@#!/usr/bin/perl

# smogrify - Copyright G. Finch 2003 - 2009
# Released under the GPL 3 or later - see file COPYING or www.gnu.org for details


##################################################################

# these MUST match with the definition in the GUI
$rc_filename=".lives";

$rfx_builder_multi="build-lives-rfx-plugin-multi";

# default temporary directory (can be overridden from the GUI)
$default_tmpdir="/tmp/livestmp/";

$umask=0177; # ->        -rw-------

$GUI_NAME="LiVES";

###################################################################

# default values
$encoder="mencoder_encoder";

$composite_command="composite -quiet -colorspace RGB -type truecolor";

# TODO - use <effect_command>, add colorspace if it is eq convert
$convert_command="convert -quiet -colorspace RGB -type truecolor";

###################################################################
# Do not change these except for testing !

$background=1;
$version="1.0.1-cvs";
#$dyneversion="LIVES-20080814";
$img_ext=".jpg"; # can be .jpg or .png

###################################################################


$uid=$>;
$gid=$);
$gid=~ s/\W.*//;

$home=$ENV{"HOME"};


###################################################################

if (defined($ARGV[0])) {
    $command=$ARGV[0];

    unless ($command eq "report"||$command eq "version") {
	$tmpdir=&rc_get("tempdir");
    }

    if (!caller||$command eq "save"||$command eq "plugin_clear") {
	if (defined $DEBUG_SM_CMDS) { 
	    print STDERR "command is $command\n";
	}

	if ($command eq "save" && $ARGV[1] eq "get_rfx") {
	    $background=0;
	}


## blocking calls


    if ($command eq "stopsubsub"||$command eq "stopsubsubs"||$command eq "stop_audio") {
	$handle=$ARGV[1];
	$curtmpdir="$tmpdir/$handle";
	if ($command eq "stop_audio") {
		$pidfile="$curtmpdir/.pidpb";
	}
	else {
		$pidfile="$curtmpdir/.pid";
	}
	$statusfile="$curtmpdir/.status";
	$wait_for_pid=1;
	if (defined $ARGV[2]) {
	    $wait_for_pid=-1;
	}

	unless (-d "$curtmpdir") {
	    exit 2;
	}
	if (defined(open IN,"< $pidfile")) {
	    read IN,$target_pid,8;
	    close IN;
	    if ($target_pid eq NULL) {
		exit 1;
	    }
	    # make sure pidfile has same group and owner, otherwise exit
	    @@stat=stat($pidfile);
	    if (!($uid==$stat[4]&&$gid==$stat[5])) {
		die "Smogrify: Unable to stop process $target_pid.\n";
	    }
	    elsif ($command eq "stopsubsub"||$command eq "stop_audio") {
		# kill all subprocesses of target_pid, and target_pid
		&kill_child_pids($target_pid);
	    }
	    elsif ($command eq "stopsubsubs") {
		# kill all subprocesses of target_pid, but not target_pid
		`pgrep -P $target_pid > $tmpdir/.pids.$target_pid`;
		if (-s "$tmpdir/.pids.$target_pid"&&defined(open IN,"$tmpdir/.pids.$target_pid")) {
		    while (<IN>) {
			$pid=$_;
			chomp($pid);
			&kill_child_pids($pid);
		    }
		    close IN;
		}
		unlink "$tmpdir/.pids.$target_pid";
	    }
	    
	    else {
		print "Attempting to stop process ".$target_pid." with $command\n";
		system("kill -TERM $target_pid>/dev/null 2>&1");
	    }
	    
	    unlink $pidfile;
	    unless ($command eq "stop_audio") {
		&sig_killed;
	    }
	    exit 0;
	}
	exit 1;
    }


    if ($command eq "pause_play") {
	`kill -STOP mplayer`;
	`kill -STOP sox`;
	exit 0;
    }

    if ($command eq "resume_play") {
	`kill -CONT mplayer`;
	`kill -CONT sox`;
	exit 0;
    }


    if ($command eq "new") {
	# warning - this has changed recently, it now takes a $key
	# this can normally be set to getpid()

	$key=$ARGV[1];

	# write mini-info file
	$infofile=$tmpdir."/.info.".$key;
	
	do {
	    $handle=int(rand 1000000000)+65536;
	    $curtmpdir="$tmpdir/$handle";
	} while (-d $curtmpdir);
	
	umask 0;
	mkdir $curtmpdir,0700;
	umask $umask;
	
	if (!defined(open OUT,"> $infofile")) {
	    exit 1;
	}
	
	print OUT $handle;
	close OUT;
	exit 0;
    }
    

    if ($command eq "get_tempdir") {
	$id=$ARGV[1];
	print "> /tmp/.smogrify.$id\n";
	open OUT,"> /tmp/.smogrify.$id" or exit 1;
	print OUT "$tmpdir";
	close OUT;
	exit 0;
    }


    if ($command eq "report") {
	$gui_bootstrap_file="";
	if (defined($ARGV[1])) {
	    $gui_bootstrap_file=$ARGV[1];
	}
	$firsttime=0;

	$video_open_command=&location("mplayer");

	$audio_player="sox";
	$audio_play_command=&rc_get_default("sox_command");
	    
	$convert_version_hash=&get_convert_version_hash;
	
	if ($audio_play_command eq "") {
	    $audio_player="mplayer";
	    $audio_play_command=&rc_get_default("mplayer_audio_command");
	}
	
	# get $tmpdir from .rc file, if no .rc file, create it
	if (! -s "$home/$rc_filename") {
	    # set comment at start of file
	    &rc_set("","");
	    $firsttime=1;
	}

	$lives_home_dir="$home/.lives-dir/";
	$default_keymap="default.keymap";

	if (! -d "$lives_home_dir") {
	    mkdir ("$lives_home_dir",0700);
	}

	&rc_set_if_not_set("version",$version);
	&rc_set_if_not_set("tempdir",$default_tmpdir);

	if (defined($dyneversion)) {
	    &rc_set_if_not_set("lib_dir","/opt/$dyneversion/lib/");
	    &rc_set_if_not_set("prefix_dir","/opt/$dyneversion/");
	}

	&rc_set_if_not_set("video_open_command",$video_open_command);
	&rc_set_if_not_set("audio_play_command",$audio_play_command);
	&rc_set_if_not_set("audio_player",$audio_player);
	&rc_set_if_not_set("midisynch","false");
	&rc_set_if_not_set("pb_quality",2);
	&rc_set_if_not_set("insert_resample","true");
	&rc_set_if_not_set("open_compression_percent",15);
	&rc_set_if_not_set("conserve_space","false");
	&rc_set_if_not_set("antialias","true");
	# resize action when opening images - can be one of: "bound", "default" or "none"
	&rc_set_if_not_set("image_resize_action","none");
	&rc_set_if_not_set("encoder",$encoder);
	&rc_set_if_not_set("output_type","mjpeg");
	&rc_set_if_not_set("audio_effect","none");
	&rc_set_if_not_set("default_image_format","jpeg");
	&rc_set_if_not_set("default_fps",25);
	&rc_set_if_not_set("vid_load_dir","$home");
	&rc_set_if_not_set("vid_save_dir","$home");
	&rc_set_if_not_set("image_dir","$home");
	&rc_set_if_not_set("proj_dir","$home");
	&rc_set_if_not_set("audio_dir","$home");
	&rc_set_if_not_set("save_directories","false");
	&rc_set_if_not_set("stop_screensaver","true");
	&rc_set_if_not_set("open_maximised","true");
	&rc_set_if_not_set("show_recent_files","true");
	&rc_set_if_not_set("lives_warning_mask",789504); # bits 19,18,11 and 10
	&rc_set_if_not_set("dl_bandwidth_K",64);
	&rc_set_if_not_set("show_player_stats","false");
	&rc_set_if_not_set("show_toolbar","true");
	&rc_set_if_not_set("debug_encoders","false");
	&rc_set_if_not_set("encoder_acodec",1); # default of PCM
	&rc_set_if_not_set("record_opts",-1);

	&rc_set_if_not_set("gui_theme","crayons");
	&rc_set_if_not_set("jack_opts",16); # start aserver on startup
	&rc_set_if_not_set("audio_opts",0);
	&rc_set_if_not_set("rte_keys_virtual",9);

	&rc_set_if_not_set("instant_open","true");
	&rc_set_if_not_set("auto_deinterlace","true");

	&rc_set_if_not_set("mt_undo_buf",32);
	&rc_set_if_not_set("mt_enter_prompt","true");
	&rc_set_if_not_set("render_prompt","true");
	&rc_set_if_not_set("mt_exit_render","true");
	&rc_set_if_not_set("mt_def_width",640);
	&rc_set_if_not_set("mt_def_height",480);
	&rc_set_if_not_set("mt_def_achans",2);
	&rc_set_if_not_set("mt_def_signed_endian",2*!&get_endian);
	&rc_set_if_not_set("mt_backaudio","1");
	&rc_set_if_not_set("mt_pertrack_audio","true");

	&rc_set_if_not_set("ar_clipset","");
	&rc_set_if_not_set("ar_layout","");
	
	&rc_set_if_not_set("rec_desktop_audio","false");
	&rc_set_if_not_set("osc_start","false");
	&rc_set_if_not_set("osc_port",9999);

	&rc_set_if_not_set("concat_images","true");

	&rc_set_if_not_set("omc_dev_opts",3);


	$tmpdir=&rc_get("tempdir");
	&write_bootstrap_file;
	&mktmpdir;
	
	$convert_old_version=&rc_get("convert_version");
	unless ($convert_old_version eq $convert_version) {
	    &rc_set("convert_version",$convert_version);
	}
	&version_check_and_upgrade;
	unless ($gui_bootstrap_file eq "") {
	    open OUT,"> $gui_bootstrap_file" or exit 4;
	    print OUT "$version|$tmpdir|$firsttime|$msg|$msg2";
	    close OUT;
	}

	#make sure we can write to tempir
	open OUT,"> $tmpdir/.test" or exit 5;
	close OUT;
	unlink "$tmpdir/.test";

	exit 0;
    }

	if ($command eq "set_clip_value") {
	    $prefs_file=$ARGV[1];
	    shift(@@ARGV);
	    $command="set_pref";
	}


    if ($command eq "set_pref") {
	# WARNING - pref keys should not contain spaces, but values can
	$key=$ARGV[1];
	shift(@@ARGV);
	shift(@@ARGV);

	$value=join(" ",@@ARGV);
	&rc_set($key,$value);
	exit 0;
    }
	
    if ($command eq "set_pref_if_not_set") {
	# WARNING - pref keys should not contain spaces, but values can
	$key=$ARGV[1];
	shift(@@ARGV);
	shift(@@ARGV);

	$value=join(" ",@@ARGV);
	&rc_set_if_not_set($key,$value);
	exit 0;
    }
	


	if ($command eq "get_clip_value") {
	    $command="get_pref";
	    $prefs_file=$ARGV[4];
	}


	if ($command eq "print_pref") {
	    $command="get_pref";
	    $ARGV[2]="-";
	}

    if ($command eq "get_pref") {
	$key=$ARGV[1];
	if (defined($ARGV[2])) {
	    $first=$ARGV[2];
	}
	else {
	    $first=$uid;
	}
	if (defined($ARGV[3])) {
	    $second=$ARGV[3];
	}
	else {
	    $second=$gid;
	}
	$value=&rc_get($key,$home);

	if ($first eq "-"&&!defined($ARGV[3])) {
	    print $value;
	    exit 0;
	}

	open OUT,"> $tmpdir/.smogval.$first.$second" or exit 1;
	print OUT $value;
	close OUT;
	exit 0;
    }

    if ($command eq "get_pref_default") {
	$key=$ARGV[1];
	if (defined($ARGV[2])) {
	    $first=$ARGV[2];
	}
	else {
	    $first=$uid;
	}
	if (defined($ARGV[3])) {
	    $second=$ARGV[3];
	}
	else {
	    $second=$gid;
	}
	$value=&rc_get_default($key);
	open OUT,"> $tmpdir/.smogval.$first.$second" or exit 1;
	print OUT $value;
	close OUT;
	exit 0;
    }

    if ($command eq "get_location") {
	$exe=$ARGV[1];
	if (defined($ARGV[2])) {
	    $first=$ARGV[2];
	}
	else {
	    $first=$uid;
	}
	if (defined($ARGV[3])) {
	    $second=$ARGV[3];
	}
	else {
	    $second=$gid;
	}
	$value=&location($exe);
	open OUT,"> $tmpdir/.smogval.$first.$second" or exit 1;
	print OUT $value;
	close OUT;
	exit 0;
    }


	if ($command eq "xmmsstop") {
	$xmms_command=&location("xmms");
	unless ($xmms_command eq "") {
	    system("$xmms_command -s");
	}
	exit 0;
    }

    if ($command eq "xmmsplay") {
	$xmms_command=&location("xmms");
	unless ($xmms_command eq "") {
	    system("$xmms_command -p \"$ARGV[1]\" &");
	}
	exit 0;
    }

    if ($command eq "pause") {
	system("touch $tmpdir/$ARGV[1]/pause; chmod 600 $tmpdir/$ARGV[1]/pause");
	exit 0;
    }


    if ($command eq "resume") {
	unlink "$tmpdir/$ARGV[1]/pause";
	exit 0;
    }


	if ($command eq "clear_tmp_files") {
	    $handle=$ARGV[1];
	    #clear old backups (e.g. when saving a set)
	    $curtmpdir="$tmpdir/$handle";
	    &clean_old;
	    &sig_complete;
	    exit 0;
	}


    if ($command eq "undo_audio") {
	$handle=$ARGV[1];
	$curtmpdir="$tmpdir/$handle";
	$statusfile="$curtmpdir/.status";
	&undo_audio;
	&sig_complete;
	exit 0;
    }

    if ($command eq "backup_audio") {
	$handle=$ARGV[1];
	$curtmpdir="$tmpdir/$handle";
	$statusfile="$curtmpdir/.status";
	chdir $curtmpdir;
	&backup_audio;
	&sig_complete;
	exit 0;
    }


    if ($command eq "save_frame") {
	$handle=$ARGV[1];
	$curtmpdir="$tmpdir/$handle";
	$frame=$ARGV[2];
	$name=&mkname($frame);
	$nfile=$ARGV[3];
	$statusfile="$curtmpdir/.status";

	# check the file is writable
	unless (&is_writeable($nfile)) {
	    &sig_error("Unable to open output file !","$GUI_NAME could not write to $nfile.");
	}

	system("$convert_command $curtmpdir/$name$img_ext \"$nfile\" >/dev/null 2>&1");
	exit 0;
    }


    if ($command eq "restore_details") {
	$handle=$ARGV[1];
	$nfile=$ARGV[2];
	$leave_headers=$ARGV[3];

	$curtmpdir="$tmpdir/$handle";
	$statusfile="$curtmpdir/.status";

	chdir $curtmpdir;
	$fsize= -s "$nfile";
	$afsize = -s "audio";
	unlink <*.tar>;
	unlink <event.*>;
	unlink "extended";

	unless (-f "header.lives") {
	    
	    if (defined(open IN,"< header2")) {
		read IN,$val,4;
		
		# TODO - do not assume, store endianness in header !
		$endian=&get_endian;
		$frames=&getint($val);
		read IN,$title,256;
		read IN,$author,256;
		read IN,$comment,256;
	    }
	    
	    $title=~ tr/\x00//d;
	    $author=~ tr/\x00//d;
	    $comment=~ tr/\x00//d;
	    
	    # very old backups didn't have a header2
	    if (! -f "header2") {
		unless ($nfile eq "") {
		    unlink <event.*>;
		    $frames=&count_frames;
		}
	    }

	    # leave headers for restoring VJ sets
	    if ($leave_headers==1) {
		$fsize=0;
	    }
	    else {
		unlink <header header2>;
	    }
	}
	else {
	    unlink <header header2>;
	    
	}

	&sig_complete($fsize,$afsize,$frames,"$title","$author","$comment");
	exit 0;
    }

    if ($command eq "list_plugins") {
	# prefix_dir pref should be set first
	# plugins are returned in sort() order

	my $allow_nonex=$ARGV[1];
	my $allow_subdirs=$ARGV[2];
	my $plugindir=$ARGV[3];
	my $ext=$ARGV[4];

	my $string="";

	if ($ext =~ /^-/) {
	    $strip_ext=1;
	    $ext=substr($ext,1,length($ext));
	}

	if (-d $plugindir) {
	    chdir $plugindir;
	    opendir DIR,$plugindir;
	    my @@files=readdir(DIR);
	    closedir DIR;
	    @@files = sort (@@files);

	    foreach my $plugname (@@files) {
		unless ($plugname =~ /^\./) {
		    if ((-f $plugname && (-x $plugname||$allow_nonex))||($allow_subdirs==1&& -d $plugname)) {
			unless($allow_nonex) {
			    next if ! -x "$plugindir/$plugname";
			}
			unless ($plugname eq "") {
			    if ($ext eq ""|| $plugname =~ /$ext$/) {
				if ($strip_ext==1) {
				    $plugname=(split(/\./,$plugname))[0];
				}
				$string.="$plugname|";
			    }
			}
		    }
		}
	    }
	}
	else {
	    exit 1;
	}
	print "$string\n";
	exit 0;
    }


	if ($command eq "build_rfx_plugins") {
	    if (&location($rfx_builder_multi) eq "") {
		&sig_error("Unable to locate the program $rfx_builder_multi");
		exit 1;
	    }

	    $type=$ARGV[1];
            $script_dir=$ARGV[2];
            $exec_dir=$ARGV[3];
	    system("$rfx_builder_multi $type $script_dir $exec_dir");
	    exit 0;
	}



	if ($command eq "make_thumb") {
	    $handle=$ARGV[1];
	    $curtmpdir="$tmpdir/$handle";
	    $statusfile="$curtmpdir/.status";
	    $dwidth=$ARGV[2];
	    $dheight=$ARGV[3];
	    $file=$ARGV[4];

	    if (! -d "$curtmpdir") {
		mkdir ("$curtmpdir",0700);
	    }

	    $antialias=&rc_get("antialias");

	    $imresact="bound";
	    &get_image_size("$file");
	    if (!($vsize*$hsize)) {
		&sig_complete(0,0);
		exit 0;
	    }

	    chdir $curtmpdir;
	    $name=&mkname(1);


	    if ($antialias eq "false") {
		system("$convert_command +antialias \"$file\" -scale $hsize"."!x"."$vsize! $curtmpdir/$name$img_ext > /dev/null 2>&1");
	    }
	    else {
		system("$convert_command -antialias \"$file\" -resize $hsize"."!x"."$vsize! $curtmpdir/$name$img_ext > /dev/null 2>&1");
	    }
	    &sig_complete($hsize,$vsize);
	    exit 0;
	}


	if ($command eq "version"&&!caller) {
	    print "smogrify $version\n";
	    exit 0;
	}


	if ($command eq "plugin_clear") {
	    # this is a special function which does general cleanup
	    # and then does the "clear" command in the plugin
	    # non-perl plugins have to implement this command themselves
	    #
	    $handle=$ARGV[1];
	    $curtmpdir="$tmpdir/$handle";
	    $statusfile=$curtmpdir."/.status";
	    chdir $curtmpdir;
	    $start=$ARGV[2];
	    $end=$ARGV[3];
	    $plugdir=$ARGV[4];
	    $type=$ARGV[5];
	    $rest=$ARGV[6];
	    $plugin="";
	    unless ($rest eq "") {
		$plugin="$plugdir$type/$rest";
	    }

	    if ($type eq "encoders") {
		if (-f "audio.origbak") {
		    unlink "audio";
		    rename "audio.origbak","audio";
		}
		$areq=&get_form_request($plugin);
		if ($areq&1||$areq&2) {
		    unlink <audiodump.wav audioclip>;
		}
		if ($areq&4) {
		    &clear_symlinks;
		}
	    }
	    if ($plugin eq "") {
		# let the plugin clean up any other temp files
		$command="clear";
		return 1;
	    }
	    else {
		system("$plugin clear $start $end");
		&sig_complete;
		exit 0;
	    }
	}



	if ($command eq "check_for_lock") {
	    # check if there is a lock file for a set, and if so is it in use
	    my $setname=$ARGV[1];
	    my $exename=$ARGV[2];
	    my $pid=$ARGV[3];

            opendir DIR,"$tmpdir/$setname";

	    while (my $file=readdir(DIR)) {
		if ($file=~/^lock\.(.*)/) {
		    #found a lockfile
		    my $proc=$1;
		    unless ($proc eq $pid) {
			my $exe=`readlink -n /proc/$proc/exe`;
			my $short_exe=&my_basename($exe);
			if ($short_exe eq $exename) {
			    # and it's in use
			    closedir DIR;
			    print $proc."\n";
			    exit 1;
			}
			unlink "$tmpdir/$setname/$file";
		    }
		}
	    }
            closedir DIR;
	    exit 0;
	}





	if ($command eq "get_recovery_file") {
	    #find first non-in-use recovery file for given uid, gid
	    my $uid=$ARGV[1];
	    my $gid=$ARGV[2];
	    my $exename=$ARGV[3];
            opendir DIR,"$tmpdir";

	    while (my $file=readdir(DIR)) {
		if ($file=~/^recovery\.$uid\.$gid\.(.*)/) {
		    if (-z $file) {
			unlink $file;
		    }
		    else {
			my $exe=`readlink -n /proc/$1/exe`;
			my $short_exe=&my_basename($exe);
			unless ($short_exe eq $exename) {
			    print $file;
			    closedir DIR;
			    exit 0;
			}
		    }
		}
	    }
            closedir DIR;
	    exit 0;
	}


        if ($command eq "get_next_in_set") {
            # this is a special function for lives-exe. It will look for
            # clips on the disk that have the marker file "set.$name"
	    # only used now for pre 0.9.6 versions

            $last=$ARGV[1];
            $setname=$ARGV[2];
            $pid=$ARGV[3];

            opendir DIR,"$tmpdir";
	    @@allfiles=readdir(DIR);
            closedir DIR;

            foreach my $subdir (@@allfiles) {
		if (-f "$tmpdir/$subdir/set.$setname") {
                    if ($last eq "none") {
                        $found=$subdir;
                        last;
                    }
                    if ($last eq $subdir) {
                        $last="none";
                    }
                }
	    }

	    if ($found eq "") {
                $found="none";
            }

            $infofile="$tmpdir/.info.$pid";
            `sync;sync;sync`;

            if (-d $tmpdir) {
                open OUT,"> $infofile";
                print OUT $found;
                close OUT;
            }
            exit 0;
        }


	if ($command eq "cleanup"||$command eq "weed") {
	    chdir $tmpdir or die "Couldn't cd to ".$tmpdir."\n";
	    print "Cleaning up temporary space for $GUI_NAME.\n";
	    if ($command eq "cleanup") {
		`/bin/rm -f /tmp/.smogval*`;
		`/bin/rm -rf *`;
		`/bin/rm -f .*`;
	    }
	    else {
		$new_temp=$ARGV[1];
		unless ($new_temp eq "") {
		    # here is where we create a new temp directory
		    unless (-d $new_temp||(mkdir $new_temp,0777)) {
			print "Smogrify: Unable to create new directory $new_temp!\n";
			exit 1;
		    }
		    print "Smogrify: moving sets from $tmpdir to $new_temp\n";
		}
		else {
		    print "Smogrify: Leaving sets intact.\n";
		}
		&weed;
	    }
	    exit 0;
	}
	
	if (substr($command,0,7) eq "fxinit_") {
	    # call onchange_init
	    $command=substr($command,7);
	    $dir=$ARGV[1];

            $width=$ARGV[2];
            $height=$ARGV[3];

	    $plugin_name="$dir/$command";
	    shift; shift; shift;

	    $ARGV[0]="onchange_init";
	    require("$plugin_name");
	    exit 0;
	}



	if ($command eq "count_frames") {
	    print &count_frames;
	    exit 0;
	}


	if ($command eq "get_proj_set") {
	    my $proj_file=$ARGV[1];
	    my $out=`tar --exclude=*/* -tzf $proj_file`;
	    unless ($out=~/\/$/) {
		exit 1;
	    }
	    chomp $out;
	    chop $out;
	    print $out;

	    exit 0;
	}

        if ($command eq "mv_pre") {
	    $handle=$ARGV[1];
	    $curtmpdir="$tmpdir/$handle";
            $statusfile=$curtmpdir."/.status";
	    unlink "$curtmpdir/pause";
	    $start=$ARGV[2];
	    $end=$ARGV[3];
	    &mv_pre;
	    &sig_complete;
	    exit 0;
	}



	if ($command eq "clear_symlinks") {
	    $handle=$ARGV[1];
	    &clear_symlinks;
	    exit 0;
	}



    
####################################################################    
    # run the rest in background
    if ($background==1) {
	if (fork()) {
	    exit 0;
	}
    }
####################################################################
    umask $umask;

    if (!caller&&(!defined($ARGV[1]) || $ARGV[1] eq "")) {
	&usage;
	exit 1;
    }

    $handle=$ARGV[1];

    $curtmpdir="$tmpdir/$handle";
    $statusfile=$curtmpdir."/.status";

    if ($command eq "play"||$command eq "play_opening_preview") {
	$pidfile=$curtmpdir."/.pidpb";
    }
    else {
	$pidfile=$curtmpdir."/.pid";
    }

    if ($command eq "play_opening_preview") {
	# play_opening_preview is exactly like play
	# except our audio filename is different
	$opening_preview=1;
	$command="play";
    }

	unless ($command eq "keep"||$command eq "close") {
	    # tell the world our pid
	    &sig_pid;
	}


    if ($command eq "play") {

	$endian=&get_endian;

	$fps=$ARGV[2];
	if ($fps==0) {
	    $fps=&rc_get("default_fps");
	}

	$start=$ARGV[3];
	$end=$ARGV[4];

	$fs=" ";
	if (defined $ARGV[5]) {
	    if ($ARGV[5]!="0") {
		$fs=" -fs ";
		}
	}
	$loop=0;
	if ($ARGV[6]!=0) {
	    $loop=$ARGV[6];
	}
	$wid=" ";
	if (defined $ARGV[7]) {
	    if ($ARGV[7]!=0) {
		$wid=" -wid ".$ARGV[7]." ";
	    }
	}
	if (!defined $ARGV[8]||$ARGV[8]==0||!($fs eq " ")) {
	    $width="";
	}
	else {
	    $hsize=$ARGV[8];
	    $width="-x $hsize ";
	}
	if (!defined $ARGV[9]||$ARGV[9]==0||!($fs eq " ")) {
	    $height="";
	}
	else {
	    $vsize=$ARGV[9];
	    $height="-y $vsize ";
	}
	if (!defined $ARGV[10]||$ARGV[10]==0) {
	    $arate=44100;
	}
	else {
	    $arate=$ARGV[10];
	}
	if (!defined $ARGV[11]||$ARGV[11]==0) {
	    $achans=2;
	}
	else {
	    $achans=$ARGV[11];
	}

	if (!defined $ARGV[12]||$ARGV[12]==0) {
	    $asamps=2;
	    $stype="w";
	}
	else {
	    $asamps=$ARGV[12];
	    if ($asamps>7) {
		$asamps/=8;
	    }
	}
	if (!defined $ARGV[13]) {
	    $signed=1;
	}
	else {
	    $signed=$ARGV[13];
	}

	if (!defined $ARGV[14]) {
	    $aendian=$endian;
	}
	else {
	    $aendian=$ARGV[14];
	}

	if (defined($opening_preview)) {
	    $aformat=".raw";
	    $audiofile=$curtmpdir."/audiodump.pcm";
	}
	else {
	    $aformat=".raw";
	    $audiofile=$curtmpdir."/audio";
	}


	$audio_player=&rc_get("audio_player");

	if (-f $audiofile && $arate) {

	    $audio_start=($start-1)/$fps;
	    $audio_end=$end/$fps;

	    $mute="";
	    if ($arate<0) {
		$mute=" -ao null  ";
		$arate=-$arate;
		if ($audio_player eq "sox") {
		    $mute=" -v 0 ";
		}
	    }
	    
	    $audio_play_command=&rc_get("audio_play_command");

	    if ($audio_player eq "sox") {
		$audio_effect=&rc_get("audio_effect");
		$trimcom=" trim $audio_start";

		if (($audio_end>$audio_start)&&$end>0) {
		    $trimcom .= " ".($audio_end-$audio_start);
		}
		else {
		    $trimcom .=" 10000000";
		}

		if ($signed==1) {
		    $signed="s";
		}
		else {
		    $signed="u";
		}

		if ($aendian==$endian) {
		    $aendian="";
		}
		else {
		    $aendian="-x";
		}
		
		if ($audio_effect eq "flanger1") {
		    $audio_effect="flanger 0.6 0.87 3.0 0.9 0.5 -s";
		}
		elsif ($audio_effect eq "echo1") {
		    $audio_effect="echo 0.8 0.9 1000.0 0.3";
		}
		elsif ($audio_effect eq "chorus1") {
		    $audio_effect="chorus 0.6 0.9 50.0 0.4 0.25 2.0 -t 60.0  0.32  0.4 1.3 -s";
		}
		elsif ($audio_effect eq "reverb1") {
		    $audio_effect="reverb 1.0 600.0 180.0 200.0";
		}
		elsif ($audio_effect eq "phaser1") {
		    $audio_effect="phaser 0.89 0.85 1.0 0.24 2.0 -t";
		}
		else {
		    $audio_effect="";
		}
		$sox_version=&get_sox_version;

		if ($sox_version<13) {
		    if ($asamps==1) {
			$stype="b";
		    }
		    elsif ($asamps==2) {
			$stype="w";
		    }
		    $aformat=".".$signed.$stype;
		    $syscom2="$audio_play_command $mute -c $achans -r $arate -$signed $aendian -t $aformat -$stype $audiofile $trimcom $audio_effect";
		}
		else {
		    $syscom2="$audio_play_command $mute -c $achans -r $arate -$signed $aendian -t $aformat -$asamps $audiofile $trimcom $audio_effect";
		}
	    } else {
		# mplayer seemingly has no easy way of playing unsigned or wrong endian
		$syscom2="$audio_play_command -demuxer rawaudio -rawaudio rate=$arate :channels=$achans:samplesize=$asamps $mute $audiofile -ss ".($audio_start-1);
	    }
	}
	
	$showed_err=0;

	do {
	    if (! -d "$curtmpdir" || -f "$curtmpdir/.stoploop" || ! -f $audiofile) {
		$loop=0;
	    }
	    else {
		$syscom3=$syscom2.">/dev/null 2>&1";
		$retval=system($syscom3);
		if ($retval>255) {
		    unless ($showed_err) {
			print STDERR "Error playing audio !\n";
			print STDERR "Failed command was: $syscom2\n";
			$syscom2;
			$showed_err=1;
		    }
		}
	    }
	} while ($loop);
	&sig_complete_audio;

	unlink "$curtmpdir/.stoploop";

	exit 0;
    }


	if ($command eq "open") {
	unlink "$curtmpdir/pause";

	$file=$ARGV[2];
	$ss="";

	$withsound=$ARGV[3];

	if (defined($ARGV[4]) && $ARGV[4] > 0) {
	    $ss=" -ss $ARGV[4] ";
	}
	$frames="";
	if (defined($ARGV[5]) && $ARGV[5] > 0 ) {
	    $ARGV[5]++;  # cf below, we remove 1st frame
	    $frames=" -frames $ARGV[5] ";
	}
	$extra_params=$ARGV[6];
	$band="";
	if ($extra_params eq "nobandwidth") {
	    $extra_params="";
	}
	else {
	    if ($extra_params eq "sendbandwidth") {
		$bandwidth=&rc_get("dl_bandwidth_K");
		if ($bandwidth eq "") {
		    $bandwidth=64;
		}
		$band="-bandwidth $bandwidth"."000";
		$extra_params="";
	    }
	}
	$compression=&rc_get("open_compression_percent");
	if ($compression eq "") {
	    $compression=25;
	}

	chdir $curtmpdir;

	# let get_file_info set this
	#$mplay_command=&rc_get("video_open_command");

	# process video

	# 3 other files we will use
	$curtmpfile=".temp";
	$audio_out="audio";
	$audio_in="audiodump.pcm";

	if ($img_ext eq ".png") {
	    $compression=int($compression/10.001)
	}
	else {
	    $quality=int(100-$compression);
	}

	$xframes=$frames;

	my $wavhead=":nowaveheader";

	if ($file=~/:\/\//) {
	    $is_remote=2;
	    #$wavhead=""; # need wav header, as user will probably finish by
	                 # quitting, thus we won't send full info
	}
	&get_file_info;

	if ($type eq "jpeg" || $type eq "png") {
	    $count=$frames;
	}
	else {
	    $frames=$xframes;

	    if ($achans eq "" || $achans eq "0") {
		$channs="";
	    }
	    else {
		$channs="-channels $achans";
	    }
	    
	    if ($withsound eq "0") {
             #video only
		if ($img_ext eq ".jpg") {
		    $syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo jpeg:quality=$quality -fps 100000 $ss $frames -noframedrop -ao null \"$file\" $extra_params </dev/null";
		}
		else {
		    $syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo png:z=$compression -fps 100000 $ss $frames -noframedrop -ao null \"$file\" $extra_params </dev/null";
		}
	    }
	    elsif ($withsound eq "1") {
             #video and audio 
		if ($img_ext eq ".jpg") {
		    $syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo jpeg:quality=$quality $ss -noframedrop $frames -ao pcm:fast$wavhead $channs -mc 0  \"$file\" $extra_params </dev/null";
		}
		else {
		    $syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo png:z=$compression $ss -noframedrop $frames -ao pcm:fast$wavhead $channs -mc 0  \"$file\" $extra_params </dev/null";
		}
            }
            else {
             #audio only 
		$syscom=$mplay_command . " -quiet $band -vo null $ss $frames -ao pcm:fast$wavhead $channs -mc 0 \"$file\" $extra_params </dev/null";
            }
	    
	    if (defined($DEBUG_OPEN)) {
		print STDERR "open command for $handle is: $syscom\n";
	    }
	    
	    $syscom2=$syscom." >$curtmpfile 2>/dev/null";

	    &sig_progress(0);

	    system($syscom2);
	    
            if (!-f $curtmpfile) {
              exit 1;
            }


	    @@info=split /  /, `grep VIDEO: $curtmpfile`;
	    @@info2=split / /, `grep AUDIO: $curtmpfile`;
	    
	    unlink $curtmpfile;
	    #$type=$info[1];
	    
	    $size=$info[2];
	    $hsize=(split /x/,$size)[0];
	    $vsize=(split /x/,$size)[1];
	    $bpp=$info[3];
	    chomp($bpp);
	    $fps=(split / /,$info[4])[0];
	    
	    $arate=$info2[1];
	    $achans=$info2[3];

	    if (! -d $curtmpdir) {
		#curtmpdir can be removed by cancel
		exit 1;
	    }
	    
	    # double check number of frames
	    $count=&count_frames;

	}

	# if the last frame has zero size, delete it
	if ($count>0) {
	    $name=&mkname($count);
	    while (-f "$name$img_ext" && -z "$name$img_ext" && $count > 1) {
		unlink "$name$img_ext";
		$count--;
	    }
	    # double check image size
	    $name=&mkname(1);
	    $imresact="none";
	    &get_image_size("$name$img_ext");
	}

	if (-f $audio_in) {
	    rename $audio_in,$audio_out;
            $af_size = -s $audio_out; 
	}

	if ($count==0||$type eq "Frames" ||$type eq "jpeg"||$type eq "png"||$type eq "Audio") {
	    # we could have audio or images
	    if (-f $audio_out) {
		# just in case...
		$type="Audio";
	    }
	    if (! -d $curtmpdir) {
		#curtmpdir can be removed by cancel
		exit 1;
	    }
	    if ($af_size>0||$count>0) {
		&sig_complete($handle,$count,$type,$hsize,$vsize,$bpp,$fps,$f_size,$arate,$achans,$asamps,$signed,$endian,$af_size,$title,$author,$comment);
		exit 0;
	    }
	    # should have audio then
	    if (!($type eq "Audio")) {
		if (!defined($DEBUG_OPEN)&&$withsound>=0) {
		    print STDERR "\nFailed to open file - I tried:\n\n $syscom\n";
		    print STDERR "\nMaybe you are missing a library in mplayer (or it is not a valid media file) ?\n";
		}
		&sig_error("This does not appear to be a valid video or image file","$GUI_NAME was unable to open it.","","Check the terminal window for more details.");
		
	    }
	}

	# mplayer seems to sometimes output one extra frame for jpg
	if (defined($MPLAYER_EXTRA_OPEN_FRAME_BUG)&&($count==$xframes+1)&&(($frames eq "")||(!($frames eq "") && ($count<$ARGV[4])||($ARGV[3]==0)))) {
	    $name=&mkname($count);
	    unlink "$name$img_ext";
	    $count--;
	}

	unless ($frames eq "") {
	    $tfps=$fps;
	    if ($fps<1) {
		$tfps=1;
	    }
	    if ($ARGV[3]>=(1/$tfps)) {
		# if we opened a selection, mplayer wrongly outputs frame 1, 
		# so we usually need to delete it

		#TODO ** - check if this is still the case

		for ($i=2;$i<=$count;$i++) {
		    $from=&mkname($i);
		    $to=&mkname($i-1);
		    rename "$from$img_ext", "$to$img_ext";
		}
		$count--;
	    }
	}

	unless (!defined($MPLAYER_SEL_AUDIO_SYNCH_BUG)||$ss eq ""||$achans==0) {
	    # try as best we can to sync sound and video for a selection
	    $audio_out=&clip_audio(0.5,1000000.);
	    rename $audio_out,"audio";
	    $audio_out="audio";
	}

	$af_size= -s $audio_out;
	if (-d $curtmpdir) {
	    &sig_complete($handle,$count,$type,$hsize,$vsize,$bpp,$fps,$f_size,$arate,$achans,$asamps,$signed,$endian,$af_size,$title,$author,$comment);
	}
	exit 0;
    }

    if ($command eq "get_details") {
	$handle=$ARGV[1];
	$curtmpdir="$tmpdir/$handle";
	$statusfile="$curtmpdir/.status";

	#attempt to get file details
	$file=$ARGV[2];
	$only_first=1;

	if (defined($ARGV[3])) {
	    $is_remote=$ARGV[3];
	}
	if (defined($ARGV[4])) {
	    $is_audio=$ARGV[4];
	}
	&get_file_info;
	&sig_complete($handle,$count,$type,$hsize,$vsize,$bpp,$fps,$f_size,$arate,$achans,$asamps,$signed,$endian,$af_size,$title,$author,$comment);
	exit 0;
    }


    if ($command eq "dvgrab") {

	if (&location("dvgrab") eq "") {
	    &sig_error("You need to install dvgrab to use this option.");
	}

	chdir $curtmpdir;
	system("dvgrab --format jpeg lives 2>/dev/null");

	if (-d $curtmpdir) {
	    &sig_complete;
	}
	exit 0;
    }


	if ($command eq "close") {
	    if (defined(open IN,"< $pidfile")) {
		close IN;
		# cancel any processing
		system("smogrify cancel $handle");
	    }
	    
	    if (chdir $curtmpdir) {
		unlink <* .*>;
		chdir $tmpdir;
		rmdir $curtmpdir;
	    }
	    exit 0;
	}
    

	
	if ($command eq "save") {
	    unlink "$curtmpdir/pause";
	    chdir $curtmpdir;
	    $get_rfx=0;

	    if ($handle eq "get_rfx") {
		$get_rfx=1;
		shift(@@ARGV);
		$handle=$ARGV[1];
	    }
	    else {
		unlink "audiodump.wav";
	    }


	    $plugin=$ARGV[2];

	    $fps=$ARGV[3];
	    $nfile=$ARGV[4];

	    # check the file is writable
	    unless ($nfile eq ""||&is_writeable($nfile)) {
		&sig_error("Unable to open output file !","$GUI_NAME could not write to $nfile.");
	    }

	    $start=$ARGV[5];
	    $is_linked=0;

	    #create symlinks in /tmp (for dynebolic)
	    $linksdir="/tmp/lives-symlinks/$handle/";

	    if ($start==-1) {
		# special value which tells us we are dealing with symlinks
		$start=1;
		$is_linked=1;
	    }

	    $end=$ARGV[6];
	    $arate=$ARGV[7];
	    $achans=$ARGV[8];
	    $asamps=$ARGV[9];
	    if (defined($ARGV[10])) {
		$ssigned=$ARGV[10];
	    }
	    
	    else {
		$ssigned=1;
		if ($asamps==8) {
		    $ssigned=0;
		}
	    }
	    if ($ssigned==1) {
		$asigned="-s";
	    }
	    else {
		$asigned="-u";
	    }
	    
	    if (defined($ARGV[11])) {
		$aud_start=$ARGV[11];
	    }
	    else {
		$aud_start=($start-1.)/($fps*1.);
	    }
	    if (defined($ARGV[12])) {
		$aud_end=$ARGV[12];
	    }
	    else {
		$aud_end=($end*1.)/($fps*1.);
	    }


	    # get image size ($hsize x $vsize)
	    $imresact="none";
	    my $firstframe=&mkname($start);
	    &get_image_size("$firstframe$img_ext");

	    $otype=&rc_get("output_type");

	    $encoder=&rc_get("encoder");

	    if (&rc_get("debug_encoders") eq "true") {
		$DEBUG_ENCODERS=1;
	    }
	    $audiofile="";

	    if ($get_rfx==0) {

		$areq=&get_form_request($plugin);


		#prepare audio stream if requested
		if (-f "$curtmpdir/audio" && $arate>0) {
		    $origaudio=$audiofile=$audio_in="$curtmpdir/audio";
		    if ($areq&1||$aud_start!=0.) {
			
			# encode sound up to the next nearest second
			# seems to be the norm...
			$aud_length=($aud_end-$aud_start);
			$aud_length=int($aud_length+1.0);
			$aud_end=$aud_start+$aud_length;
			
			# clip the (raw) audio

			$audiofile=$audio_in=&clip_audio($aud_start,$aud_end);
			
			#pad to end with silence
			$desired_length=$aud_length*$arate*$achans*$asamps/8;
			&append_silence($desired_length,$audiofile);
			
			if ($aud_start!=0.&&!($areq&1)) {
			    if (&rc_get("conserve_space") eq "true") {
				`/bin/rm -f $origaudio`;
			    }
			    else {
				rename "$origaudio","$origaudio.origbak";
			    }
			    rename "$curtmpdir/$audiofile","$origaudio";
			    $audio_file=$audio_in=$origaudio;
			}
		    }
		    if ($areq&2) { 
			# convert raw audio to wav
			$audio_out=$curtmpdir . "/audiodump.wav";
			&convert_audio_to_wav;
			unlink $audio_in;
			$audiofile=$audio_out;
		    }
		}
		
		if ($areq&4) {
	
		    if ($start>1) {
			# move the selection down so that frames start at 1
			# note, LiVES never uses this any more, 
			# instead it first calls link_frames, and possibly sets $start to -1
			# (see above)

			if (-d $linksdir) {
			    system("/bin/rm -rf $linksdir");
			}
		    
			system("/bin/mkdir -p $linksdir");
			system ("/bin/chmod -R 777 $linksdir");

			for ($i=1;$i<=($end-$start+1);$i++) {
			    $name=&mkname($i);
			    $from=&mkname($i+$start-1);
			    if (-f "$curtmpdir$from$img_ext") {
				system ("/bin/ln $curtmpdir/$from$img_ext $linksdir$name$img_ext");
			    }
			}
			$is_linked=1;
		    }
		}
		
		if ($is_linked==1) {
		    if (-f $audiofile) {
			my $xaudiofile=(split(/\//,$audiofile))[-1];
			system("/bin/ln $audiofile $linksdir$xaudiofile");
		    }
		    chdir $linksdir;
		}

	    }


	    unless ($plugin eq "") {
		#non-perl
	        if (defined $DEBUG_ENCODERS) {
		    $DB_ENCODERS=$DEBUG_ENCODERS;
		}
		else {
		    $DB_ENCODERS=0;
		}
		$atype=&rc_get("encoder_acodec");
		$fields="$fps \"$nfile\" $start $end $img_ext $otype $atype $hsize $vsize";
		$fields.=" $DB_ENCODERS";
		$fields.=" $arate $achans $asamps $ssigned";
		if ($get_rfx==0) {
		    $fields.=@@ARGV[13..$#ARGV];
		    system("$plugin encode $fields");
		}
		else {
		    system("$plugin get_rfx $fields");
		}

		&sig_complete;
		exit 0;
	    }


	    if (-f ".comment") {
		open IN,"< .comment";
		read IN,$string,1040;
		close IN;
		unlink ".comment";
	    }
	    @@tmp=split(/\|\|\%/,$string);
	    $title=$tmp[0];
	    $author=$tmp[1];
	    $comment=$tmp[2];
	    chomp($comment);

	    if ($get_rfx==0) {
		$command="encode";
	    }
	    else {
		$command="get_rfx";
	    }
	    return 1;
	    exit 0; # just in case
	}


	if ($command eq "link_frames") {
	unlink "$curtmpdir/pause";
	    chdir $curtmpdir;

	    my $start=$ARGV[2];
	    my $end=$ARGV[3];

	    my $from_handle=$ARGV[4];

	    my $i;
	    my $audiofile="audio";


	    if ($from_handle eq "") {
		#create symlinks in /tmp for dynebolic
		$linksdir="/tmp/lives-symlinks/$handle/";

		if (-d $linksdir) {
		    system("/bin/rm -rf $linksdir");
		}

		system("/bin/mkdir -p $linksdir");
		system ("/bin/chmod -R 777 $linksdir");
	    }
	    else {
		$linksdir=$curtmpdir;
		$curtmpdir="$tmpdir/$from_handle/";
	    }

	    for ($i=1;$i<=($end-$start+1);$i++) {
		$name=&mkname($i);
		$from=&mkname($i+$start-1);
		if (-f "$curtmpdir/$from$img_ext") {
		    system ("/bin/ln $curtmpdir/$from$img_ext $linksdir/$name$img_ext");

		}
		&sig_progress($i);
	    }

 	    unless ($from_handle eq "") {
		$curtmpdir=$linksdir;
	    }

	    &sig_complete;
	    exit 0;
	}


	if ($command eq "resize_all") {
	    unlink "$curtmpdir/pause";
	    chdir $curtmpdir;
	    $end=$ARGV[2];

	    my $width=$ARGV[3];
	    my $height=$ARGV[4];
	    

	    $resize_ext=".mgk";

	    for ($i=1;$i<=$end;$i++) {
		$name=&mkname($i);
		&resize_frame($name,$width,$height);
		&sig_progress($i);
	    }
	    $start=1;
	    &mv_mgk;
	    &sig_complete;
	    exit 0;
	}

    if ($command eq "backup") {
	$withaudio=$ARGV[2];
	$start=$ARGV[3];
	$end=$ARGV[4];

	if ($withaudio==0) {
	    $audio="";
	}
	else {
	    $audio="audio";
	}

	$nfile=$ARGV[5];

	unlink "$curtmpdir/pause";
	chdir $curtmpdir;

	# check the file is writable
	unless (&is_writeable($nfile)) {
	    &sig_error("Unable to open output file !","$GUI_NAME could not write to $nfile.");
	}

	unlink <*.tar>;
	system ("tar -cf header.tar $audio header* extended* event.* 2>/dev/null");

	if ($start>0) {
	    # we have to add frames 100 at a time, otherwise tar complains about 'too many parameters'
	    $oend=$end;
	    $nexthundred=int($start/100)+1;
	    if ($end>$nexthundred*100-1) {
		$end=$nexthundred*100-1;
	    }
	    
	    $tarcount=1;
	    $tarname=&mkname($tarcount).".tar";
	    
	    for ($i=$start;$i<=$end;$i++) {
		$name=&mkname($i);
		system("tar -rf $tarname $name$img_ext");
		&sig_progress(int($start+($i-$start)/4));
	    }
	    
	    while (($nexthundred+1)*100<=$oend) {
		$end=$nexthundred*100;
		$len=length ($nexthundred);
		$name=substr("000000",$len) . $nexthundred . "*";
		$tarname=&mkname(++$tarcount).".tar";
		system("tar -cf $tarname $name$img_ext");
		$nexthundred++;
		&sig_progress(int($start+($end-$start)/4));
	    }
	    
	    $tarname=&mkname(++$tarcount).".tar";
	    
	    for ($i=$end;$i<=$oend;$i++) {
		$name=&mkname($i);
		system("tar -rf $tarname $name$img_ext 2>.tar_err");
		if (-f ".tar_err") {
		    open IN,"< .tar_err";
		    read IN,$tarerr,255;
		    close IN;
		    unless ($tarerr eq "") {
			&sig_err("Error creating new backup - temp dir may be full.",$tarerr);
			unlink <*.tar .tar_err>;
			exit 1;
		    }
		}
		&sig_progress($start+($i-$start));
	    }
	}
	system ("tar -czf \"$nfile\" *.tar 2>.tar_err");
	unlink <header.tar 0*.tar>;
	if (-f ".tar_err") {
	    open IN,"< .tar_err";
	    read IN,$tarerr,255;
	    close IN;
	    # TODO - check this, it is not working
	    unless ($tarerr eq "") {
		&sig_error("Error creating new backup.",$tarerr);
		unlink <*.tar .tar_err>;
		exit 1;
	    }
	}
	$size=-s "$nfile";
	&sig_complete($size);
	exit 0;
    }


    if ($command eq "restore") {
	$nfile=$ARGV[2];
	chdir $curtmpdir;

	system("tar -zxf \"$nfile\" 2>/dev/null");
	unless (-f "header.tar"||-f "header"||-f "header.lives") {
	    &sig_error("This does not appear to be a valid backup file","$GUI_NAME was unable to open it.");
	}
	system("for i in *.tar; do tar -xf \$i 2>/dev/null; /bin/rm -f \$i; done");
	&sig_complete;
	exit 0;
    }



    if ($command eq "reorder") {
	unlink "$curtmpdir/pause";
	if (!defined($ARGV[2])) {
	    $endian=&get_endian;
	}
	else {
	    $endian=$ARGV[2];
	}
	if (defined $ARGV[3]) {
	    $newwidth=$ARGV[3];
	}
	if (defined $ARGV[4]) {
	    $newheight=$ARGV[4];
	}
	if (defined $ARGV[5]) {
	    if ($ARGV[5]==1) {
		$leave_bak=1;
	    }
	}
	if (defined $ARGV[6]) {
	    $old_end=$ARGV[6];
	}

	$newframe=-1;
	$event_file="$curtmpdir/event.frames";
	$resize_ext=".tmp";
	chdir $curtmpdir;

	unless ($leave_bak==1) {
	    &clean_old;
	}

	if (defined(open IN,"< $event_file")) {
	    $fcount=1;
	    read IN,$val,4;
	    $pstart=&getint($val);
	    $count=$pstart;
	    
	    while ($newframe!=0) {
		read IN,$val,4;
		$newframe=&getint($val);
		if ($newframe>0) {
		    $from=&mkname($newframe);
		    if (-f "$curtmpdir/$from$img_ext") {
			$to=&mkname($count);

			if (defined $newwidth && defined $newheight && $newwidth*$newheight > 0) {
			    &resize_frame($from,$newwidth,$newheight);
			    unlink "$to.mgk";
			    rename "$from$resize_ext","$to.mgk";
			}
			else {
			    # we don't preview here...
			    unless ($from eq $to) {
				`/bin/cp $from$img_ext $to.mgk`;
			    }
			}
		    }

		    $count++;
		}
		&sig_progress($fcount++);
	    }
	    close IN;
	}
	
	else {
	    &sig_error;
	}

	$start=$pstart;
	$new_count=--$count;
	$end=$count;

	&mv_mgk;

	if ($end<$old_end) {
	    for ($i=$end+1;$i<=$old_end;$i++) {
		$name=&mkname($i);
		if (-f "$curtmpdir/$name$img_ext") {
		    unlink "$curtmpdir/$name.bak";
		    rename "$curtmpdir/$name$img_ext","$curtmpdir/$name.bak";
		}
	    }
	    &sig_progress($i);
	}

	&sig_complete($new_count);
	exit 0;
    }



    if ($command eq "deorder") {
	$start=$ARGV[2];
	$end=$ARGV[3];
	$frames=$ARGV[4];
	if (defined $ARGV[5]) {
	    $leave_bak=$ARGV[5];
	}
	else {
	    $leave_bak=0;
	}

	chdir $curtmpdir;

	$oend=$end;
	if ($end>$frames) {
	    $end=$frames;
	}

	&undo(!$leave_back);

	for ($i=$frames+1;$i<=$oend;$i++) {
	    $name=&mkname($i);
	    if (!$leave_bak) {
		unlink "$name$img_ext";
	    }
	    else {
		rename "$curtmpdir/$name$img_ext","$curtmpdir/$name.mgk";
		
	    }
	}
	if (!$leave_bak) {
	    &clean_old;
	}
	&sig_complete;
	exit 0;
    }


    if ($command eq "cut") {
	unlink "$curtmpdir/pause";
	&clean_old;

	$start=$ARGV[2];
	$end=$ARGV[3];
	$cut_audio=$ARGV[4];
	$frames=$ARGV[5];
	&cut($start,$end);

	if ($cut_audio) {
	    $fps=$ARGV[6];
	    $arate=$ARGV[7];
	    $achans=$ARGV[8];
	    $asamps=$ARGV[9];
	    if ($arate*$asamps*$achans) {
		$start=($start-1)/$fps;
		$end=$end/$fps;
		&cut_audio;
	    }
	}
	&sig_complete;
	exit 0;
    }


	if ($command eq "delete_all") {
	    $frames=$ARGV[2];
	    if (! -d $curtmpdir) {
		&sig_complete;
		exit 1;
	    }
	    chdir $curtmpdir;
	    unlink <*>;
	    if ($GUI_NAME eq "LiVES") {
		# LiVES needs this to stop the progress dialog from flickering 
		sleep(1);
	    }
	    &sig_complete;
	    exit 0;
	}



    if ($command eq "reverse") {
	unlink "$curtmpdir/pause";
	$start=$ARGV[2];
	$end=$ARGV[3];
	&reverse;
	&sig_complete;
	exit 0;
    }


    if ($command eq "undo") {
	unlink "$curtmpdir/pause";

	$start=$ARGV[2];
	$end=$ARGV[3];
	&undo;
	&sig_complete;
	exit 0;
    }


    if ($command eq "redo") {
	unlink "$curtmpdir/pause";

	$start=$ARGV[2];
	$end=$ARGV[3];

	&mv_mgk(1);
	&sig_complete;
	exit 0;
    }


    if ($command eq "fs_preview") {
	$win=$ARGV[2];
	$hsize=$ARGV[3];
	$vsize=$ARGV[4];
	$start_time=$ARGV[5];
	$preview_frames=$ARGV[6];
	$file=$ARGV[7];
	$extra_params=$ARGV[8];
	$mplayer_command=&location("mplayer");

	system("$mplayer_command -quiet -x $hsize -y $vsize -wid $win -vo x11 -zoom -ss $start_time -frames $preview_frames \"$file\" $extra_params >/dev/null 2>&1 </dev/null");
	&sig_complete;
	exit 0;
    }

        if ($command eq "mv_mgk") {
	    unlink "$curtmpdir/pause";
	    $start=$ARGV[2];
	    $end=$ARGV[3];
	    &mv_mgk;
	    &sig_complete;
	    exit 0;
	}



    if ($command eq "export_audio") {
	$audio_start=$ARGV[2];
	$audio_end=$ARGV[3];
	$arate=$ARGV[4];
	$achans=$ARGV[5];
	$asamps=$ARGV[6];
	$asigned=$ARGV[7];
	$nrate=$ARGV[8];
	$nfile=$ARGV[9];

	# check the file is writable
	unless (&is_writeable($nfile)) {
	    &sig_error("Unable to open output file !","$GUI_NAME could not write to $nfile.");
	}
	if ($asigned==1) {
	    $asigned="-s";
	}
	else {
	    $asigned="-u";
	}
	
	if ($audio_end>0.) {
	    $audio_in=&clip_audio($audio_start,$audio_end);
	}
	else {
	    $audio_in="$curtmpdir/audio";
	}
	# convert raw audio to wav
	$audio_out=$curtmpdir . "/audiodump.wav";
	&convert_audio_to_wav;
	if ($audio_end>0.) {
	    unlink $audio_in;
	}
  
	system("mv $audio_out \"$nfile\" >/dev/null 2>&1");

	&sig_complete;
	exit 0;
    }



    if ($command eq "append_audio") {
	# here we end up with (raw) 'audiodump', which will be renamed to 'audio' in commit_audio
	$endian=&get_endian;

	$type=$ARGV[2];
	$nrate=$ARGV[3];
	$nchans=$ARGV[4];
	$nsamps=$ARGV[5];
	$nsigned=$ARGV[6];
	$nendian=$ARGV[7];
	$file=$ARGV[8];
	$audio_in="audiodump.wav";

	chdir $curtmpdir;
	$audiofile="audio";

	if ($type eq "mp3") {
	    &mp3_open;
	}
	elsif ($type eq "ogg") {
	    &ogg_open;
	}
	elsif ($type eq "wav") {
	    &wav_open;
	}
	else {
	    &othera_open;
	}

	`sync;sync;sync`;

	unless (-f $audio_in) {
	    &sig_error("$GUI_NAME was not able to open the file","$file");
	}
	
	$audio_out="audio.new";
	&convert_audio_to_raw;
	unlink $audio_in;

	$audio_bak="audio.bak";

	# resample $audio_out (if required)
	unless ($arate==$nrate&&$achans==$nchans&&$asamps==$nsamps&&$nsigned==$signed&&$nendian==$endian) {
	    $audio_in=$audio_out;
	    $audio_out=$audio_bak;
	    &resample_audio;
	    unlink $audio_in;
	    rename $audio_out,$audio_in;
	    $audio_out=$audio_in;
	}

	system("cat audio $audio_out > audiodump");

	unlink $audio_out;
	$fsize=-s "audiodump";
	&sig_complete($fsize);
	exit 0;
    }


    if ($command eq "trim_audio") {
	$audio_start=$ARGV[2];
	$audio_end=$ARGV[3];
	$arate=$ARGV[4];
	$achans=$ARGV[5];
	$asamps=$ARGV[6];

	unless (&rc_get("conserve_space") eq "true") {
	    &backup_audio;
	}

	# $audio_from is the new clip
	$audio_from=&clip_audio($audio_start,$audio_end);
	unlink $audio_in;
	$where=$audio_start;
	$end=$audio_end-$audio_start;
	$start=0;
	# insert_audio will insert silence at start
	&insert_audio;
	unlink $audio_out;
	&append_silence(&align($audio_end*$arate*$align));

	&sig_complete;
	exit 0;
    }


    if ($command eq "delete_audio") {
	$start=$ARGV[2];
	$end=$ARGV[3];
	$arate=$ARGV[4];
	$achans=$ARGV[5];
	$asamps=$ARGV[6];

	&cut_audio;

	&sig_complete;
	exit 0;
    }

    if ($command eq "resample_audio") {
	$arate=$ARGV[2];
	$achans=$ARGV[3];
	$asamps=$ARGV[4];
	$asigned=$ARGV[5];
	$aendian=$ARGV[6];


	$nrate=$ARGV[7];
	$nchans=$ARGV[8];
	$nsamps=$ARGV[9];
	$nsigned=$ARGV[10];
	$nendian=$ARGV[11];
	$audio_in="$curtmpdir/audio.bak";
	$audio_out="$curtmpdir/audio";

	if (defined($ARGV[12])) {
	    $stretch=$ARGV[12];
	    $audio_in="$curtmpdir/audio.orig";
	}

	unlink $audio_in;
	rename $audio_out,$audio_in;
	`sync;sync;sync`;

	&resample_audio;

	if (&rc_get("conserve_space") eq "true" && (-s $audio_out)) {
	    unlink $audio_in;
	}

	&sig_complete;
	exit 0;
    }



    if ($command eq "get_window_id") {
	system("xwininfo > $curtmpdir/tmpinfo");

	system("grep \"Window id:\" $curtmpdir/tmpinfo > $curtmpdir/tmpinfo2");
	if (defined(open IN,"< $curtmpdir/tmpinfo2")) {
	    read IN,$win_id,128;
	    close IN;
	}
	@@wid=split(/ /,$win_id);
	$win_id=hex($wid[3]);
	chomp($win_id);

	system("grep \"Width:\" $curtmpdir/tmpinfo > $curtmpdir/tmpinfo2");
	if (defined(open IN,"< $curtmpdir/tmpinfo2")) {
	    read IN,$width,128;
	    close IN;
	}
	@@widths=split(/Width: /,$width);
	$width=$widths[1];
	chomp($width);

	system("grep \"Height:\" $curtmpdir/tmpinfo > $curtmpdir/tmpinfo2");
	if (defined(open IN,"< $curtmpdir/tmpinfo2")) {
	    read IN,$height,128;
	    close IN;
	}
	@@heights=split(/Height: /,$height);
	$height=$heights[1];
	chomp($height);

	system("grep \"Depth:\" $curtmpdir/tmpinfo > $curtmpdir/tmpinfo2");
	if (defined(open IN,"< $curtmpdir/tmpinfo2")) {
	    read IN,$bpp,128;
	    close IN;
	}
	@@bpps=split(/Depth: /,$bpp);
	$bpp=$bpps[1];
	chomp($bpp);

	unlink "$curtmpdir/tmpinfo";
	unlink "$curtmpdir/tmpinfo2";

	&sig_complete($win_id,$width,$height,$bpp);
	exit 0;
    }


    if ($command eq "fill_and_redo_frames") {
	# remove any gaps in the play images
	unlink "$curtmpdir/pause";
	$start=$ARGV[2];
	$end=$ARGV[3];
	$width=$ARGV[4];
	$height=$ARGV[5];
	$has_audio=0;
	$fps=$ARGV[6];
	$arate=$ARGV[7];
	$achans=$ARGV[8];
	$asamps=$ARGV[9];
	if ($achans>0) {
	    $has_audio=1;
	}

	$new_frames=&fill_and_redo_frames;
	
	if ($has_audio) {
	    $aud_end=($new_frames/$fps)*$achans*$arate*($asamps/8);
	    $audio_in="$curtmpdir/audio";
	    $audsize=-s $audio_in;
	    if ($audsize > $aud_end) {
		$audio_out=&clip_audio(0.,$new_frames/$fps);
		unlink $audio_in;
		rename $audio_out,$audio_in;
	    }
	    elsif ($audsize<$aud_end) {
		$audio_out="$curtmpdir/audio.bak";
		rename $audio_in,$audio_out;
		&append_silence($aud_end-$audsize,$audio_in);
		`cat $audio_out>>$audio_in`;
		unlink $audio_out;
	    }
	}

	&sig_complete($new_frames,$hsize,$vsize,$bpp);
	exit 0;
    }


    if ($command eq "commit_audio") {
	# commit the audio file in either audiodump or audiodump.wav as new audio file
	chdir $curtmpdir;
	$audio_out="audio";
	$audio_bak="audio.bak";

	my $gotit=0;

	$file=$audio_in="audiodump.wav";

	my $f_size=-s $audio_in;
	if ($f_size>0) {
	    # wav format
	    if (&rc_get("conserve_space") eq "true") {
		unlink $audio_out;
	    }
	    else {
		if (-f $audio_out) {
		    rename $audio_out,$audio_bak;
		}
		else {
		    `touch $audio_bak`;
		}
	    }
	    $is_audio=TRUE;
	    &get_file_info;
	    &convert_audio_to_raw;
	}
	else {
	    $audio_in="audiodump";
	    if (! -f $audio_in) {
		$audio_in="audiodump.pcm";
	    }
	    else {
		$gotit=1;
	    }
	    if ($gotit || -f $audio_in) {
		# raw format
		if (&rc_get("conserve_space") eq "true") {
		    unlink $audio_out;
		}
		else {
		    if (-f $audio_out) {
			rename $audio_out,$audio_bak;
		    }
		    else {
			`touch $audio_bak`;
		    }
		}
		rename $audio_in,$audio_out;
		# dummy values, the GUI should know these
		$arate=$achans=$asamps=0;
		$signed=$endian=1;
	    }
	    else {
		&sig_error("$GUI_NAME audio error.");
	    }
	}
	unlink <audiodump.*>;

	$f_size=-s $audio_out;
	&sig_complete($arate,$achans,$asamps,$signed,$endian,$f_size);
	exit 0;
    }

    if ($command eq "cancel_audio") {
	# remove the audio file in audiodump/audiodump.wav
	# plus any audio.new files (e.g. from append audio)

	chdir $curtmpdir;
	unlink <audiodump* audio.new>;

	&sig_complete;
	exit 0;
    }


    if ($command eq "cdopen") {

	$cdda2wav_command=&location("cdda2wav");
	if ($cdda2wav_command eq "") {
	    &sig_error("cdda2wav is required for this function.","Please install it first.");
	}

	$cdplay_device=&rc_get("cdplay_device");
	if ($cdplay_device eq "") {
	    &sig_error("You must set the CD device first in Preferences.");
	}

	$track=$ARGV[2];

	$audiofile=$curtmpdir."/audiodump.wav";
	if (-f $audiofile) {
	    unlink $audiofile;
	}

	system("$cdda2wav_command -q -x -D $cdplay_device -t $track $audiofile >/dev/null 2>&1");
	$f_size=-s $audiofile;
	# the '-x' option will force these
	$arate=44100;
	$achans=2;
	$asamps=16;
	$aendian=&get_endian;
	$asigned=1;
	if ($asamps==8) {
	    $asigned=0;
	}
	&sig_complete($arate,$achans,$asamps,$asigned,$aendian,$f_size);
	exit 0;
    }


    if ($command eq "audioopen") {
	# TODO - allow front end to specify rate/channels, etc.

	$file=$ARGV[2];
	$audio_in=$curtmpdir."/audiodump.wav";

	$ext=&get_ext($file);
	if ($ext eq ".mp3") {
	    &mp3_open;
	}
	elsif ($ext eq ".ogg") {
	    &ogg_open;
	}
	elsif ($ext eq ".wav") {
	    $audio_in=$curtmpdir."/audiodump.wav";
	    &wav_open;
	}
	else {
	    &othera_open;
	}

	&sig_complete($arate,$achans,$asamps,$asigned,$aendian,$f_size);
	exit 0;
    }

    if ($command eq "xmmsrandom") {
	#messy, but it should work for now
	# TODO - compile list of all audio files, then pick one at random
	$trackstoplay=$ARGV[2];
	$descend=$ARGV[3];
	$minmeg=$ARGV[4];
	$maxmeg=$ARGV[5];
	$origdir=$dir=$ARGV[6];
	$meg=1024*1024;

	$xmms_command=&location("xmms");
	unless ($xmms_command eq "") {
	    $first=1;
	    $tracks=0;
	    # give up if we tried 200 files and didn't get an audio file
	    $giveup=200;

	    do {
		opendir DIR,$dir;
		@@length=readdir(DIR);
		$count=scalar(@@length);
		closedir DIR;
		
		if ($count>0) {
		    $filetoplay=int(rand $count);
		    $file=$length[$filetoplay];

		    if ((-d "$dir$file")&&$descend==1) {
			unless ($file =~ /^\./) {
			    $dir="$dir$file/";
			}
		    }
		    elsif (-f "$dir$file") {
			$size=-s "$dir$file";
			if (($size>$minmeg*$meg)&&($size<$maxmeg*$meg)) {
			    $ext=&get_ext($file);
			    # TODO - add more extensions (and allow editing thru prefs...)
			    if (($ext eq ".mp3")||($ext eq ".ogg")||($ext=".mod")) {
				$tracks++;
				$giveup=200;
				if ($first==1) {
				    system("$xmms_command -p \"$dir$file\"");
				    $first=0;
				}
				else {
				    system("$xmms_command -p -e \"$dir$file\"");
				}
			    }
			}
			$dir=$origdir;
		    }
		}
		else {
		    $giveup=0;
		}
	    } while ($tracks<$trackstoplay&&($giveup--)>0);
	    if ($giveup<=0) {
		&sig_error("$GUI_NAME could not find enough tracks fitting your request.","Try again with different values.");
	    }
	}
	&sig_complete;
	exit 0;
    }


    if ($command eq "insert") {
	# with_audio == 2 means undo delete audio
	unlink "$curtmpdir/pause";

	$where=$ARGV[2];
	$start=$ARGV[3];
	$end=$ARGV[4];
	$from_handle=$ARGV[5];
	$with_audio=$ARGV[6];
	$num_frames=$ARGV[7];
	$width=$ARGV[8];
	$height=$ARGV[9];
	$times=1;
	$undo_cut=0;

	chdir $curtmpdir;

	if (defined ($ARGV[14])) {
	    $times=$ARGV[14];
	    if ($times<0) {
		# this indicates undoing a previous cut
		$times=-$times;
		$undo_cut=1;
		$num_frames+=$end-$start+1;
	    }
	    else {
		if ($start>=0) {
		    &clean_old;
		}
		else {
		    # $start < 0 tells us to leave backups alone
		    $start=-$start;
		}
		$antialias=&rc_get("antialias");
	    }
	}

	if ($with_audio<2) {
	    &insert;
	}
	else {
	    $audio_from="$curtmpdir/audio.bak";
	}

	if ($with_audio) {
	    $fps=$ARGV[10];
	    $arate=$ARGV[11];
	    $achans=$ARGV[12];
	    $asamps=$ARGV[13];

	    if ($undo_cut==0) {
		$end/=$fps;
		$start=($start-1.)/$fps;
		$where/=$fps;
		if (-f "audio") {
		    system("cp audio audio.bak");
		    `sync;sync;sync`;
		}
	    }
	    elsif ($with_audio<2) {
                $end=-s "audio.bak";
                $end/=$arate*$achans*$asamps/8;
                $start=0.;
                $where/=$fps;
	    }
	    &insert_audio;
	}

	if ($undo_cut==1) {
	    &clean_old;
	}

	&sig_complete;
	exit 0;
    }

	if ($command eq "undo_insert") {
	    #clean up after an interrupted insert
	    $start=$ARGV[2];
	    $end=$ARGV[3];
	    $frames=$ARGV[4];

	    # move extra frames back to end
	    `sync;sync;sync`;
	    &undo_insert;

	    $end=$frames;
	    &undo(1);
	    &undo_audio;
	    &sig_complete;
	    exit 0;
	}


    # effects

	if (substr($command,0,10) eq "pfxrender_") {
	    #fx preview
	    $fx_prev=1;
	    $command=substr($command,1);
	    $out_ext=".pre";
	}

	if (substr($command,0,9) eq "fxrender_") {

	    chdir $curtmpdir;
	    unlink "$curtmpdir/pause";
	    $command=substr($command,9);
	    $status=$ARGV[2];
	    $start=$ARGV[3];
	    $end=$ARGV[4];
	    $nwidth=$width=$ARGV[5];
	    $nheight=$height=$ARGV[6];
	    # call render plugins in plugins/effects/rendered/$command
	    $lib_dir=&rc_get("lib_dir");

	    unless (defined($fx_prev)) {
		$out_ext=".mgk";
		&clean_old;
	    }
	    if ($status==0) {
		$plugin_name="$command";
	    }
	    elsif ($status==1) {
		$plugin_name="$home/.lives-dir/plugins/effects/rendered/custom/$command";
	    }
	    else {
		$plugin_name="$home/.lives-dir/plugins/effects/rendered/test/$command";
	    }
	    $fx_desc=`$plugin_name get_description`;
	    $num_in_channels=(split(/\|/,$fx_desc))[3];
	    if ($num_in_channels==2) {
		# transitions get some extra params
		$start2=$ARGV[7];
		$clipboard=$ARGV[8];
	    }

	    if ($num_in_channels==0) {
		$out_ext=$img_ext;
	    }

	    $fps=0;

	    $fx_caps=`$plugin_name get_capabilities`;
	    if ($fx_caps&0x8000) {
		# is autogenerated
		# we are so nice :-), we set: 
		# $handle,$curtmpdir,$img_ext,$start,$end,$width,$height
		# and for transitions $where, $chandle
		# remove fxrender $handle $status start end width height
		shift; shift; shift; shift; shift; shift;
		if ($num_in_channels==2) {
		    shift; shift;
		}
		$ARGV[0]="process";
		if ($status>1) {
		    $error="";
		    unless (eval "require (\"$plugin_name\")") {
			$error=$@@;
		    }
		    unless ($error eq "") {
			&sig_error("$plugin_name failed:","$error");
		    }
		}
		else {
		    require("$plugin_name");
		}

		if ($num_in_channels>0) {
		    unless (defined($fx_prev)) {
			&mv_mgk;
		    }
		}
		else {
		    $frames=&count_frames;
		}
		&sig_complete($nwidth,$nheight,$fps,$frames);
		exit 0;
	    }
	    else {
		# other (non-perl) language
		shift; shift; shift; #remove "fxrender_.." and $handle $status
		my ($res_file)="$curtmpdir/.rfx_result";
		my ($err)=system "$plugin_name process \"$curtmpdir\" $img_ext $out_ext @@ARGV > $res_file";
		if (!$err) {
		    if (defined(open IN,"< $res_file")) {
			read IN,$size,128;
			($nwidth,$nheight)=split(" ",$size);
			close IN;
			unlink "$res_file";
		    }
		}
		else {
		    my (@@err)="";
		    if (defined(open IN,"< $res_file")) {
			read IN,$errt,512;
			@@err=split("\n",$errt);
			close IN;
			unlink "$res_file";
		    }
		    &sig_error(@@err);
		    exit 1;
		}
		unless (defined($fx_prev)) {
		    &mv_mgk;
		}
		&sig_complete($nwidth,$nheight);
		exit 0;
	    }
	}

	if ($command eq "import_project") {
	    $proj_file=$ARGV[2];
	    chdir $tmpdir;
	    umask 0;
	    `tar --no-same-owner -xzf \"$proj_file\"`;
	    &sig_complete;
	    exit 0;
	}

	if ($command eq "export_project") {
	    my $set=$ARGV[2];
	    my $proj_file=$ARGV[3];
	    chdir $tmpdir;
	    `tar --exclude=*.bak --exclude=.pid* --exclude .status* --exclude=lock.* --exclude=*.mgk --exclude=*.tmp --exclude=audioclip* -czf \"$proj_file\" $set`;
	    &sig_complete;
	    exit 0;
	}

	if ($command eq "bg_weed") {
	    my $bytes_cleaned=&weed;
	    &sig_complete($bytes_cleaned);
	    exit 0;
	}

	if (!caller) {
	    print STDERR "smogrify: unrecognised command $command\n";
	    exit 1;
	}
    }
    return 1;
    exit 99; # just in case
}






######################################################
    
#subroutines

sub usage {
    print STDERR "$command must have a parameter\n";
    print STDERR "show usage...\n";
}

sub mkname {
    my ($num)=shift;
    $ret=sprintf("%08d",$num);
    $ret;
}

sub check_for_pause {
    if (-f "$curtmpdir/pause") {
	`sync;sync;sync`;
    }
    while (-f "$curtmpdir/pause") {
	sleep 1;
    }
}


sub check_for_stop {
    if (defined(open IN,"< $curtmpdir/.status.fileop")) {
	close IN;
	return 1;
    }
    return 0;
}



sub get_pgid {
    #get process group for a given pid
    my $pgidstr=`cat /proc/$target_pid/stat`;
    my $pgid=(split(" ",$pgidstr))[4];
    return $pgid;
}

sub kill_child_pids {
    my $target_pid=shift;
    my $pid;
    `pgrep -P $target_pid > $tmpdir/.pids.$target_pid`;
    `kill -TERM $target_pid >/dev/null 2>&1`;
    if (-s "$tmpdir/.pids.$target_pid"&&defined(open IN,"$tmpdir/.pids.$target_pid")) {
	while (<IN>) {
	    $pid=$_;
	    chomp($pid);
	    &kill_child_pids($pid);
	}
	close IN;
    }
    unlink "$tmpdir/.pids.$target_pid";
}

sub is_writeable {
    # see if is writable or creatable
    # but do not actually create the file
    my $file=shift;
    if (! -s $nfile) {
	unlink $nfile;
    }
    $exists=(-f "$nfile");
    if (!$exists) {
	umask 0;
	system("touch \"$nfile\"; chmod o+w \"$nfile\"");
	umask $umask;
    }
    `sync;sync;sync`;
    $ret=(-w "$nfile");
    if (!$exists) {
	unlink "$nfile";
    `sync`;
    }
    return $ret;
}


sub mv_mgk {
    # pass in first param as 1 to show progress of frames
    # new files are .mgk files, back up old files to .bak

    my ($option)=shift;
    my ($i,$name);

    unless (!defined($statusfile)||$statusfile eq "") {
	# don't want to get killed in this stage...
	unlink $statusfile;
    }

    for ($i=$start;$i<=$end;$i++) {
	$name=&mkname($i);
	if (-f "$curtmpdir/$name.mgk") {
		if (-f "$curtmpdir/$name$img_ext") {
		    if ($leave_bak==1&&-f "$curtmpdir/$name.bak") {
			unlink "$curtmpdir/$name$img_ext";
		    }
		    else {
			rename "$curtmpdir/$name$img_ext","$curtmpdir/$name.bak";
		    }
		}
		rename "$curtmpdir/$name.mgk","$curtmpdir/$name$img_ext";
	    }
	if ($option==1) {
	    &sig_progress($i);
	}
    }
    `sync;sync;sync`;
}




sub mv_pre {
    # new files are .pre files, back up old files to .bak
    my ($i,$name);
    unless (!defined($statusfile)||$statusfile eq "") {
	# don't want to get killed in this stage...
	unlink $statusfile;
    }

    chdir $curtmpdir;
    unlink <*.mgk>;

    for ($i=$start;$i<=$end;$i++) {
	$name=&mkname($i);
	if (-f "$curtmpdir/$name.pre") {
	    if (-f "$curtmpdir/$name$img_ext") {
		unlink "$curtmpdir/$name.bak";
		rename "$curtmpdir/$name$img_ext","$curtmpdir/$name.bak";
	    }
	    rename "$curtmpdir/$name.pre","$curtmpdir/$name$img_ext";
	}
    }
    `sync;sync;sync`;
}


sub undo {
    # recover .bak files; if param==0 or undefined, move current files to .mgk files
    my ($param)=shift;
    if ($param eq "") {
	$param=0;
    }

    my ($i,$name);
    for ($i=$start;$i<=$end;$i++) {
	$name=&mkname($i);
	if (-f "$curtmpdir/$name.bak") {
	    if ($param==0) {
		rename "$curtmpdir/$name$img_ext","$curtmpdir/$name.mgk";
	    }
	    rename "$curtmpdir/$name.bak","$curtmpdir/$name$img_ext";
	}
	&sig_progress($i);
    }
}


sub undo_audio {
    if (-f "$curtmpdir/audio.orig") {
	unlink "$curtmpdir/audio";
	rename "$curtmpdir/audio.orig","$curtmpdir/audio";
	unlink "$curtmpdir/audio.bak";
    }
    else {
	unlink "$curtmpdir/audio.new";
	rename "$curtmpdir/audio","$curtmpdir/audio.new";
	rename "$curtmpdir/audio.bak","$curtmpdir/audio";
	rename "$curtmpdir/audio.new","$curtmpdir/audio.bak";
    }
}



sub backup_audio {
    &clean_old;
    `/bin/cp $curtmpdir/audio $curtmpdir/audio.bak >/dev/null 2>&1`;
}


sub cut {
    my ($start,$end)=@@_;
    my ($i,$name);
    chdir $curtmpdir;
    $frames_cut=$end-$start+1;

    for ($i=$start;$i<=$end;$i++) {
	$name=&mkname($i);
	rename "$name$img_ext","$name.bak";
	&sig_progress($i);
    }

    for ($i=$end+1;$i<=$frames;$i++) {
	$from=&mkname($i);
	$to=&mkname($i-$frames_cut);
	rename $curtmpdir."/".$from.$img_ext,$curtmpdir."/".$to.$img_ext;
	&sig_progress($i);
    }
}




sub reverse {
    for ($i=$start;$i<int(($start+$end)/2+.5);$i++) {
	$from=&mkname($i);
	$to=&mkname($end-$i+1);
	rename $curtmpdir."/".$from.$img_ext,$curtmpdir."/.revtemp";
	rename $curtmpdir."/".$to.$img_ext,$curtmpdir."/".$from.$img_ext;
	&sig_progress($start+($i-$start)*2);
	rename $curtmpdir."/.revtemp",$curtmpdir."/".$to.$img_ext;
	&sig_progress($start+($i-$start)*2+1);
    }
}



sub undo_insert {
    $frames_inserted=$end-$start+1;

    for ($i=$frames+$frames_inserted;$i>$frames;$i--) {
	# move any shifted frames back
	$name=&mkname($i);
	$to=&mkname($i-$frames_inserted);
	if (-f "$curtmpdir/$name$img_ext") {
	    unlink "$curtmpdir/$to$img_ext";
	    rename "$curtmpdir/$name$img_ext","$curtmpdir/$to$img_ext";
	}
    }
}




sub insert {
    my ($from,$to,$frames_to_move);
    $times_inserted=0;
    $factor=1;

    my ($nend)=$end;
    my ($nstart)=$start;
    my ($nwhere)=$where;
    my ($nfromdir)=$fromdir;

    if (!defined($times)) {
	$times=1;
    }
    if (!defined($undo_cut)) {
	$undo_cut=0;
    }

    $fromdir="$tmpdir/$from_handle";
    $frames_to_move=($nend-$nstart+1)*$times;

    # make space for new frames
    for ($i=$num_frames;$i>$nwhere;$i--) {
	$from=&mkname($i);
	$to=&mkname($i+$frames_to_move);
	if ($i<=($num_frames-$frames_to_move)&&!$undo_cut&&-f "$curtmpdir/$from$img_ext") {
	    # this frame will get overwritten, so back it up
	    system("/bin/cp $curtmpdir/$from$img_ext $curtmpdir/$from.bak");
	}
	rename "$curtmpdir/$from$img_ext","$curtmpdir/$to$img_ext";
	&sig_progress($num_frames-$i);
    }

    $resize_ext=$img_ext;

    #move from $from_handle
    $j=$start;
    while ($times_inserted<$times) {
	for ($i=$nstart;$i<=$nend;$i++) {
	    $from=&mkname($i);
	    $to=&mkname($nwhere+$i-$nstart+1);

	    if ($undo_cut==1) {
		system("/bin/cp $fromdir/$from.bak $curtmpdir/$to$img_ext 2>/dev/null");
	    }
	    else {
		while (! -f "$fromdir/$from$img_ext") {
		    print STDERR "waiting on image $fromdir/$from$img_ext\n";
		    sleep 1;
		    `sync`;
		}
		system("/bin/cp $fromdir/$from$img_ext $curtmpdir/$to$img_ext");
	    }
	    
	    if ($height && $width && !($fromdir eq $curtmpdir)) {
		&resize_frame($to,$width,$height);
	    }
	    &sig_progress(int($num_frames-$where+$j++-$start+1));
	}

	$times_inserted+=$factor;
	$inserted=$nend-$nstart+1;

	if ($times_inserted==2) {
	    $nend=$nwhere;
	    $nstart=$nwhere-$inserted+1;
	    $fromdir=$curtmpdir;
	}
	$nwhere+=$inserted;

	if ($times_inserted>1) {
	    $nend+=$inserted;
	    $factor*=2;
	}
	while ($times>$times_inserted&&$factor>$times-$times_inserted) {
	    $nstart+=($nend-$nstart+1)/2;
	    $factor/=2;
	}
    }
}



sub resize_frame {
    my ($name,$width,$height)=@@_;

    if (!defined($input_ext)) {
	$input_ext=$img_ext;
    }
    if (!defined($antialias)) {
	$antialias="false";
    }

    if ($antialias eq "false") {
	system("$convert_command +antialias -size $width"."x$height $name$input_ext -scale $width!x$height! $name$resize_ext >/dev/null 2>&1");
    }
    else {
	system("$convert_command -size $width"."x$height $name$input_ext -resize $width!x$height! $name$resize_ext >/dev/null 2>&1");
    }
}


sub zoom_frame {
    my ($name,$centre_x,$centre_y,$width,$height,$rscale)=@@_;
    # zoom into a frame

    # first we will crop the frame to just slightly larger than
    # our target, then we will resize, then do an exact crop
    
    # TODO - if we expand an edge a lot, our final crop needs
    # adjusting

    if (!defined($antialias)) {
	$antialias="false";
    }
    if (!defined($input_ext)) {
	$input_ext=$img_ext;
    }
    
    my ($left)=int($centre_x-($width/(2.*$rscale)))-1;
    my ($top)=int($centre_y-($height/(2.*$rscale)))-1;
    my ($right)=int($centre_x+($width/(2.*$rscale)))+1;
    my ($bottom)=int($centre_y+($height/(2.*$rscale)))+1;
    
    if ($left<0) {
	$right-=$left;
	$left=0;
    }
    if ($top<0) {
	$bottom-=$top;
	$top=0;
    }
    if ($right>=$width) {
	$left-=$right-$width+1;
	if($left<0) {
	    $left=0;
	}
	$right=$width-1;
    }
    if ($bottom>=$height) {
	$top-=$bottom-$height+1;
	if($top<0) {
	    $top=0;
	}
	$bottom=$height-1;
    }
    my ($nwidth)=$right-$left+1;
    my ($nheight)=$bottom-$top+1;
    
    if ($antialias eq "false") {
	system("$convert_command -antialias -size $width"."x$height $name$input_ext -crop $nwidth!x$nheight!+$left!+$top! -resize $width!x$height! $name$resize_ext >/dev/null 2>&1");
    }
    else {
	system("$convert_command +antialias -size $width"."x$height $name$input_ext -crop $nwidth!x$nheight!+$left!+$top! -resize $width!x$height! $name$resize_ext >/dev/null 2>&1");
    }
    
}





sub trim_frame {
    my ($name,$width,$height,$x,$y,$nwidth,$nheight)=@@_;

    if (!defined($input_ext)) {
	$input_ext=$img_ext;
    }
    if (!defined($antialias)) {
	$antialias="false";
    }
    if ($antialias eq "false") {
	system("$convert_command +antialias -size $width"."x$height $name$input_ext -crop $nwidth!x$nheight!+$x+$y $name$resize_ext >/dev/null 2>&1");
    }
    else {
	system("$convert_command -antialias -size $width"."x$height $name$input_ext -crop $nwidth!x$nheight!+$x+$y $name$resize_ext >/dev/null 2>&1");
    }
}

sub trim_center {
    my ($name,$width,$height)=@@_;

    if (!defined($input_ext)) {
	$input_ext=$img_ext;
    }

    $imresact="none";
    &get_image_size("$name$input_ext");

    unless ($hsize>=$width&&$vsize>=$height) {
	#composite over a large enough frame
	$size=$hsize;
	if ($vsize>$size) {
	    $size=$vsize;
	}

	$xstart=int(($size-$hsize)/2);
	$ystart=int(($size-$vsize)/2);

	# make a background frame
	if (!defined($bgcolour)) {
	    $bgcolour="#000000";
	}

	system("$convert_command -size $size!x$size! xc:$bgcolour blank.jpg >/dev/null 2>&1");
	system("$composite_command -compose plus -dissolve 100 -geometry $hsize!x$vsize!+$xstart!+$ystart! $name$input_ext blank.jpg $name$input_ext >/dev/null 2>&1");
	$hsize=$vsize=$size;
    }

    $x=int(($hsize-$width)/2);
    $y=int(($vsize-$height)/2);

    system("$convert_command $name$input_ext -crop $width" . "!x" . $height . "!+" . $x . "+" . $y . " $name$resize_ext >/dev/null 2>&1");

}


sub get_ext {
    # return the extension of a file (including the '.')
    my ($file)=shift;
    return substr($file,-4);
}



sub get_formats {
    if ($asamps==8){
	$format=16;
	$signed=0;
	$xsigned="-u";
    }
    else {
	$signed=1;
	$xsigned="-s";
	if ($endian==1) {
	    # little
	    $format=128;
	}
	else {
	    # big
	    $format=256;
	}
    }
}




sub get_file_info {
    $af_size=0;
    $count=0;
    $bpp=24;  # default if none is found
    $fps=0; # let the front-end handle this if we can't get it ;-)
    $type="Unknown";
    $hsize=0;
    $vsize=0;
    $signed=-1;
    $f_size=0;
    $arate=$asamps=$achans=0;
    $frames=0;
    $asamps=0;

    # try to force language to English
    $mplay_command="LANGUAGE=en LANG=en ";

    $mplay_command.=&rc_get("video_open_command");
    $file_ident="$curtmpdir/file_info";

    $id_vid_form="";

    if ($is_audio) {
	$type="Audio";
    }

    # if mplayer supports the -identify command, use that
    # the format changed for 1.0pre1 so now we use -vo null -ao null -frames 0

    unless ($mplay_command eq "") {
    if (defined($is_remote)&&($is_remote>0)) {
	# remote files might be streams, so we need to cache a bit before we can identify them
	system("$mplay_command -identify -vo null -ao null -frames 0 -cache 32 \"$file\">$file_ident 2>/dev/null </dev/null");
    }
    else {
	system("$mplay_command -identify -vo null -ao null -frames 0 \"$file\">$file_ident 2>/dev/null </dev/null");
    }

    if (-f $file_ident) {
        $id_vid_form=`grep ID_VIDEO_CODEC $file_ident 2>/dev/null`;
        $id_vid_form=(split("=",(split("\n",$id_vid_form))[0]))[1];
        chomp($id_vid_form);

	if ($id_vid_form eq "") {
	    $id_vid_form=`grep ID_VIDEO_FORMAT $file_ident 2>/dev/null`;
	    $id_vid_form=(split("=",(split("\n",$id_vid_form))[0]))[1];
	    chomp($id_vid_form);
	}

	if ($id_vid_form eq "") {
	    $id_vid_form=`grep VIDEO: $file_ident 2>/dev/null`;
	    $id_vid_form=(split("  ",(split("\n",$id_vid_form))[0]))[1];
	    chomp($id_vid_form);
	}
	if (! -f $file_ident) {return;};

	$id_aud_form=`grep ID_AUDIO_FORMAT $file_ident 2>/dev/null`;
	$id_aud_form=(split("=",(split("\n",$id_aud_form))[0]))[1];
	chomp($id_aud_form);

	if ($id_aud_form eq "") {
	    $id_aud_form=`grep AUDIO: $file_ident 2>/dev/null`;
	    $id_aud_form=(split("  ",(split("\n",$id_aud_form))[0]))[1];
	    chomp($id_aud_form);
	}

	if (! -f $file_ident) {return;};

	if ($id_vid_form eq "") {
	    if (!($id_aud_form eq "")) {
		$id_vid_form="Audio";
	    }
	}

	unless ($id_vid_form eq "") {
	    # this could probably be done better using regexp...
	    $type=$id_vid_form;

	    if (! -f $file_ident) {return;};
	    $asamps=`grep AUDIO: $file_ident 2>/dev/null`;
	    $asamps=(split(" ",$asamps))[5];
	    chomp($asamps);

	    if ($asamps =~ /^s/) {
		$asamps=substr($asamps,1,-1);
		$signed=1;
	    }
	    if ($asamps =~ /^u/) {
		$asamps=substr($asamps,1,-1);
		$signed=0;
	    }

	    if (! -f $file_ident) {return;};
	    $bpp=`grep VIDEO: $file_ident 2>/dev/null`;
	    $bpp=(split("bpp",(split("  ",$bpp))[3]))[0];
	    chomp($bpp);

	    if (! -f $file_ident) {return;};
	    if ($bpp eq "") {
		$bpp=`grep \"Image size:\" $file_ident 2>/dev/null`;
		@@tmp=split(" ",$bpp);
		$bpp=substr($tmp[5],1,2);
	    }

	    if (! -f $file_ident) {return;};
	    $hsize=`grep ID_VIDEO_WIDTH $file_ident 2>/dev/null`;
	    $hsize=(split("=",(split("\n",$hsize))[0]))[1];
	    chomp($hsize);
	    
	    if (! -f $file_ident) {return;};
	    $vsize=`grep ID_VIDEO_HEIGHT $file_ident 2>/dev/null`;
	    $vsize=(split("=",(split("\n",$vsize))[0]))[1];
	    chomp($vsize);
	    
	    if (! -f $file_ident) {return;};
	    $fps=`grep ID_VIDEO_FPS $file_ident 2>/dev/null`;
	    $fps=(split("=",(split("\n",$fps))[0]))[1];
	    chomp($fps);

	    if (! -f $file_ident) {return;};
	    $arate=`grep ID_AUDIO_RATE $file_ident 2>/dev/null`;
	    my @@results=split("\n",$arate);
	    foreach my $val (@@results) {
		$arate=(split("=",$val))[1];
		chomp($arate);
		last if $arate>0;
	    }
	    if (! -f $file_ident) {return;};
	    if ($arate==0) {
		$arate=`grep Samplerate $file_ident 2>/dev/null`;
		$arate=(split(": ",(split("\n",$arate))[0]))[1];
		chomp($arate);
	    }

	    
	    if (! -f $file_ident) {return;};
	    $achans=`grep ID_AUDIO_NCH $file_ident 2>/dev/null`;
	    chomp($achans);
	    $achans=(split("\n",$achans))[-1];
	    $achans=(split("=",(split("\n",$achans))[0]))[1];

	    if (! -f $file_ident) {return;};
	    $abitrate=`grep ID_AUDIO_BITRATE $file_ident 2>/dev/null`;
	    chomp($abitrate);
	    $abitrate=(split("\n",$abitrate))[-1];
	    $abitrate=(split("=",(split("\n",$abitrate))[0]))[1];


	    unless ($id_aud_form eq "" || $achans>0) {
		# need to look deeper for $achans
		$adets=`grep AO: $file_ident 2>/dev/null`;

		$adets=(split("AO: ",$adets))[1];
		chomp($adets);

		$arate=(split(" ",$adets))[1];
		if ($arate eq "[oss]") {
		    $arate=(split(" ",$adets))[2];
		    $achans=(split(" ",$adets))[3];

		}
		else {
		    $achans=(split(" ",$adets))[2];
		}
		chomp($arate);
		chomp($achans);

		$arate=$arate*1;
		$achans=$achans*1;
	    }

	    if (! -f $file_ident) {return;};
	    $comment=`grep Comments: $file_ident 2>/dev/null`;
	    @@tmp=split(" ",$comment);
	    shift(@@tmp);
	    $comment=join(" ",@@tmp);
	    chomp($comment);

	    if (! -f $file_ident) {return;};
	    $title=`grep Title: $file_ident 2>/dev/null`;
	    @@tmp=split(" ",$title);
	    shift(@@tmp);
	    $title=join(" ",@@tmp);
	    chomp($title);

	    if (! -f $file_ident) {return;};
	    $title=`grep Author: $file_ident 2>/dev/null`;
	    @@tmp=split(" ",$author);
	    shift(@@tmp);
	    $author=join(" ",@@tmp);
	    chomp($author);

	    if (! -f $file_ident) {return;};
	    $count=`grep \"frames  total\" $file_ident 2>/dev/null`;
	    @@tmp=split(" ",$count);
	    $count=$tmp[2];
	    chomp($count);

            if ($count eq "") {
                $length=`grep ID_LENGTH $file_ident 2>/dev/null`;
                $length=(split("=",(split("\n",$length))[0]))[1];
                chomp($length);
                $count=int($fps*$length+.5);
            }
            if ($count eq "") {
                $count=1000000; #take a guess...
            }
	}
	if ($asamps==0&&$arate*$achans>0) {
	    $asamps=$abitrate/$arate/$achans;
	}
	unlink $file_ident;
    }
   }


    if (($hsize*$vsize==0||$count eq "")&&!($type eq "Audio")) {
	$name=&mkname(1);
	unless (-f "$curtmpdir/$name") {
	    # see if it is image(s)
	    &open_images(1);
	    opendir DIR,$curtmpdir;
	    while ($file2=readdir(DIR)) {
		if ($file2 =~ /$img_ext$/) {
		    $count++;
		    $imresact="none";
		    if ($only_first) {
			unlink <$curtmpdir/*$img_ext>;
			last;
		    }
		    else {
			$f_size+=-s $file2;
		    }
		}
		else {
		    unless ($file2 eq $audio_in) {
			unlink $file2;
		    }
		}
	    }
	    closedir DIR;

	    if ($count) {
		# got image(s)
		$frames=$count;
		# got image(s)
		if ($img_ext eq ".jpg") {
		    $type="jpeg";
		}
		else {
		    $type="png";
		}
		
		$count=0;
		$name=&mkname(1);
	    }
	}
    }

    if ($signed==-1) {
	if ($asamps==8) {
	    $signed=0;
	}
	else {
	    $signed=1;
	}
    }

    $endian=&get_endian; # assume audio endian matches machine endian

    # get file size
    if ($f_size==0) {
	$f_size= -s $file;
    }

    if ($asamps<5&&$asamps>0) {
	$asamps=16;
    }
    
    if ($type=~ m/^\[/) {
	$type=substr($type,1,-1);
    }

}





sub convert_audio_to_raw {
    &get_formats;
    if (!(&rc_get("audio_player") eq "mplayer")) {
	system("sox -t .wav $audio_in -t .raw $xsigned $audio_out > /dev/null 2>&1");
    }
    else {
	$format=&get_mplayer_format;
	system(&rc_get("video_open_command") . " -quiet $audio_in -ao pcm:nowaveheader:file=$audio_out $format >/dev/null 2>&1");
    }

    `sync;sync;sync`;
}


sub convert_audio_to_wav {
    #WARNING - $asamps and $nasamps are in bits
    my ($aasamps)=$asamps/8;

    chdir $curtmpdir;
    if (&rc_get("audio_player") eq "mplayer") {
	$format=&get_mplayer_format;
	system(&rc_get("video_open_command") . " -quiet -ao pcm -demuxer rawaudio -rawaudio rate=$arate:channels=$achans:samplesize=$aasamps -ao pcm:waveheader $format -vo null $audio_in >/dev/null 2>&1 </dev/null");
    }
    else {

	if (!defined($sox_version)) {
	    $sox_version=&get_sox_version;
	}

	if ($sox_version<13) {
	    if ($asamps==8) {
		$sasamps="b";
	    }
	    else {
		$sasamps="w";
	    }
	}
	else {
	    $sasamps=$aasamps;
	}


	if (!defined($nrate)) {
	    $nrate=$arate;
	}

	if (!defined($nchans)) {
	    $nchans=$achans;
	}

	if (!defined($nasamps)) {
	    $nasamps=$sasamps;
	}

	if (!defined($asigned)) {
	    if ($sasamps==8) {
		$asigned="-u";
	    }
	    else {
		$asigned="-s";
	    }
	}

	if (!defined($nsigned)) {
	    if ($nasamps==8) {
		$nsigned="-u";
	    }
	    else {
		$nsigned=$asigned;
	    }
	}

	if (!defined($nendian)) {
	    $nendian=$aendian;
	}
	system("sox -t .raw -r $arate $asigned -$sasamps -c $achans $aendian $audio_in -t .wav -r $nrate -c $nchans $nsigned -$nasamps $nendian $curtmpdir/audiodump.wav >/dev/null 2>&1");
    }

    `sync;sync;sync`;
}





#clip (actually, trim) the audio from $start seconds to $end seconds
sub clip_audio {
    my ($start,$end)=@@_;

    if ($achans==0) {
	return;
    }

    $audio_in=$curtmpdir."/audio";
    $audio_out=$curtmpdir."/audioclip";

    unlink $audio_out;
    `touch $audio_out; chmod 600 $audio_out`;

    $align=$achans*$asamps/8;

    $spos=&align($arate*$align*$start);
    $epos=&align($arate*$align*$end);

    my ($fsize)= (-s $audio_in);

    if ($epos>$fsize) {
	$epos=$fsize;
    }
    if ($spos>$epos) {
	$spos=$epos;
    }

    my ($size)=($epos-$spos);

    if ($size>0) {
	$fblocks=int($size/32);
	$rblocks=$size-($fblocks*32);
	unlink $audio_out;
	system("dd if=$audio_in of=$audio_out bs=32 count=$fblocks skip=".int($spos/32)." >/dev/null 2>&1");
	system("dd if=$audio_in of=$audio_out bs=1 count=$rblocks skip=".($spos+$fblocks*32)." seek=".($fblocks*32)." >/dev/null 2>&1");
    }

    `sync;sync;sync`;
    $audio_out;
}


sub resample_audio {
    #WARNING - $asamps and $nasamps are in bits

    $endian=&get_endian;

    if (!defined($sox_version)) {
	$sox_version=&get_sox_version;
    }
    
    if ($sox_version<13) {
	if ($asamps==8) {
	    $osamps="b";
	}
	else {
	    $osamps="w";
	}
	
	
	if ($nsamps==8) {
	    $nsamps="b";
	}
	else {
	    $nsamps="w";
	}
    }
    else {
	$osamps=$asamps/8;
	$nsamps/=8;
    }
    
    if ($asigned==1) {
	$osigned="s";
    }
    else {
	$osigned="u";
    }
    
    if ($nsigned==1) {
	$nsigned="s";
    }
    else {
	$nsigned="u";
    }
    
    if ($aendian==$endian) {
	$oendian="";
    }
    else {
	$oendian="-x";
    }
    
    if ($nendian==$endian) {
	$nendian="";
    }
    else {
	$nendian="-x";
    }
    
    if (defined($stretch)) {
	system("sox -t .raw -r $arate -c $achans -$osigned -$osamps $oendian $audio_in -t .raw -r $nrate -c $nchans -$nsigned $nendian -$nsamps $audio_out stretch $stretch>/dev/null 2>&1");
    }
    else {
	system("sox -t .raw -r $arate -c $achans -$osigned -$osamps $oendian $audio_in -t .raw -r $nrate -c $nchans -$nsigned $nendian -$nsamps $audio_out>/dev/null 2>&1");
    }
}




sub insert_audio {
#what we are going to do:
# 1) copy the end of the audio (after insertion) to a new file
# 2) then insert the new section
# 3) then put the end back

#input params:
# $where - insertion pt -in seconds
# $start, $end - new section - in seconds
# $from_handle - handle of from file

    #if $arate<0, we will insert silence


    if ($achans==0) {
	return;
    }

    if (!defined($times)) {
	$times=1;
    }

    my ($audio_from)=$audio_from;

    my ($audio_to)="$curtmpdir/audio";
    if (defined($from_handle)) {
	if ($undo_cut>0) {
	    $audio_from="$tmpdir/$from_handle/audio.bak";
	}
	else {
	    $audio_from="$tmpdir/$from_handle/audio";
	}
    }
    my ($audio_temp)="$curtmpdir/audio.temp";

    unlink $audio_temp;
    `touch $audio_temp; chmod 600 $audio_temp`;

    $silence=0;
    if ($arate<0) {
	$silence=1;
	$arate=-$arate;
	$audio_from="/dev/zero";
    }

    $align=$achans*$asamps/8;

    $spos=&align($arate*$align*$start);
    $oepos=$epos=&align($arate*$align*$end);
    $wpos=&align($arate*$align*$where);

    if ($silence==0) {
	$fsize=&align(-s $audio_from);
	if ($epos>$fsize) {
	    $epos=$fsize;
	}
	if ($spos>$epos) {
	    $spos=$epos;
	}
    }

    # step 1 - move end to temp
    $fsize=-s $audio_to;

    my ($size)=$fsize-$wpos;
    if ($size>0) {
	$fblocks=int($size/32);
	$rblocks=$size-($fblocks*32);
	system("dd if=$audio_to of=$audio_temp bs=32 count=$fblocks skip=".int($wpos/32)." >/dev/null 2>&1");
	system("dd if=$audio_to of=$audio_temp bs=1 count=$rblocks skip=".($wpos+$fblocks*32)." seek=".($fblocks*32)." >/dev/null 2>&1");
    }

    # step 2 - insert new section (possibly multiple times)


    # pad with silence to insertion point
    &append_silence($wpos);

####################################################

    my ($nepos)=$epos;
    my ($nspos)=$spos;
    my ($nwpos)=$wpos;

    $times_inserted=0;
    $factor=1;
    $silence_remembered=0;

    my ($xaudio_from)=$audio_from;

    while ($times_inserted<$times) {
	$size=$nepos-$nspos;
	if ($size>0) {
	    $fblocks=int($size/32);
	    $rblocks=$size-($fblocks*32);
	    system("dd if=$xaudio_from of=$audio_to bs=32 count=$fblocks skip=".int($nspos/32)." seek=".int($nwpos/32)." >/dev/null 2>&1");
	    system("dd if=$xaudio_from of=$audio_to bs=1 count=$rblocks skip=".($nspos+$fblocks*32)." seek=".($nwpos+$fblocks*32)." >/dev/null 2>&1");
	}
	
	$times_inserted+=$factor;
	# pad with silence if necessary
	if (-s $audio_temp||$times_inserted<$times) {
	    $inserted=$oepos-$nspos;
	    &append_silence($nwpos+$inserted);
	    unless ($silence_remembered>0) {
		$silence_remembered=$oepos-$nepos;
	    }
	}
	else {
	    $inserted=$nepos-$nspos;
	}

	if ($times_inserted==2) {
	    $oepos=$nepos=$nwpos;
	    $nspos=$nwpos-$inserted;
	    $xaudio_from=$audio_to;
	}

	$nwpos+=$inserted;

	if ($times_inserted>1) {
	    $nepos+=$inserted;
	    $oepos+=$inserted;
	    $factor*=2;
	}
	while ($times>$times_inserted&&$factor>$times-$times_inserted) {
	    $nspos+=($oepos-$nspos)/2;
	    $factor/=2;
	}
	if ($factor+$times_inserted==$times) {
	    # this will be our last insertion...
	    if (-s $audio_temp==0) {
		$nepos-=$silence_remembered;
	    }
	}
    }


####################################################

    #step 3 - copy end back after insertion
    $size=&align(-s $audio_temp);
    if ($size>0) {
	$fblocks=int($size/32);
	$rblocks=$size-($fblocks*32);
	system("dd if=$audio_temp of=$audio_to bs=32 count=$fblocks seek=".int(($nwpos)/32)." >/dev/null 2>&1");
	system("dd if=$audio_temp of=$audio_to bs=1 count=$rblocks skip=".($fblocks*32)." seek=".($nwpos+$fblocks*32)." >/dev/null 2>&1");
    }

    unlink $audio_temp;
    `sync;sync;sync`;
}



sub cut_audio {
#what we are going to do:
    #1) copy up to $start to a new file
    #2) back up the section to be deleted
    #3) append the section after $end to the new file
    #4) copy the new file to the original
    #$start, $end are in seconds

    if ($achans==0) {
	return;
    }

    my ($audio_in)="$curtmpdir/audio";
    my ($audio_temp)="$curtmpdir/audio.temp";
    my ($audio_bak)="$curtmpdir/audio.bak";

    unlink $audio_temp;
    unlink $audio_bak;

    if ($end==0.) {
	rename ($audio_in,$audio_bak);
    }
    else {
	`touch $audio_temp; chmod 600 $audio_temp`;
	
	$align=$achans*$asamps/8;
	
	# step 1
	$spos=&align($arate*$align*$start);
	$epos=&align($arate*$align*$end);
	
	my ($fsize)=&align(-s $audio_in);
	
	if ($epos>$fsize) {
	    $epos=$fsize;
	}
	if ($spos>$epos) {
	    $spos=$epos;
	}
	
	$seekstart=$spos;
	my ($size)=$spos;
	
	if ($size>0) {
	    $fblocks=int($size/32);
	    $rblocks=$size-($fblocks*32);
	    system("dd if=$audio_in of=$audio_temp bs=32 count=$fblocks >/dev/null 2>&1");
	    system("dd if=$audio_in of=$audio_temp bs=1 count=$rblocks skip=".($fblocks*32)." seek=".($fblocks*32)." >/dev/null 2>&1");
	}
	
	#step 2
	$size=($epos-$spos);
	
	if ($size>0) {
	    $fblocks=int($size/32);
	    $rblocks=$size-($fblocks*32);
	    system("dd if=$audio_in of=$audio_bak bs=32 skip=".int($spos/32)." count=$fblocks >/dev/null 2>&1");
	    system("dd if=$audio_in of=$audio_bak bs=1 count=$rblocks skip=".($spos+$fblocks*32)." seek=".($fblocks*32)." >/dev/null 2>&1");
	}
	
	
	#step 3
	$spos=$epos;
	$epos=$fsize;
	$size=($epos-$spos);
	
	if ($size>0) {
	    $fblocks=int($size/32);
	    $rblocks=$size-($fblocks*32);
	    system("dd if=$audio_in of=$audio_temp bs=32 count=$fblocks skip=".int($spos/32)." seek=".int($seekstart/32)." >/dev/null 2>&1");
	    system("dd if=$audio_in of=$audio_temp bs=1 count=$rblocks skip=".($spos+$fblocks*32)." seek=".($seekstart+$fblocks*32)." >/dev/null 2>&1");
	}
	
	# step 4
	unlink $audio_in;
	rename "$audio_temp", "$audio_in";
    }
    `sync;sync;sync`;

}


sub align {
    my ($guess)=shift;
    # align our audio cuts so we don't end halfway through a sample/channel
    if (!defined($align)) {
	$align=$achans*$asamps/8;
    }
    $guess=int($guess/$align+.5)*$align;
    return $guess;
}


sub append_silence {
    #pad from end of file to byte $end-1 with zeros
    my ($end,$audio_file)=@@_;
    if ($audio_file eq "") {
	$audio_file="$curtmpdir/audio";
    }

    unless (-f $audio_file) {
	`touch $audio_file; chmod 600 $audio_file`;
    }

    my ($fsize)= -s $audio_file;
    $size=&align($end-$fsize);
    
    if ($size>0) {
	$fblocks=int($size/32);
	$rblocks=$size-($fblocks*32);
	system("dd if=/dev/zero of=$audio_file bs=32 count=$fblocks seek=".int($fsize/32)." >/dev/null 2>&1");
	system("dd if=/dev/zero of=$audio_file bs=1 count=$rblocks seek=".($fsize+$fblocks*32)." >/dev/null 2>&1");
    }
}





sub open_images {
    # set $file before calling this function
    # set $only_first to 1 to just open the first image in a directory
    # set $height $width to force a particular size, otherwise $height=$width=0 to open all to the first image size
    # if first image size cannot be obtained $dwidth and $dheight are used

    my ($i)=shift;
    my $orig=$i;

    if (-d $file) {
	# is a directory

	$dir=$file;
	opendir DIR,$dir;
	my @@files=readdir(DIR);
	closedir DIR;

	unless ($only_first) {
	    # open in numeric order
	    @@files = sort {$a <=> $b} (@@files);
	    if (!defined($antialias)) {
		$antialias=&rc_get("antialias");
	    }
	}

	foreach (@@files) {
	    unless ($_ =~ /^\./||(-d $_)) {
		$file="$dir/$_";
		$nframes=&open_single_image($i);
		if (-s "$curtmpdir/$name$img_ext") {
		    if ($only_first) {
			$i++;
			last;
		    }
		    else {
			$i+=$nframes;
		    }
		}
		else {
		    unlink "$curtmpdir/$name$img_ext";
		}
	    }
	}
    }
    else {
	&open_single_image($i);
	unless (-s "$curtmpdir/$name$img_ext") {
	    unlink "$curtmpdir/$name$img_ext";
	}
    }
    return $i-$orig;
}


sub open_single_image {
    # set $hsize and $vsize to force the image size, set to 0 to autoresize
    #identify hangs if the file extension is ".avi" or ".mp4" or ".mpg"

    my $i=shift;
    my $j;
    $name=&mkname($i);
    my $nframes=0;

    if (!defined($file_ext)) {
	$file_ext=&get_ext($file);
    }

    # TODO - return for any streams (anything with a :// in)

    if ($file_ext eq ".avi"||$file_ext eq ".mp4"||$file_ext eq ".mpg"||$file_ext eq ".ogg") {
	# need to set $name before we return
	return 0;
    }

    if ($hsize*$vsize==0) {
	&get_image_size($file);
    }

    `sync;sync;sync`;

    if ($antialias eq "false") {
	system("$convert_command +antialias \"$file\" -scale $hsize"."!x"."$vsize! $curtmpdir/$name$img_ext > /dev/null 2>&1");
    }
    else {
	system("$convert_command \"$file\" -resize $hsize"."!x"."$vsize! $curtmpdir/$name$img_ext >/dev/null 2>&1");
    }

    #convert gives multiple frames for e.g. animated gif
    $found=1;
    for ($j=0;$found==1;$j++) {
	if (-f "$curtmpdir/$name-$j$img_ext") {
	    $newname=&mkname($i+$j);
	    rename "$curtmpdir/$name-$j$img_ext","$curtmpdir/$newname$img_ext";
	    $nframes++;

	}
	else {
	    $found=0;
	}
    }

    if ($hsize*$vsize==0) {
	&get_image_size("$curtmpdir/$name$img_ext");
    }

    if ($hsize*$vsize>0&&$nframes==0) {
	$nframes=1;
    }

    return $nframes;

}



sub get_image_size {
    # returns $hsize,$vsize and $bpp for $1
    my ($file)=shift;
    my ($i);

    #identify hangs if the file extension is ".avi" or ".mp4"...maybe more...
    my ($file_ext)=&get_ext($file);

    if ($file_ext eq ".avi"||$file_ext eq ".mp4"||$file_ext eq ".mpg") {
	$height=$width=$bpp=0;
	return;
    }

    $bpp=8; # default for images
    if (!defined($imresact)) {
	$imresact=&rc_get("image_resize_action");
    }

    # imresact can be: default - resize all images to default; bound - use as max size but keep aspect (e.g. for thumbnails); or none: return actual size

    my ($id_cmd)=&location("identify");

    unless ($id_cmd eq "") {
	@@info=split / /, `$id_cmd \"$file\" 2>/dev/null`;


	my ($file2)=$file;
	$space_count=($file2 =~ tr/ //);
	for ($i=0;$i<$space_count;$i++) {
	    shift(@@info);
	}
	$bppstr=$info[4];
	@@bpp=split /-/,$bppstr;
	$bpp=$bpp[0];
	@@sizestr=split /\+/,$info[2];
	@@size=split /x/,$sizestr[0];

	$hsize=$size[0];
	$vsize=$size[1];
	
	if ($imresact eq ""||$imresact eq "default") {
	    $hsize=$vsize="";
	}
	elsif ($imresact eq "bound") {
	    if ($hsize>$dwidth) {
		$shrink=$hsize/$dwidth;
		$hsize/=$shrink;
		$vsize/=$shrink;
	    }
	    if ($vsize>$dheight) {
		$shrink=$vsize/$dheight;
		$hsize/=$shrink;
		$vsize/=$shrink;
	    }
	    $hsize=int($hsize);
	    $vsize=int($vsize);
	}
    }
    if (!defined($hsize)||$hsize eq "") {
	$hsize=$dwidth;
    }
    if (!defined($vsize)||$vsize eq "") {
	$vsize=$dheight;
    }
}




sub fill_and_redo_frames {
    # starting at start and ending at end, we will remove any gaps in image files
    # we return the last repacked frame number

    # if pre_cut_frames is defined, we will cut that many frames from start first
    if (defined($pre_cut_frames)) {
	for ($i=$start;$i<$start+$pre_cut_frames;$i++) {
	    $name=&mkname($i);
	    unlink "$name$img_ext";
	}
    }
    $hsize=$vsize=$bpp=0;
    $oldnext=-1;

    $missing=0;
    $lastframe=0;
    $imresact="none";

    chdir $curtmpdir;
    
    for ($i=$start;$i+$pre_cut_frames+$missing<=$end;$i++) {
	$name=&mkname($i);
	$found=0;

	while ($found==0&&$i+$pre_cut_frames+$missing<=$end) {

	    $next=$i+$pre_cut_frames+$missing;
	    $nextname=&mkname($next);

	    if (-f "$nextname$img_ext") {
		$lastframe=$i;
		$found=1;

		# clip the bottom row
		unless ($next==$oldnext) {
		    system("$convert_command -crop $width" . "!x" . $height . "! $nextname$img_ext $nextname.mgk >/dev/null 2>&1");
		    unlink "$nextname$img_ext";
		    rename "$nextname.mgk","$nextname$img_ext";
		    $oldnext=$next;
		}
		unless ($next==$i) {
		    system("cp $nextname$img_ext $name$img_ext");
		}
		if ($missing>0) {
		    $missing--;
		}
	    }
	    else {
		# frame not found - try the next one
		$missing++;
	    }
	}
	&sig_progress($i);
    }
    
    for ($i=$end-$pre_cut_frames+1;$i<=$end;$i++) {
	$name=&mkname($i);
	unlink "$name$img_ext";
    }

    $file=&mkname(1);
    $file.=$img_ext;
    &get_image_size($file);
    return $lastframe;
}



sub mp3_open {
    if (-f $audio_in) {
	unlink $audio_in;
    }
    $f_size=0;

    # prefer mpg321 if it's available
    unless (&location("mpg321") eq "") {
	system("mpg321 -w $audio_in --rate 44100 --stereo \"$file\" >/dev/null 2>&1");
	$f_size=-s $audio_in;
    }
    if ($f_size==0) {
	unless (&location("mpg123") eq "") {
	    system("mpg123 -w $audio_in --rate 44100 --stereo \"$file\" >/dev/null 2>&1");
	    $f_size=-s $audio_in;
	}
    }
    if ($f_size==0) {
	&othera_open;
	return;
    }

    $arate=44100;
    $achans=2;
    $asamps=16;

    $asigned=1;
    if ($asamps==8) {
	$asigned=0;
    }
    $aendian=&get_endian;
    $f_size=-s $audio_in;
}


sub ogg_open {
    if (-f $audio_in) {
	unlink $audio_in;
    }
    
    system("ogg123 -d wav -f $audio_in \"$file\" >/dev/null 2>&1");
    $f_size= -s $audiofile;

    if ($f_size==0) {
	&othera_open;
	return;
    }

    # values are assumed here
    $arate=44100;
    $achans=2;
    $asamps=16;

    $asigned=1;
    if ($asamps==8) {
	$asigned=0;
    }
    $aendian=&get_endian;
}


sub wav_open {
    $mplay_command=&rc_get("video_open_command");
    $curtmpfile=$curtmpdir . "/.temp";

    if (-f $audio_in) {
	unlink $audio_in;
    }
    
    system("cp \"$file\" $audio_in");
    system("$mplay_command -frames 0 $audio_in > $curtmpfile 2>/dev/null </dev/null");
    
    @@info2=split / /, `grep AUDIO: $curtmpfile`;
    unlink $curtmpfile;
    $arate=$info2[1];
    $achans=$info2[3];
    $asamps=$info2[5];


    if ($arate==0&&$achans==0&&$asamps==0) {
	# TODO - find way to read these
	# have to assume these for now
	$arate=44100;
	$achans=2;
	$asamps=16;
    }
    
    # and it seems we *must* assume these...
    $asigned=1;
    if ($asamps==8) {
	$asigned=0;
    }
    $aendian=&get_endian;

    $f_size= -s $audio_in;
}



sub othera_open {
    $arate=44100;
    $achans=2;
    $asamps=16;
    $aendian=&get_endian;
    $asigned=1;
    $format=&get_mplayer_format;

    system(&rc_get("video_open_command") . " -quiet \"$file\" -ao pcm:waveheader:file=$audio_in $format >/dev/null 2>&1 </dev/null");
    $f_size=-s $audio_in;
}



################################################
# utility subroutines

sub get_current_date {
    ($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = localtime(time);
    my $RealMonth = $Month + 1; # Months of the year are not zero-based

    if($RealMonth < 10)
    {
	$RealMonth = "0" . $RealMonth; # add a leading zero to one-digit months
    }
    if($Day < 10)
    {
	$Day = "0" . $Day; # add a leading zero to one-digit days
    }
    
    $Fixed_Year = $Year + 1900;

    return $Fixed_Year."-".$RealMonth."-".$Day;
}




sub getint {
    my ($string)=shift;
    my (@@val)=unpack("CCCC",$string);

    # TODO - this needs checking !

    if (!defined($endian)||$endian==1) {
	#little endian
	return ((($val[3]*256+$val[2])*256+$val[1])*256)+$val[0];
    }
    else {
	return ((($val[0]*256+$val[1])*256+$val[2])*256)+$val[3];
    }
}


sub get_endian {
    return unpack("h*", pack("s", 1)) =~ /^1/;
}



sub get_mplayer_format {
    if (!defined($nrate)) {
	$nrate=$arate;
    }
    if (!defined($nchans)) {
	$nchans=$achans;
    }
    if (!defined($nasamps)) {
	$nasamps=$asamps;
    }
    if (!defined($asigned)) {
	$asigned=$signed;
    }
    if (!defined($aendian)) {
	$aendian=$endian;
    }
    if (!defined($nsigned)) {
	$nsigned=$asigned;
    }
    if (!defined($nendian)) {
	$nendian=$aendian;
    }

    if ($nasamps==8) {
	if ($nsigned==0) {
	    return "-format u8";
	}
	return "-format s8";
    }
    if ($nsigned==0) {
	if ($nendian==0) {
	    return "-format u16be";
	}
	return "-format u16le";
    }
    if ($nendian==0) {
	return "-format s16be";
    }
    return "-format s16le";
}




sub clean_old {
    return if (! -d "$tmpdir/$handle");
    chdir "$tmpdir/$handle";
    unlink <*.mgk *.bak *.pre *.tmp pause audio.* audiodump*>;
    `sync;sync;sync`;
}



sub sig_complete {
    return if (! -d $curtmpdir);
    my($status)="completed";
    foreach (@@_) {
	$status.="|".$_;
    }
    `sync;sync;sync`;

    if (-d $curtmpdir) {
	&check_for_pause;
	open OUT,"> $statusfile";
	print OUT $status;
	close OUT;
	unlink $pidfile;
    }
}


sub sig_killed {
    return if (! -d $curtmpdir);
    return if (-f $statusfile);
    my($status)="killed";

    open OUT,"> $statusfile";
    print OUT $status;
    close OUT;
    unlink $pidfile;
}


sub sig_complete_audio {
    return if (! -d $curtmpdir);
    my($status)="audio_ended|";
    foreach (@@_) {
	$status.="|".$_;
    }
    
    open OUT,"> $statusfile.play";
    # autoflush output
    select((select(OUT), $| = 1)[0]);
    print OUT $status;
    close OUT;

    unless ($img_ext eq ".mgk"||$opening_preview==1) {
	unlink $pidfile;
    }
}

sub sig_complete_video {
    return if (! -d $curtmpdir);
    my($status)="video_ended|";
    #foreach (@@_) {
	#$status.=$_."|";
    #}

    open OUT,"> $statusfile.play";
    print OUT $status;
    close OUT;
    unless ($img_ext eq ".mgk") {
	unlink $pidfile;
    }
}


sub sig_error {
    # WARNING: error strings MUST NOT contain newlines, instead you can pass up to 4 lines of text as params
    return if (! -d $curtmpdir);

    my($status)="error";
    my ($count)=0;
    foreach (@@_) {
	$status.="|".$_;
	$count++;
    }
    if ($count<4) {
	$status.="|||ERROR|";
    }

    open OUT,"> $statusfile";
    print OUT $status;
    close OUT;
    unlink $pidfile;
    `sync;sync;sync`;
    exit 1;
}


sub sig_pid {
# write our pid in case we need to be cancelled
    open OUT,"> $pidfile";
    print OUT $$;   # process ID
    close OUT;
}



sub sig_progress {
# report progress of frame processing
    my $status="";
    foreach (@@_) {
	if ($status eq "") {
	    $status=$_;
	}
	else {
	    $status.="|".$_;
	}
    }
    &check_for_pause;
    open OUT,"> $statusfile";
    print OUT $status;
    close OUT;
}


sub sig_clear {
    &check_for_pause;
    unlink $statusfile;
}



sub location {
    # return the location of an executable
    my ($command)=shift;
    my ($location)=`which $command 2>/dev/null`;
    chomp($location);
    $location;
}


sub rc_set_if_not_set {
    my ($key)=$_[0];
    shift (@@_);
    my ($value)=join(" ",@@_);
    $skip_if_exist=1;
    &rc_set($key,$value);
}

sub rc_delete {
    my ($key)=$_[0];

    $delpref=1;
    &rc_set($key,"");
}



sub rc_set {
    # set a value in the .rc file
    my ($key)=$_[0];
    shift (@@_);
    my ($value)=join(" ",@@_);

    my ($rcfile)=$home."/".$rc_filename;

    if (defined($prefs_file)) {
	$rcfile=$prefs_file;
    }

    if (!defined(open OUT,"> $rcfile.new") && -e $rcfile) {
	exit 3;
    }

    # autoflush output
    select((select(OUT), $| = 1)[0]);

    if (! defined ($delpref)) {
	$delpref=0;
    }

    if ($key eq "") {
	$date=&get_current_date;
	print OUT "# This file is autogenerated by $GUI_NAME on $date\n# You are strongly advised to change the values only through the GUI.\n";
    }

    #replace <$key> to </$key> with our new value
    else {
	if (!defined(open IN,"$rcfile") && -e $rcfile) {
	    exit 2;
	}
	$string="";
	$part=0;
	$found=0;
	while (<IN>) {
	    $string=$_;
	    if ($found==0||$part==1) {
		if ($part==1||$_=~ /^(<$key>)/) {
		    if ($skip_if_exist==1) {
			close IN;
			close OUT;
			unlink "$rcfile.new";
			$skip_if_exist=0;
			return;
		    }
		    if ($part==0) {
			$part=1;
			if ($delpref==0) {
			    print OUT "$1$2\n$value\n</$key>\n";
			}
			else {
			    #$date=&get_current_date;
			    #print OUT "# $key deleted by $GUI_NAME $date\n";
			}
			$string=$3;
			$found=1;
		    }
		    if ($string=~ /(<\/$key>)$/) {
			if ($delpref==0) {
			    print OUT $3;
			}
			$part=0;
		    }
		}
		elsif ($part==0) {
		    print OUT $string;
		}
	    }
	    else {
		print OUT $string;
	    }
	}
	if ($found==0&&$delpref==0) {
	    print OUT "\n<$key>\n$value\n</$key>\n";
	}
    }
    close IN;
    close OUT;
    rename $rcfile.".new",$rcfile or exit 3;
    $delpref=0;
}


sub rc_get {
    # return a value from our .rc file
    my ($key)=shift;
    my ($rcfile)=$home.'/'.$rc_filename;
    my ($string)='';

    if (defined($prefs_file)) {
	$rcfile=$prefs_file;
    }

    unless (defined(open IN,"$rcfile")) {
	print STDERR "Smogrify: Unable to read values from rc file, $rcfile\n";
	exit 2;
    }
    $part=0;
    while (<IN>) {
	if ($part==1&&$_=~ /(<\/$key>)$/) {
	    close IN;
	    return $string;
	}
	if ($part==1||$_=~ /^(<$key>)/) {
	    if ($part==1) {
		$_=~ s/\n//g;
		if ($string eq "") {
		    $string=$_;
		}
		else {
		    $string.="\n".$_;
		}
	    }
	    else {
		$part=1;
		$string=$2;
	    }
	}
    }
    close IN;
    return $string;
}



sub count_frames {
    #count number of frames using a binary search

    my $count=0,$gap=1;
    if (!defined $handle) {
	$handle=$ARGV[1];
	$curtmpdir="$tmpdir/$handle";
    }

    $name=&mkname(1);
    unless (-f "$curtmpdir/$name$img_ext") {
	return 0;
    }

    while (1) {
	$name=&mkname($count+$gap);
	if (-f "$curtmpdir/$name$img_ext") {
	    $count+=$gap;
	    $gap*=2;
	}
	else {
	    if ($gap==1) {
		last;
	    }
	    $gap/=2;
	}
    }
    return $count;
}
    


sub my_basename {
    my ($exe)=shift;
    my @@parts=split(/\//,$exe);
    return @@parts[-1];
}



sub write_bootstrap_file {
    #write our bootstrap file and make our tmpdir
    unlink $gui_bootstrap_file;
    unless (defined(open OUT,"> $gui_bootstrap_file")) {
	exit 4;
    }
    close OUT;
}


sub mktmpdir {
    unless (-d $tmpdir) {
	# create working directory
	umask 0;
	unless (mkdir $tmpdir,0777) {
	    unless ($gui_bootstrap_file eq "") {
		open OUT,"> $gui_bootstrap_file" or exit 4;
		print OUT "$version|$tmpdir|$msg|$msg2";
		close OUT;
	    }
	    exit 5;
	}
	umask $umask;
    }
}


sub fndset {
    /^set\./ or return;
    $in_set=1;
}



sub get_home_dir {
    return $ENV{"HOME"};
}



# get default values
sub rc_get_default {
    # return a value from our .rc file
    my ($key)=shift;
    my ($ret)="";

    if ($key eq "mplayer_play_video_command") {
	$ret=&location("mplayer");
	if (!($ret eq "")) {
	    $ret.=" -double";
	}
    }

    elsif ($key eq "sox_command") {
	$ret=&location("play");
    }

    elsif ($key eq "mplayer_audio_command") {
	$ret=&location("mplayer");
    }

    $ret;
}



sub version_check_and_upgrade {
    my $old_version=&rc_get("version");
    my $version_hash=&version_hash($old_version);

    $msg="";

    # throw a warning if using png and convert_version < 6.0.0
    if (&rc_get("default_image_format") eq "png" && $convert_version_hash<6000) {
	$msg="You are advised to upgrade to at least version 6.0 of Image Magick if using png files";
    }

    if ($version_hash>0) {
	if ($version_hash<8005) {
	    # not used now
	    &rc_delete("frontend");
	    &rc_delete("mog_auto_bak");
	    &rc_delete("plugin_dir");
	}
	if ($version_hash<9001) {
	    # convert_version is used instead now
	    &rc_delete("mogrify_version");

	    &rc_delete("effects_command");

	    # hey, now we use our own keyboard poller
	    # things are getting groovy !
	    &rc_delete("no_fast_keys");

	    # changed to "open_compression_percent"
	    &rc_delete("open_quality");

	    &rc_delete("kbd_rpt_state");
	    &rc_delete("kbd_rpt_delay");
	    &rc_delete("kbd_rpt_rate");

	    #encoder_command not used any more
	    &rc_delete("encoder_command");

	    #encoder_acodec used instead
	    &rc_delete("audio_encode_quality");

	    #encoder plugin names changed
	    $msg="Make sure you delete all the old encoder plugins and install the new ones.";
	    $msg2="Then change your encoder from Preferences / Encoders";
	}
	if ($version_hash<9006) {
	    &rc_delete("video_player");
	    &rc_delete("video_play_command");
	    &rc_delete("PAL/NTSC");
	}
	if ($version_hash<9006) {
	    &rc_delete("osc_opts");
	}
	unless ($old_version eq $version) {
	    $current_keymap=`grep \"keymap file version 4\" $lives_home_dir$default_keymap 2>/dev/null`;
	    if ($current_keymap eq "") {
		unlink "$lives_home_dir$default_keymap";
	    }
	    unless (&location("build-lives-plugin-multi") eq "") {
		`build-lives-plugin-multi custom`;
		`build-lives-plugin-multi test`;
	    }
	}
    }

    if (&rc_get("jack_testing") eq "false") {
	&rc_delete("jack_testing");
    }

    # bless this version
    &rc_set("version",$version);
}


sub version_hash {
    my ($string)=shift;
    if ($string eq "") {
	return 0;
    }
    my ($ver_major,$ver_minor,$ver_micro)=split (/[.]/, $string,3);
    my $version_hash=($ver_major*1000+$ver_minor)*1000+$ver_micro;
    $version_hash;
}


sub RGB24_to_string {
    my ($red,$green,$blue)=@@_;
    sprintf("'#%02X%02X%02X'",int($red),int($green),int($blue));
}


sub get_form_request {
    my ($plugin)=shift;
    if ($plugin eq "") {
	return &get_format_request;
    }
    else {
	return `$plugin get_format_request`;
    }
}


sub get_convert_version_hash {
    my $real_convert_command=(split(" ",$convert_command))[0];
    my $convert_version=`$real_convert_command | grep -i version`;
    $convert_version=(split(" ",$convert_version))[2];
    return &version_hash($convert_version);
}


sub weed {
    my $file;
    if (!chdir $tmpdir) {
	print STDERR "Could not clean up, directory $tmpdir is not accessible\n";
	return 0;
    }
    my $start_total=(split / /, `du -sb -B 1048567 2>/dev/null`)[0];

    use File::Find;
    opendir DIR,$tmpdir;
    while ($file=readdir(DIR)) {
	unless ($file =~ /^\./) {
	    if (-d "$tmpdir/$file") {
		if (-d "$tmpdir/$file/clips/" || -d "$tmpdir/$file/layouts") {
		    # TODO - prune subdirs of clips
		    # new style sets, for now only check /clips subdir
		    unless (!defined($new_temp)||$new_temp eq "") {
			system("/bin/mv $file $new_temp/");
		    }
		}
		else {
		    $in_set=0;
		    find (\&fndset,"$tmpdir/$file/");
		    if (!$in_set) {
			`/bin/rm -rf $file`;
		    }
		    else {
			unless (-f "noprune") {
			    chdir $file;
			    &prune;
			    chdir $tmpdir;
			}
			unless (!defined($new_temp)||$new_temp eq "") {
			    system("/bin/mv $file $new_temp/");
			}
		    }
		}
	    }
	    else {
		unless (!defined($new_temp)||$new_temp eq "") {
		    if ($file =~ /^recovery/) {
			system("/bin/mv $file $new_temp/");
		    }
		}
	    }
	}
    }
    closedir DIR;

    `/bin/rm -f .* 2>/dev/null`;
    `/bin/rm -f rfx.* 2>/dev/null`;
    `/bin/rm -f /tmp/.smogval* 2>/dev/null`;
    `/bin/rm -rf /tmp/lives-symlinks 2>/dev/null`;
    my $end_total=(split / /, `du -sb -B 1048567 2>/dev/null`)[0];

    return $start_total-$end_total;
}


sub get_sox_version {
    my $soxv=`sox -h 2>&1 | grep -i sox:`;

    my $soxvv=(split(/\./,(split(" ",$soxv))[2]))[0];

    if (substr($soxvv,0,1) eq "v") {
	$soxvv=substr($soxvv,1,length($soxvv));
    }
    if ($soxvv eq "") {
	# version 12.x.x or lower
	$soxvv=0;
    }

    return $soxvv;
}


sub prune {
    $old_handle=$handle;
    $handle=$file;
    &clean_old;
    $handle=$old_handle;
}




sub clear_symlinks {
    my $linksdir="lives-symlinks/$handle/";
    
    chdir "/tmp";
    
    if (-d $linksdir) {
	# remove directory + contents
	system("/bin/rm -rf $linksdir");
    }
    
    #create dir so next step works
    system("/bin/mkdir -p $linksdir");

    # remove dir + any empty parents
    system("/bin/rmdir -p $linksdir 2>/dev/null");
}
@


1.234
log
@synch to 1.0.0
@
text
@d35 1
a35 1
$version="1.0.0";
@


1.233
log
@gui/theme updates
@
text
@d35 1
a35 1
$version="1.0.0-cvs";
@


1.232
log
@fix selection encoding
@
text
@d258 1
a258 1
	&rc_set_if_not_set("gui_theme","editor");
@


1.231
log
@updates
@
text
@d1638 1
a1638 1
	    my $to_handle=$ARGV[4];
d1644 1
a1644 1
	    if ($to_handle eq "") {
d1664 1
a1664 1
		    system ("/bin/ln $curtmpdir/$from$img_ext $linksdir$name$img_ext");
d1670 1
a1670 1
 	    unless ($to_handle eq "") {
@


1.230
log
@minor mt updates
@
text
@d258 1
a258 1
	&rc_set_if_not_set("gui_theme","crayons");
@


1.229
log
@updates
@
text
@d258 1
a258 1
	&rc_set_if_not_set("gui_theme","editor");
@


1.228
log
@code cleanup
@
text
@d258 1
a258 1
	&rc_set_if_not_set("gui_theme","crayons");
@


1.227
log
@updates
@
text
@d258 1
a258 1
	&rc_set_if_not_set("gui_theme","editor");
@


1.226
log
@symlinks for db, pt 1
@
text
@d1551 1
a1551 1
			# instead it first calls link_frames, and sets $start to -1
d1638 2
a1642 2
	    #create symlinks in /tmp for dynebolic
	    $linksdir="/tmp/lives-symlinks/$handle/";
d1644 14
a1657 2
	    if (-d $linksdir) {
	        system("/bin/rm -rf $linksdir");
a1659 3
	    system("/bin/mkdir -p $linksdir");
	    system ("/bin/chmod -R 777 $linksdir");

d1670 4
@


1.225
log
@updates
@
text
@d692 1
a692 10
		    for ($i=1;$i<=($end-$start+1);$i++) {
			$name=&mkname($i);
			if (-f "$name.ign") {
			    if (-f "$name$img_ext") {
				# remove symlink
				unlink "$name$img_ext";
			    }
			    rename "$name.ign","$name$img_ext";
			}
		    }
d888 8
a1418 1
	    unlink "audiodump.wav";
d1426 4
d1442 11
d1547 1
a1547 1
		    #move the selection down so that frames start at 1
d1549 12
d1564 2
a1565 5
			    if (-f "$name$img_ext") {
				rename "$name$img_ext","$name.ign";
			    }
			    if (-f "$from$img_ext") {
				system ("/bin/ln -sf $from$img_ext $name$img_ext");
d1568 1
d1572 8
d1602 1
d1635 3
a1637 3
	    my $from_handle=$ARGV[2];
	    my $start=$ARGV[3];
	    my $end=$ARGV[4];
d1641 9
a1649 1
	    $fromdir="$tmpdir/$from_handle/";
d1654 3
a1656 2
		if (-f "$fromdir$from$img_ext") {
		    system ("/bin/ln -sf $fromdir$from$img_ext $name$img_ext");
d1660 1
a1660 3
	    if (-f "$fromdir$audiofile") {
		system ("/bin/ln -sf $fromdir$audiofile $audiofile");
	    }
d4762 1
a4762 1
    return @@parts[scalar(@@parts)-1];
d4995 1
d5025 20
@


1.224
log
@fix crash in event_list_rectify
@
text
@d1218 1
a1218 1
		    $syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo jpeg:quality=$quality -fps 100000 $ss $frames -vf scale -noframedrop -ao null \"$file\" $extra_params </dev/null";
d1221 1
a1221 1
		    $syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo png:z=$compression -fps 100000 $ss $frames -vf scale -noframedrop -ao null \"$file\" $extra_params </dev/null";
d1227 1
a1227 1
		    $syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo jpeg:quality=$quality $ss -noframedrop $frames -ao pcm:fast$wavhead $channs -vf scale -mc 0  \"$file\" $extra_params </dev/null";
d1230 1
a1230 1
		    $syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo png:z=$compression $ss -noframedrop $frames -ao pcm:fast$wavhead $channs -vf scale -mc 0  \"$file\" $extra_params </dev/null";
@


1.223
log
@updates bloody updates
@
text
@d1282 1
a1282 1
	    if (-f "$name$img_ext" && -z "$name$img_ext") {
@


1.222
log
@various updates
@
text
@d3327 2
a3329 1
	    chomp($achans);
d3333 2
d3336 1
a3336 1
	    chomp($abitrate);
a3358 1

@


1.221
log
@synch with 0.9.9.9
@
text
@d1798 2
a1799 1
			if (defined $newwidth && defined $newheight) {
d3337 5
a3341 3
		$adets=`grep AUDIO: $file_ident 2>/dev/null`;
		$achans=(split(" ",$adets))[3];
		chomp($achans);
d3345 5
d3352 5
@


1.220
log
@updates
@
text
@d35 1
a35 1
$version="0.9.9-cvs";
@


1.219
log
@small updates
@
text
@d256 2
a257 1
	
@


1.218
log
@synch to 0.9.9.8
@
text
@d35 1
a35 1
$version="0.9.9.-cvs";
@


1.217
log
@small updates
@
text
@d35 1
a35 1
$version="0.9.9-cvs";
@


1.216
log
@textwidget fix
@
text
@a240 1
	&rc_set_if_not_set("bgcolour","black");
d3141 1
a3141 1
	    $bgcolour=&rc_get("bgcolour");
@


1.215
log
@updates
@
text
@d275 1
a275 1
	&rc_set_if_not_set("mt_pertrack_audio","false");
@


1.214
log
@updates
@
text
@d3 1
a3 1
# smogrify - Copyright G. Finch 2003 - 2007
@


1.213
log
@omc learn prefs pt1
@
text
@d242 5
a246 5
	&rc_set_if_not_set("vid_load_dir","/usr/local/");
	&rc_set_if_not_set("vid_save_dir","/usr/local/");
	&rc_set_if_not_set("image_dir","/usr/local/");
	&rc_set_if_not_set("proj_dir","/usr/local/");
	&rc_set_if_not_set("audio_dir","/usr/local/");
d1506 1
@


1.212
log
@fix for odd height theora clips
@
text
@d286 3
@


1.211
log
@fix for rendered gens
@
text
@a30 1
    
@


1.210
log
@img preview fix
@
text
@d2556 1
@


1.209
log
@img preview fix
@
text
@d1107 2
d1117 6
a1122 3
		    print STDERR "Error playing audio !\n";
		    print STDERR "Failed command was: $syscom2\n";
		    $syscom2;
@


1.208
log
@multihead support
@
text
@d623 3
a625 1
	    $file=$ARGV[2];
a4059 8
    unless ($imresact eq "none"||$imresact eq "") {
	if (!defined($dwidth)) {
	    $dwidth=&rc_get("default_width");
	}
	if (!defined($dheight)) {
	    $dheight=&rc_get("default_height");
	}
    }
@


1.207
log
@auto-deinterlace, other updates
@
text
@a285 1
	&rc_set_if_not_set("virt_screens","1x1");
@


1.206
log
@updates
@
text
@d24 1
a24 1
$encoder="multi_encoder";
d265 1
@


1.205
log
@updates
@
text
@d264 2
@


1.204
log
@resample virtual files, code cleanup
@
text
@d1224 1
a1224 1
		$syscom=$mplay_command . " -quiet $band -vc null -vo null $ss $frames -ao pcm:fast$wavhead $channs -mc 0 \"$file\" $extra_params </dev/null";
@


1.203
log
@RFX in virtual files
@
text
@d912 1
a912 1
    if ($command eq "play"||$command eq "play_opening_preview"||$command eq "play_preview") {
d920 1
a920 1
	# play_preview is exactly like play
a925 9
    if ($command eq "play_preview") {
	# play_preview is exactly like play, but we play .mgk files
	$img_ext=".mgk";
	
	# take the opportunity to sync the disk
	`sync;sync;sync`;
	$command="play";
    }

a1387 30
    if ($command eq "dvcomplete") {
	chdir $curtmpdir;
	
	$i=0;

	opendir DIR,$curtmpdir;
	while ($file=readdir(DIR)) {
	    unless ($file =~ /^\./||$file =~ /^0/) {
		$name=&mkname(++$i);
		rename "$file","$name$img_ext";
	    }
	}
	closedir DIR;

	$imresact="none";
	&get_image_size("$name$img_ext");
	$endian=&get_endian;

	$pal_ntsc=&rc_get("PAL/NTSC");
	if ($pal_ntsc eq "NTSC") {
	    $fps=29.97;
	}
	else {
	    $fps=25.00;
	}

	&sig_complete($handle,$i,"dv",$hsize,$vsize,$bpp,$fps,$f_size,44100,0,16,1,$endian,0,$title,$author,$comment);
	exit 0;
    }

d1784 12
a1795 10
		    $to=&mkname($count);
		    if (defined $newwidth && defined $newheight) {
			&resize_frame($from,$newwidth,$newheight);
			unlink "$to.mgk";
			rename "$from$resize_ext","$to.mgk";
		    }
		    else {
			# we don't preview here...
			unless ($from eq $to) {
			    `cp $from$img_ext $to.mgk`;
d1798 1
d1815 1
d1819 4
a1822 2
		unlink "$curtmpdir/$name.bak";
		rename "$curtmpdir/$name$img_ext","$curtmpdir/$name.bak";
a2536 86
    if ($command eq "merge_frames") {
	unlink "$curtmpdir/pause";
	$cbstart=$ARGV[2];
	$start=$ARGV[3];
	$end=$ARGV[4];
	$from_handle=$ARGV[5];
	$width=$ARGV[6];
	$height=$ARGV[7];
	$owidth=$ARGV[8];
	$oheight=$ARGV[9];
	$x=$ARGV[10];
	$y=$ARGV[11];
	$threshold=$ARGV[12];
	$transwhite=$ARGV[13];
	$pc_start=100;

	if (defined $ARGV[14] && !($ARGV[14] eq "")) {
	    $pc_start=$ARGV[14];
	}
	$pc_step=0;
	if (defined $ARGV[15] && !($ARGV[15] eq "")) {
	    $pc_step=$ARGV[15];
	}
	$pc_end=-1;
	if (defined $ARGV[16] && !($ARGV[16] eq "")) {
	    $pc_end=$ARGV[16];
	    if ($pc_step>0&&$pc_end<$pc_start) {
		$pc_end=-1;
	    }
	    if ($pc_step<0&&$pc_end>$pc_start) {
		$pc_end=-1;
	    }
	}

	&clean_old;
	$antialias=&rc_get("antialias");

	$threshold_plus=-$threshold;

	$j=$cbstart;

	for ($i=$start;$i<=$end;$i++) {

	    $from=&mkname($j);
	    $in2="$tmpdir/$from_handle/$from$img_ext";

	    unless (-f $in2) {
		# end of clipboard reached, loop back to start
		$j=$cbstart;
		$from=&mkname($j);
		$in2="$tmpdir/$from_handle/$from$img_ext";
	    }

	    $name=&mkname($i);
	    $toimg="$curtmpdir/$name.mgk";

	    &merge;

	    $pc_start+=$pc_step;
	    if ($pc_start>100) {
		$pc_start=100;
	    }
	    if ($pc_start<0) {
		$pc_start=0;
	    }

	    if ($pc_end!=-1) {
		if ($pc_step>0&&$pc_start>$pc_end) {
		    $pc_start=$pc_end;
		}
		if ($pc_step<0&&$pc_start<$pc_end) {
		    $pc_start=$pc_end;
		}
	    }
	    $j++;
	    &sig_progress($i);
	}
	
	$end=$where+$end-$start;
	$start=$where;

	&mv_mgk;
	&sig_complete;
	exit 0;
    }

@


1.202
log
@rfx preview for virtual clips
@
text
@a4818 7
# usleep (seconds)
sub usleep ($) {
    select (undef, undef, undef, shift);
}



@


1.201
log
@updates and virtual file rfx pt 1
@
text
@d4819 4
@


1.200
log
@decoder plugins
@
text
@a30 1

d921 1
a921 2
	# unless we are opening audio,
	# then we will play wav, not raw
d1021 2
a1022 2
	    $aformat=".wav";
	    $audiofile=$curtmpdir."/audiodump.wav";
d1191 2
d1195 2
d1225 1
a1225 1
		    $syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo jpeg:quality=$quality $ss -noframedrop $frames -ao pcm:fast:nowaveheader $channs -vf scale -mc 0  \"$file\" $extra_params </dev/null";
d1228 1
a1228 1
		    $syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo png:z=$compression $ss -noframedrop $frames -ao pcm:fast:nowaveheader $channs -vf scale -mc 0  \"$file\" $extra_params </dev/null";
d1233 1
a1233 1
		$syscom=$mplay_command . " -quiet $band -vc null -vo null -hardframedrop $ss $frames -ao pcm:fast:nowaveheader $channs -mc 0 \"$file\" $extra_params </dev/null";
d2280 2
d2284 1
a2284 1
	$f_size=-s $audio_in;
d2304 7
a2310 1
	    if (-f $audio_in) {
@


1.199
log
@fix sox version check
@
text
@d3062 1
a3062 1
	if ($i<=($num_frames-$frames_to_move)&&!$undo_cut) {
d3064 1
a3064 1
	    system("cp $curtmpdir/$from$img_ext $curtmpdir/$from.bak");
d3080 1
a3080 1
		system("cp $fromdir/$from.bak $curtmpdir/$to$img_ext");
d3088 1
a3088 1
		system("cp $fromdir/$from$img_ext $curtmpdir/$to$img_ext");
@


1.198
log
@decoder plugins
@
text
@d5057 1
a5057 1
    my $soxvv=(split(/\./,(split(" ",$soxv))[3]))[0];
d5059 3
d5066 1
@


1.197
log
@fixes for new libtool
@
text
@d24 1
a24 1
$encoder="mencoder_encoder";
d1309 1
a1309 1
		if (!defined($DEBUG_OPEN)) {
@


1.196
log
@decoder plugins
@
text
@d556 1
a556 1
	# plugins are return in sort() order
d561 1
d565 5
d581 1
a581 1
			    $plugname=(split /\./,$plugname)[0];
d584 6
a589 1
			    $string.="$plugname|";
@


1.195
log
@code updates
@
text
@d1171 1
a1171 1
	$audio_in="audiodump.wav";
d1201 1
d1209 2
a1210 1
	    else {
d1212 1
a1212 1
		    $syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo jpeg:quality=$quality $ss -noframedrop $frames -ao pcm $channs -vf scale -mc 0  \"$file\" $extra_params </dev/null";
d1215 1
a1215 1
		    $syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo png:z=$compression $ss -noframedrop $frames -ao pcm $channs -vf scale -mc 0  \"$file\" $extra_params </dev/null";
d1217 5
a1221 1
	    }
d1278 2
a1279 3
	    &convert_audio_to_raw;
	    unlink $audio_in;
	    $af_size=-s $audio_out;
d1284 1
a1284 1
	    if (-f $audio_in) {
@


1.194
log
@multitrack audio
@
text
@a2923 4
sub hup_handler {
    $hupped=1;
}

a4021 1
    $hupped=0;
d4026 1
a4026 4
	# TODO - signal to GUI that 'enough' will now work
	unless ($only_first) {
	    $SIG{'HUP'}="hup_handler";
	}
a4041 3
		if ($hupped) {
		    last;
		}
a4224 3
    $hupped=0;
    $SIG{'HUP'}="hup_handler";

a4229 3
	if ($hupped) {
	    last;
	}
d4231 1
a4232 4
	while ($found==0&&$i+$pre_cut_frames+$missing<=$end) {
	    if ($hupped) {
		last;
	    }
a4262 3
	if ($hupped) {
	    last;
	}
@


1.193
log
@updates for dynelives
@
text
@d273 1
@


1.192
log
@updates
@
text
@d38 1
d221 6
@


1.191
log
@mplayer audio updates
@
text
@d266 1
@


1.190
log
@updates
@
text
@d3560 1
a3560 1
	system(&rc_get("video_open_command") . " -quiet -ao pcm -demuxer rawaudio -rawaudio rate=$arate:channels=$achans:samplesize=$aasamps -waveheader $format -vo null $audio_in >/dev/null 2>&1 </dev/null");
d3614 1
a3614 1
	system("sox -t .raw -r $arate $asigned -$sasamps -c $achans $aendian $audio_in -t .wav -r $nrate -c $nchans $nsigned -$nasamps $nendian $curtmpdir/audiodump.wav > /dev/null 2>&1");
@


1.189
log
@lives TV pt 1
@
text
@a100 1
	    #print "Attempting to stop process ".$target_pid." with $command\n";
d120 1
@


1.188
log
@lives TV pt 1
@
text
@d72 1
a72 1
    if ($command eq "stopsubsub"||$command eq "stopsubsubs") {
d75 6
a80 1
	$pidfile="$curtmpdir/.pid";
d102 1
a102 1
	    elsif ($command eq "stopsubsub") {
d125 3
a127 1
	    &sig_killed;
a146 6
    if ($command eq "stop_audio") {
	$ppid=$ARGV[1];
	&stop_audio;
	exit 0;
    }

d1082 1
a4621 8
sub stop_audio {
    my $aplayer=&rc_get("audio_player");
    if ($aplayer eq "sox"||$aplayer eq "mplayer") {
	$audio_play_command=&rc_get("audio_play_command");
	`pkill -TERM -g $ppid -f $audio_play_command>/dev/null 2>&1`;
    }
}

@


1.187
log
@firsttime improvements
@
text
@d1216 5
d3540 1
a3540 1
	system("sox -t .wav $audio_in -t .raw $xsigned $audio_out");# > /dev/null 2>&1");
@


1.186
log
@preview opt
@
text
@d225 1
a225 1
	&rc_set_if_not_set("open_compression_percent",25);
d4949 5
@


1.185
log
@updates
@
text
@d857 14
d2687 2
a2688 2
		unless (defined($fx_prev)) {
		    if ($num_in_channels>0) {
a2690 4
		    else {
			$frames=&count_frames;
		    }
		    &sig_complete($nwidth,$nheight,$fps,$frames);
d2692 4
a2723 1
		    &sig_complete($nwidth,$nheight);
d2725 1
d2881 27
@


1.184
log
@updates
@
text
@d825 3
d829 1
a829 1
	    shift;
@


1.183
log
@multitrack polish
@
text
@a3181 79

sub merge { # heh :-)	    'the underwater function'
    # a $threshold of 100000 means no transparency, >0 otherwise is transparent over, <0 is transparent under

    if (!defined($transwhite)) {
	$transwhite=0;
    }

    if ($threshold<100000&&$threshold>=0) {
	# transparent over
	if ($antialias eq "false") {
	    system("$convert_command +antialias -size $width"."x$height $fromimg -scale $width!x$height! resize.png >/dev/null 2>&1");
	}
	else {
	    system("$convert_command -size $width"."x$height $fromimg -resize $width!x$height! resize.png >/dev/null 2>&1");
	}
    
	system("$convert_command -size $width!x$height! xc:transparent -matte blank.png >/dev/null 2>&1");
	if ($transwhite==0) {
	    system("$convert_command resize.png -threshold $threshold mask.png >/dev/null 2>&1");
	}
	else {
	    system("$convert_command resize.png -threshold ".(65535-$threshold)." -negate mask.png >/dev/null 2>&1");
	}
	system("$composite_command resize.png blank.png mask.png output.png >/dev/null 2>&1");
	system("$composite_command -compose plus -dissolve $pc_start -geometry +$x!+$y! output.png $curtmpdir/$name$img_ext $toimg.jpg >/dev/null 2>&1");
	system("$convert_command +matte $toimg.jpg $toimg > /dev/null 2>&1");

	unlink <mask.png blank.png output.png resize.png resize2.png>;
	unlink "$toimg.jpg";
    }
    elsif ($threshold<0) {
	# transparent under
	if ($antialias eq "false") {
	    system("$convert_command +antialias -size $width"."x$height $fromimg -scale $width!x$height! resize.png >/dev/null 2>&1");
	}
	else {
	    system("$convert_command -size $width"."x$height $fromimg -resize $width!x$height! resize.png >/dev/null 2>&1");
	}
    
	system("$convert_command $curtmpdir/$name$img_ext resize2.png >/dev/null 2>&1");
	system("$convert_command -size $owidth!x$oheight! xc:transparent -matte blank.png >/dev/null 2>&1");
	if ($transwhite==0) {
	    system("$convert_command -threshold ".($threshold_plus)." resize2.png mask.png >/dev/null 2>&1");
	}
	else {
	    system("$convert_command -threshold ".(65536-$threshold_plus)." -negate resize2.png mask.png >/dev/null 2>&1");
	}

	system("$composite_command resize2.png blank.png mask.png output.png >/dev/null 2>&1");

	if ($height!=$oheight||$width!=$owidth) {
	    system("$composite_command -compose plus -dissolve $pc_start -geometry -$x!-$y! output.png resize.png $toimg.png >/dev/null 2>&1");
	    system("$composite_command -geometry +$x!+$y! $toimg.png resize2.png $toimg.jpg >/dev/null 2>&1");
	}
	else {
	    system("$composite_command -compose plus -dissolve $pc_start -geometry -$x!-$y! output.png resize.png $toimg.jpg >/dev/null 2>&1");
	}

	system("$convert_command +matte $toimg.jpg $toimg >/dev/null 2>&1");

	unlink <mask.png blank.png output.png resize.png resize2.png>;
	unlink "$toimg.jpg";
	unlink "$toimg.png";
    }
    else {
	# fade merge
	if ($antialias eq "false") {
	    system("$convert_command +antialias -size $width"."x$height $name$img_ext -scale $width!x$height! $name.tmp >/dev/null 2>&1");
	}
	else {
	    system("$convert_command -size $width"."x$height $fromimg -resize $width!x$height! resize.png >/dev/null 2>&1");
	}
	system("$composite_command -compose plus -dissolve $pc_start -geometry +$x!+$y! $name.tmp $curtmpdir/$name$img_ext $toimg >/dev/null 2>&1");
	unlink $name.tmp;
    }
}


@


1.182
log
@add preview quality to prefs
@
text
@d196 1
a196 4
	$real_convert_command=(split(" ",$convert_command))[0];
	$convert_version=`$real_convert_command | grep -i version`;
	$convert_version=(split(" ",$convert_version))[2];
	$convert_version_hash=&version_hash($convert_version);
d5017 8
@


1.181
log
@config updates and fix for hang
@
text
@d226 1
a250 2
	&rc_set_if_not_set("default_height",240); # currently unused
	&rc_set_if_not_set("default_width",320); # currently unused
a251 1
	&rc_set_if_not_set("PAL/NTSC","PAL");
@


1.180
log
@small updates
@
text
@d455 1
a456 1
	$handle=$ARGV[1];
d464 1
a465 1
	$handle=$ARGV[1];
@


1.179
log
@decoder plugins pt 1
@
text
@d2802 1
a2810 1
    `kill -TERM $target_pid >/dev/null 2>&1`;
@


1.178
log
@further colorspace updates 2 / fix undo_cut
@
text
@d26 1
a26 1
$composite_command="composite -colorspace RGB -type truecolor";
d29 1
a29 1
$convert_command="convert -colorspace RGB -type truecolor";
@


1.177
log
@share to lib changes
@
text
@a2995 4
	    while (! -f "$curtmpdir/$from$img_ext") {
		print STDERR "waiting on image $fromdir/$from$img_ext\n";
		sleep 1;
	    }
a3011 5
	    while (! -f "$fromdir/$from$img_ext") {
		print STDERR "waiting on image $fromdir/$from$img_ext\n";
		sleep 1;
	    }

d3016 5
@


1.176
log
@fix 0Hz audio problem
@
text
@d553 3
a555 4
	$allow_nonex=$ARGV[1];
	$allow_subdirs=$ARGV[2];
	$dir=$ARGV[3];
	$in_home=$ARGV[4];
d557 1
a557 14
	$string="";

	if ($in_home==1) {
	    $prefix_dir="$home/";
	}
	elsif ($in_home==2) {
	    $prefix_dir="";
	}
	else {
	    $prefix_dir=&rc_get("prefix_dir");
	    if ($prefix_dir eq "") {
		exit 1;
	    }
	}
a558 1
	$plugindir="$prefix_dir$dir";
d566 1
a566 1
	    foreach $plugname (@@files) {
d594 3
a596 1
	    system("$rfx_builder_multi $type");
a825 1
	    #$prefix_dir=&rc_get("prefix_dir");
d2621 1
a2621 1
	    $prefix_dir=&rc_get("prefix_dir");
d2628 1
a2628 1
		$plugin_name="$prefix_dir/share/lives/plugins/effects/rendered/$command";
@


1.175
log
@small updates
@
text
@d3436 6
a3441 3
	    $arate=(split("=",(split("\n",$arate))[0]))[1];
	    chomp($arate);
	    
@


1.174
log
@updates
@
text
@a3008 4
	while (! -f "$curtmpdir/$from$img_ext") {
	    print STDERR "waiting on image $curtmpdir/$from$img_ext\n";
	    sleep 1;
	}
d3010 4
d3030 2
a3031 2
	    while (! -f "$curtmpdir/$from$img_ext") {
		print STDERR "waiting on image $curtmpdir/$from$img_ext\n";
@


1.173
log
@small fixes
@
text
@d3009 4
d3030 5
@


1.172
log
@more fixes 4
@
text
@d5030 4
a5033 1
    chdir $tmpdir;
d5078 1
@


1.171
log
@more fixes 3
@
text
@d116 1
a116 1
		system("kill -9 $target_pid>/dev/null 2>&1");
d2824 1
a2824 1
    `kill -9 $target_pid >/dev/null 2>&1`;
d4665 1
a4665 1
	`pkill -9 -g $ppid -f $audio_play_command>/dev/null 2>&1`;
@


1.170
log
@more fixes 2
@
text
@d82 8
a89 3
	while ($wait_for_pid) {
	    unless (-d "$curtmpdir") {
		exit 2;
d91 18
a108 26
	    if (defined(open IN,"< $pidfile")) {
		read IN,$target_pid,8;
		close IN;
		if ($target_pid eq NULL) {
		    exit 1;
		}
		# make sure pidfile has same group and owner, otherwise exit
		@@stat=stat($pidfile);
		if (!($uid==$stat[4]&&$gid==$stat[5])) {
		    die "Smogrify: Unable to stop process $target_pid.\n";
		}
		#print "Attempting to stop process ".$target_pid." with $command\n";
		elsif ($command eq "stopsubsub") {
		    # kill all subprocesses of target_pid, and target_pid
		    &kill_child_pids($target_pid);
		}
		elsif ($command eq "stopsubsubs") {
		    # kill all subprocesses of target_pid, but not target_pid
		    `pgrep -P $target_pid > $tmpdir/.pids.$target_pid`;
		    if (-s "$tmpdir/.pids.$target_pid"&&defined(open IN,"$tmpdir/.pids.$target_pid")) {
			while (<IN>) {
			    $pid=$_;
			    chomp($pid);
			    &kill_child_pids($pid);
			}
			close IN;
d110 1
a110 5
		    unlink "$tmpdir/.pids.$target_pid";
		}

		else {
		    system("kill -9 $target_pid>/dev/null 2>&1");
d112 1
a112 4

		unlink $pidfile;
		&sig_killed;
		exit 0;
d114 3
a116 12

	    # wait for status "killed" if nothing else
	    if (defined(open IN,"< $statusfile")) {
		read IN,$status,9;
		close IN;
		# note: $status could also be "error", "video_ended"
		# or "audio_ended" in which case we leave it there
		exit 1;
	    }
	 
	    if ($wait_for_pid==-1) {
		exit 1;
d118 4
d123 1
a455 1
	unlink "$curtmpdir/pause";
a464 1
	unlink "$curtmpdir/pause";
a497 1
	unlink "$curtmpdir/pause";
a618 1
	    unlink "$curtmpdir/pause";
a661 1
	    unlink "$curtmpdir/pause";
d1117 1
a1150 1
	unlink "$curtmpdir/pause";
a1332 1
	unlink "$curtmpdir/pause";
a1350 1
	unlink "$curtmpdir/pause";
a1365 1
	unlink "$curtmpdir/pause";
d1595 1
a1595 1
	    unlink "$curtmpdir/pause";
a1643 13


    if ($command eq "keep") {
	unlink "$curtmpdir/pause";
	system("smogrify cancel_hup $handle");
	$start=$ARGV[2];
	$end=$ARGV[3];
	&mv_mgk;
	&sig_complete;
	exit 0;
    }


a1734 1
	unlink "$curtmpdir/pause";
d1749 1
d1873 1
a1917 1

a1949 1
	unlink "$curtmpdir/pause";
d1964 1
a1964 1
	if ($command eq "mv_mgk") {
a1975 1
	unlink "$curtmpdir/pause";
a2019 1
	unlink "$curtmpdir/pause";
a2077 1
	unlink "$curtmpdir/pause";
a2104 1
	unlink "$curtmpdir/pause";
a2117 1
	unlink "$curtmpdir/pause";
a2154 1
	unlink "$curtmpdir/pause";
d2202 1
a2203 1
	# remove any gaps in the play images
a2243 1
	unlink "$curtmpdir/pause";
a2301 1
	unlink "$curtmpdir/pause";
a2311 1
	unlink "$curtmpdir/pause";
a2347 1
	unlink "$curtmpdir/pause";
a2373 1
	unlink "$curtmpdir/pause";
d2531 1
d2627 1
@


1.169
log
@more fixes
@
text
@d4185 1
a4185 1
	system("$convert_command \"$file\" -resize $hsize"."!x"."$vsize! $curtmpdir/$name$img_ext >/dev/null");
@


1.168
log
@various fixes
@
text
@d4185 1
a4185 1
	system("$convert_command \"$file\" -resize $hsize"."!x"."$vsize! $curtmpdir/$name$img_ext >/dev/nu");
@


1.167
log
@updates
@
text
@a70 19
    if ($command eq "stopsub") {
	# kill all subprocesses
	$ppid=$ARGV[1];
	chdir $tmpdir;
	`pgrep -g $ppid > .pids.$ppid`;
	if (!defined(open IN,".pids.$ppid")) {
	    exit 2;
	}
	while (<IN>) {
	    $pid=$_;
	    if ($pid!=$ppid) {
		`kill -9 $pid`;
	    }
	}
	close IN;
	unlink ".pids.$ppid";
	exit 0;
    }

d72 1
a72 1
    if ($command eq "cancel_hup"||$command eq "stop") {
d98 16
a113 2
		if ($command eq "cancel_hup") {
		    system("kill -HUP $target_pid 2>/dev/null");
d115 1
d117 1
a117 1
		    system("kill -9 $target_pid 2>/dev/null");
d119 1
a1110 1
	    #fork into 2, one for video, one for audio
d2857 15
a2871 1

d4185 1
a4185 1
	system("$convert_command \"$file\" -resize $hsize"."!x"."$vsize! $curtmpdir/$name$img_ext");
d4710 1
a4710 1
	`pkill -9 -g $ppid -f $audio_play_command`;
@


1.166
log
@fix mplayer audio playback
@
text
@d2829 1
a2829 1
    my ($num)=@@_;
a2854 4
    #my $target_pid=@@_;    #this doesnt seem to work - not sure why



d2866 1
a2866 1
    my $file=@@_;
d2890 1
a2890 1
    my ($option)=@@_;
d2925 1
a2925 1
    my ($param)=@@_;
d3312 1
a3312 1
    my ($file)=@@_;
a3543 1

d4048 1
a4048 1
    my ($guess)=@@_;
d4090 1
a4090 1
    my ($i)=@@_;
d4149 1
a4149 1
    my ($i)=@@_;
d4168 3
d4175 1
a4175 1
	system("$convert_command \"$file\" -resize $hsize"."!x"."$vsize! $curtmpdir/$name$img_ext > /dev/null 2>&1");
d4208 1
a4208 1
    my ($file)=@@_;
d4501 1
a4501 1
    my ($string)=@@_;
d4706 1
a4706 1
    my ($command)=@@_;
d4817 1
a4817 1
    my ($key)=@@_;
d4893 1
a4893 1
    my ($exe)=@@_;
d4943 1
a4943 1
    my ($key)=@@_;
d5036 1
a5036 1
    my ($string)=@@_;
d5053 1
a5053 1
    my ($plugin)=@@_;
@


1.165
log
@updates
@
text
@d91 1
a91 1
    if ($command eq "cancel"||$command eq "cancel_hup"||$command eq "stop"||$command eq "stop_pb") {
d94 1
a94 6
	if ($command eq "stop_pb") {
	    $pidfile="$curtmpdir/.pidpb";
	}
	else {
	    $pidfile="$curtmpdir/.pid";
	}
a119 5
		elsif ($command eq "stop") {
		    $target_pid=&get_pgid;
		    system("kill -HUP -$target_pid 2>/dev/null");
		    &stop_audio;
		}
d158 1
d1112 1
a1112 1
		$syscom2="$audio_play_command -rawaudio rate=$arate :channels=$achans:samplesize=$asamps $mute $audiofile -ss ".($audio_start-1);
d3639 1
a3639 1
	system(&rc_get("video_open_command") . " -quiet -ao pcm -rawaudio rate=$arate:channels=$achans:samplesize=$aasamps -waveheader $format -vo null $audio_in >/dev/null 2>&1 </dev/null");
d4700 1
a4700 1
    if ($aplayer eq "sox"||$player eq "mplayer") {
d4702 1
a4702 1
	`if pgrep -s 0 -f $audio_play_command; then pkill -9 -s 0 -f $audio_play_command; fi`;
@


1.164
log
@bugfixes
@
text
@d37 1
a37 1
$version="0.9.8.8";
@


1.163
log
@fix lv2 import, update po
@
text
@d37 1
a37 1
$version="0.9.9-cvs";
d71 20
d121 1
a121 1
		#print "Attempting to stop process ".$target_pid."\n";
a948 1
    else {
a952 2
    }

d1595 1
a1595 1
		    $fields=@@ARGV[13..$#ARGV];
d3643 1
a3646 1
	my ($aasamps)=$asamps/8;
@


1.162
log
@fs_preview fixes
@
text
@d873 1
a873 1
	    my $out=`tar --exclude=*/* -tjf $proj_file`;
d2786 1
a2786 1
	    `tar --exclude=*.bak --exclude=.pid* --exclude=lock.* --exclude=*.mgk --exclude=*.tmp --exclude=audioclip* -czf \"$proj_file\" $set`;
@


1.161
log
@various bugfixes
@
text
@d461 1
a463 1
	$curtmpdir="$tmpdir/$handle";
d471 1
a473 1
	$curtmpdir="$tmpdir/$handle";
@


1.160
log
@bugfix
@
text
@d71 1
a71 1
    if ($command eq "cancel"||$command eq "cancel_hup"||$command eq "stop") {
d74 6
a79 1
	$pidfile="$curtmpdir/.pid";
d118 1
a449 21
    if ($command eq "get_details") {
	$handle=$ARGV[1];
	$curtmpdir="$tmpdir/$handle";
	$statusfile="$curtmpdir/.status";
	unlink "$curtmpdir/pause";

	#attempt to get file details
	$file=$ARGV[2];
	$only_first=1;

	if (defined($ARGV[3])) {
	    $is_remote=$ARGV[3];
	}
	if (defined($ARGV[4])) {
	    $is_audio=$ARGV[4];
	}
	&get_file_info;
	&sig_complete($handle,$count,$type,$hsize,$vsize,$bpp,$fps,$f_size,$arate,$achans,$asamps,$signed,$endian,$af_size,$title,$author,$comment);
	exit 0;
    }

d904 7
a910 1
    $pidfile=$curtmpdir."/.pid";
d1169 2
a1170 1
	$mplay_command=&rc_get("video_open_command");
d1344 22
d2786 1
a2786 1
	    `tar --exclude=*.bak --exclude=.pid --exclude=lock.* --exclude=*.mgk --exclude=*.tmp --exclude=audioclip* -czf \"$proj_file\" $set`;
@


1.159
log
@remote stream fixes
@
text
@d2663 1
@


1.158
log
@fs preview improvements pt 1
@
text
@a1163 1
		    $extra_params="";
d1167 1
d1195 4
d1237 2
d3352 1
a3352 1
    if (defined($is_remote)&&($is_remote==1)) {
d3354 1
a3354 1
	system("$mplay_command -identify -v -vo null -ao null -frames 0 -cache 32 \"$file\">$file_ident 2>/dev/null </dev/null");
d3357 1
a3357 1
	system("$mplay_command -identify -v -vo null -ao null -frames 0 \"$file\">$file_ident 2>/dev/null </dev/null");
d3470 3
d4574 1
d4679 1
a4679 1
	`pkill -9 -s 0 -f $audio_play_command`;
d4844 6
@


1.157
log
@deinterlace on open, part 1
@
text
@d1971 1
a1971 1
	system("$mplayer_command -quiet -x $hsize -y $vsize -wid $win -ss $start_time -frames $preview_frames \"$file\" $extra_params >/dev/null 2>&1 </dev/null");
@


1.156
log
@various fixes
@
text
@a289 1

d4807 6
a4812 1
		$string.=$_;
@


1.155
log
@various fixes
@
text
@d4670 1
a4670 1
	`pkill -9 -s 0 -f $audio_play_command >/dev/null 2>&1`;
@


1.154
log
@rendered generators part 5
@
text
@d866 1
a866 1
	    $prefix_dir=&rc_get("prefix_dir");
d4983 1
a4983 1
	    unless (location("build-lives-plugin-multi") eq "") {
@


1.153
log
@rendered gens more updates
@
text
@d2683 2
d2717 1
a2717 1
		    &sig_complete($nwidth,$nheight,$frames);
d4670 1
a4670 1
	system("pkill -9 -s 0 -f $audio_play_command >/dev/null 2>&1");
@


1.152
log
@rendered generators pt 1
@
text
@a1011 6
	    if ($asamps==1) {
		$stype="b";
	    }
	    if ($asamps==2) {
		$stype="w";
	    }
d1099 1
d1101 7
a1107 1
		    $syscom2="$audio_play_command $mute -c $achans -r $arate -f $signed $aendian -t $aformat -s $stype $audiofile $trimcom $audio_effect";
d1110 1
a1110 1
		    $syscom2="$audio_play_command $mute -c $achans -r $arate -$signed $aendian -t $aformat -$stype $audiofile $trimcom $audio_effect";
d3600 2
d3609 12
a3620 2
	if ($asamps==8) {
	    $sasamps="b";
d3623 1
a3623 1
	    $sasamps="w";
d3625 2
a3626 1
	
d3714 2
d3718 2
a3719 5
    if ($asamps==8) {
	$osamps="b";
    }
    else {
	$osamps="w";
d3722 15
a3736 3
    
    if ($nsamps==8) {
	$nsamps="b";
d3739 2
a3740 1
	$nsamps="w";
@


1.151
log
@advanced encoders pt 4
@
text
@d2678 4
d2706 1
d2708 7
a2714 2
		    &mv_mgk;
		    &sig_complete($nwidth,$nheight);
d4615 9
a4623 1
    my ($frames)=@@_;
d4626 1
a4626 1
    print OUT $frames;
d4798 4
a4801 2
    $handle=$ARGV[1];
    $curtmpdir="$tmpdir/$handle";
@


1.150
log
@advanced encoders pt 1
@
text
@d1558 1
@


1.149
log
@updates
@
text
@d64 5
d869 3
a871 10
	    $status=$ARGV[1];
	    if ($status==0) {
		$plugin_name="$prefix_dir/share/lives/plugins/effects/rendered/$command";
	    }
	    elsif ($status==1) {
		$plugin_name="$home/.lives-dir/plugins/effects/rendered/custom/$command";
	    }
	    else {
		$plugin_name="$home/.lives-dir/plugins/effects/rendered/test/$command";
	    }
d873 1
d1415 7
d1429 1
a1429 1
	    unless (&is_writeable($nfile)) {
d1475 1
d1483 1
a1483 1
	    $areq=&get_form_request($plugin);
d1485 30
a1514 21
	    #prepare audio stream if requested
	    if (-f "$curtmpdir/audio" && $arate>0) {
		$origaudio=$audiofile=$audio_in="$curtmpdir/audio";
		if ($areq&1||$aud_start!=0.) {
		    
		    # encode sound up to the next nearest second
		    # seems to be the norm...
		    $aud_length=($aud_end-$aud_start);
		    $aud_length=int($aud_length+1.0);
		    $aud_end=$aud_start+$aud_length;
				    
		    # clip the (raw) audio
		    $audiofile=$audio_in=&clip_audio($aud_start,$aud_end);

		    #pad to end with silence
		    $desired_length=$aud_length*$arate*$achans*$asamps/8;
		    &append_silence($desired_length,$audiofile);

		    if ($aud_start!=0.&&!($areq&1)) {
			if (&rc_get("conserve_space") eq "true") {
			    `/bin/rm -f $origaudio`;
d1516 7
a1522 5
			else {
			    rename "$origaudio","$origaudio.origbak";
			}
			rename "$curtmpdir/$audiofile","$origaudio";
			$audio_file=$audio_in=$origaudio;
d1525 13
a1537 20
		if ($areq&2) { 
		    # convert raw audio to wav
		    $audio_out=$curtmpdir . "/audiodump.wav";
		    &convert_audio_to_wav;
		    unlink $audio_in;
		    $audiofile=$audio_out;
		}
	    }

	    if ($areq&4) {
		#move the selection down so that frames start at 1
		if ($start>1) {
		    for ($i=1;$i<=($end-$start+1);$i++) {
			$name=&mkname($i);
			$from=&mkname($i+$start-1);
			if (-f "$name$img_ext") {
			    rename "$name$img_ext","$name.ign";
			}
			if (-f "$from$img_ext") {
			    system ("/bin/ln -sf $from$img_ext $name$img_ext");
d1541 1
d1557 6
a1562 1
		system("$plugin encode $fields");
d1580 6
a1585 1
	    $command="encode";
d3317 4
a3320 1
    $mplay_command=&rc_get("video_open_command");
@


1.148
log
@updates
@
text
@a528 2
	    $frames=-2;
	    
d546 1
a546 1
		if (!($nfile eq "")) {
d548 1
a548 12
		    
		    if (-f "audio") {
			$frames--;
		    }
		    if (-f "header") {
			$frames--;
		    }
		    
		    opendir DIR,$curtmpdir;
		    @@length=readdir(DIR);
		    $frames+=scalar(@@length);
		    closedir DIR;
d883 1
a883 17
	    my $count=0,$gap=1;
	    $handle=$ARGV[1];
	    $curtmpdir="$tmpdir/$handle";
	    while (1) {
		$name=&mkname($count+$gap);
		if (-f "$curtmpdir/$name$img_ext") {
		    $count+=$gap;
		    $gap*=2;
		}
		else {
		    if ($gap==1) {
			last;
		    }
		    $gap/=2;
		}
	    }
	    print $count;
d1258 1
a1258 18
	    $found=0;
	    for ($i=$count;$i>0&&$found==0;$i--) {
		$name=&mkname($i);
		if (-f "$name$img_ext") {
		    $found=$i;
		}
	    }

	    if ($count==$found) {
		#check for extra frames
		for ($i=$count+1;$found==$i-1;$i++) {
		    $name=&mkname($i);
		    if (-f "$name$img_ext") {
			$found=$i;
		    }
		}
	    }
	    $count=$found;
a1259 9
	    unless ($type eq "Frames"||$count>0) {
		opendir DIR,$curtmpdir;
		while ($file=readdir(DIR)) {
		    if ($file =~ /$img_ext$/) {
			$count++;
		    }
		}
		closedir DIR;
	    }
d1321 3
a1332 7
	# if we were interrupted, the last frame can have 0 size, if so delete it
	$name=&mkname($count);
	unless (-s "$name$img_ext") {
	    unlink "$name$img_ext";
	    $count--;
	}

d4749 28
@


1.147
log
@mplayer rawadio syntax changed
@
text
@d3462 8
d3610 1
a3610 1
	system("sox -t .wav $audio_in -t .raw $xsigned $audio_out > /dev/null 2>&1");
@


1.146
log
@update to gpl 3; other fixes
@
text
@d1143 1
a1143 1
		$syscom2="$audio_play_command -rawaudio on:rate=$arate :channels=$achans:samplesize=$asamps $mute $audiofile -ss ".($audio_start-1);
d3618 1
a3618 1
	system(&rc_get("video_open_command") . " -quiet -ao pcm -rawaudio on:rate=$arate:channels=$achans:samplesize=$aasamps -waveheader $format -vo null $audio_in >/dev/null 2>&1 </dev/null");
@


1.145
log
@fixes
@
text
@d3 2
a4 2
# smogrify - Copyright G. Finch 2003 - 2005
# Released under the GPL 2.0 - see file COPYING or www.gnu.org for details
@


1.144
log
@multi file open part 2
@
text
@d66 1
a66 1
    if ($command eq "cancel"||$command eq "cancel_hup") {
d95 5
a135 5
    if ($command eq "stop") {
	&stop;
	exit 0;
    }

d2848 14
a4644 6
sub stop {
    system("pkill -HUP -s 0 -g -f smogrify >/dev/null 2>&1");
    &stop_audio;
}


@


1.143
log
@update
@
text
@d273 3
d1182 1
@


1.142
log
@update
@
text
@d1133 1
a1133 1
		    $syscom2=$audio_play_command." -c " . $achans . " -r " . $arate . " -f $signed $aendian -t $aformat -s " . $stype . " " . $audiofile . $mute . $trimcom . " $audio_effect";
d1136 1
a1136 1
		    $syscom2="$audio_play_command -c $achans -r $arate -$signed $aendian -t $aformat -$stype $audiofile $mute $trimcom $audio_effect";
a3642 2
#	system("sox -t raw -r $arate $asigned -$sasamps -c $achans $aendian $audio_in -t .wav -r $nrate -c $nchans $nsigned -$nasamps $nendian $curtmpdir/audiodump.wav > /dev/null 2>&1");

d3743 1
a3743 1
	system("sox -t .raw -r $arate -c $achans $osigned -$osamps $oendian $audio_in -t .raw -r $nrate -c $nchans $nsigned $nendian -$nsamps $audio_out stretch $stretch>/dev/null 2>&1");
d3746 1
a3746 1
	system("sox -t .raw -r $arate -c $achans $osigned -$osamps $oendian $audio_in -t .raw -r $nrate -c $nchans $nsigned $nendian -$nsamps $audio_out>/dev/null 2>&1");
@


1.141
log
@sox 13.x.x compatibility
@
text
@d4630 1
a4630 1
    system("pkill -HUP -s -g -f smogrify >/dev/null 2>&1");
@


1.140
log
@shrink_expand fix
@
text
@d1040 1
a1040 1
		$stype="-b";
d1043 1
a1043 1
		$stype="-w";
d1131 7
a1137 2
#		$syscom2=$audio_play_command." -c " . $achans . " -r " . $arate . " -f $signed $aendian -t $aformat -s " . $stype . " " . $audiofile . $mute . $trimcom . " $audio_effect";
		$syscom2="$audio_play_command -c $achans -r $arate -$signed $aendian -t $aformat $stype $audiofile $mute $trimcom $audio_effect";
a3583 1
#	system("sox -t wav $audio_in -t raw $xsigned $audio_out > /dev/null 2>&1");
d5015 12
@


1.139
log
@sox fixes, rfx preview fixes
@
text
@a3138 3
    # crop area around center, then expand it, then crop to exact size
    # TODO - optimise this if possible

d3140 1
a3140 1
	system("$convert_command +antialias -size $width"."x$height $name$input_ext -crop $nwidth" . "!x" . $nheight . "!+" . $left . "+" . $top . " $name$resize_ext >/dev/null 2>&1");
d3143 1
a3143 1
	system("$convert_command +antialias -size $width"."x$height $name$input_ext -crop $nwidth" . "!x" . $nheight . "!+" . $left . "+" . $top . " $name.$resize_ext >/dev/null 2>&1");
a3145 5
    system("$convert_command -size $nwidth"."x$nheight $name$resize_ext -resize ".int($nwidth*$rscale)."!x".int($nheight*$rscale)."! $name.tmp >/dev/null 2>&1");
    
    system("$convert_command -size ".int($nwidth*$rscale)."x".int($nheight*$rscale)." $name.tmp -crop $width" . "!x" . $height . "!+" . int((int($nwidth*$rscale)-$width-.5)/2) . "+" . int((int($nheight*$rscale)-$height-.5)/2) . " $name$resize_ext >/dev/null 2>&1");

    unlink "$name.tmp";
@


1.138
log
@fix image opening (again)
@
text
@d1040 1
a1040 1
		$stype="b";
d1043 1
a1043 1
		$stype="w";
d1061 1
a1061 1
	    $aformat="wav";
d1065 1
a1065 1
	    $aformat="raw";
d1131 2
a1132 1
		$syscom2=$audio_play_command." -c " . $achans . " -r " . $arate . " -f $signed $aendian -t $aformat -s " . $stype . " " . $audiofile . $mute . $trimcom . " $audio_effect";
d1135 1
a1135 1
		$syscom2=$audio_play_command . " -rawaudio on:rate=" . $arate . ":channels=" . $achans . ":samplesize=" . $asamps . " " . $mute . " " . $audiofile . " -ss ".($audio_start-1);
d1147 1
a1147 1
		if ($retval!=0) {
d3587 2
a3588 1
	system("sox -t wav $audio_in -t raw $xsigned $audio_out > /dev/null 2>&1");
d3647 1
d3649 1
a3649 1
	system("sox -t raw -r $arate $asigned -$sasamps -c $achans $aendian $audio_in -t wav -r $nrate -c $nchans $nsigned -$nasamps $nendian $curtmpdir/audiodump.wav > /dev/null 2>&1");
d3721 1
a3721 1
	$osigned="-s";
d3724 1
a3724 1
	$osigned="-u";
d3728 1
a3728 1
	$nsigned="-s";
d3731 1
a3731 1
	$nsigned="-u";
d3749 1
a3749 1
	system("sox -t raw -r $arate -c $achans $osigned -$osamps $oendian $audio_in -t raw -r $nrate -c $nchans $nsigned $nendian -$nsamps $audio_out stretch $stretch>/dev/null 2>&1");
d3752 1
a3752 1
	system("sox -t raw -r $arate -c $achans $osigned -$osamps $oendian $audio_in -t raw -r $nrate -c $nchans $nsigned $nendian -$nsamps $audio_out>/dev/null 2>&1");
d4634 1
a4634 9
# find better way to stop processes
    $uname=`uname`;
    chomp($uname);
    if ($uname eq "OpenBSD"||$uname eq "NetBSD") {
	system("pkill -HUP -g smogrify >/dev/null 2>&1");
    }
    else {
	system("killall -HUP -g smogrify >/dev/null 2>&1");
    }
d4640 4
a4643 9
    if (&rc_get("audio_player") eq "sox") {
	$uname=`uname`;
	chomp($uname);
	if ($uname eq "OpenBSD"||$uname eq "NetBSD") {
	    system("pkill -9 sox >/dev/null 2>&1");
	}
	else {
	    system("killall -9 sox >/dev/null 2>&1");
	}
@


1.137
log
@fix set locking 2
@
text
@d3521 1
a3521 1
			unlink <*$img_ext>;
d3535 1
d4038 1
d4060 1
a4060 1
	    unless ($_ =~ /^\./) {
d4068 1
d4087 1
a4120 2


d4139 4
@


1.136
log
@updates
@
text
@d760 1
a760 1
			    print $proc;
@


1.135
log
@updates
@
text
@a3337 2
    my $line;

d3353 1
a3353 1
	open MPLAYER, '$mplay_command -identify -v -vo null -ao null -frames 0 -cache 32 \"$file\"2>/dev/null </dev/null |';
d3356 1
a3356 1
	open MPLAYER, '$mplay_command -identify -v -vo null -ao null -frames 0 \"$file\" 2>/dev/null </dev/null |';
d3359 4
a3362 1
    my @@output=<MPLAYER>;
d3364 5
a3368 25
    close MPLAYER;

    print @@output;

    $line=(grep /^ID_VIDEO_CODEC/,@@output)[0];
    chomp($line);
    print "line is $line\n";
    $id_vid_form=(split("=",$line))[1];

    if ($id_vid_form eq "") {
	$line=(grep /^ID_VIDEO_FORMAT/,@@output)[0];
	chomp($line);
	$id_vid_form=(split("=",$line))[1];
    }

    if ($id_vid_form eq "") {
	$line=(grep /^VIDEO/,@@output)[0];
	chomp($line);
	$id_vid_form=(split("=",$line))[1];
    }


    $line=(grep /^ID_AUDIO_FORMAT/,@@output)[0];
	 chomp($line);
	$id_aud_form=(split("=",$line))[1];
d3370 10
d3382 4
a3385 3
	    $line=(grep /^AUDIO:/,@@output)[0];
	 chomp($line);
	$id_aud_form=(split("=",$line))[1];
d3387 1
a3387 1
	}
a3394 7
	if ($id_aud_form eq "") {
	    $line=(grep /^AUDIO:/,@@output)[0];
	 chomp($line);
	$id_aud_form=(split(" ",$line))[5];

	}

d3399 4
d3413 4
a3416 7
	    $line=(grep /^VIDEO:/,@@output)[0];
	 chomp($line);
	$bpp=(split(" ",$line))[3];

	}


d3418 1
d3420 2
a3421 3
	    $line=(grep /^VIDEO:/,@@output)[0];
	      chomp($line);
		@@tmp=split(" ",$line);
d3425 14
a3438 3
	    $line=(grep /^ID_VIDEO_WIDTH:/,@@output)[0];
            chomp($line);
	    $hsize=(split("=",$line))[1];
d3440 9
a3448 3
	    $line=(grep /^ID_VIDEO_HEIGHT:/,@@output)[0];
            chomp($line);
	    $vsize=(split("=",$line))[1];
d3450 4
a3453 18

	    $line=(grep /^ID_VIDEO_FPS:/,@@output)[0];
            chomp($line);
	    $fps=(split("=",$line))[1];


	    $line=(grep /^ID_AUDIO_RATE:/,@@output)[0];
            chomp($line);
	    $arate=(split("=",$line))[1];


	    $line=(grep /^ID_AUDIO_NCH:/,@@output)[0];
            chomp($line);
	    $achans=(split("=",$line))[1];

	    $line=(grep /^ID_AUDIO_BITRATE:/,@@output)[0];
            chomp($line);
	    $abitrate=(split("=",$line))[1];
d3457 1
a3457 1
		$adets=(grep /^AUDIO:/,@@output)[0];
d3464 2
a3465 1
	    $comment=(grep /^Comments:/,@@output)[0];
d3471 2
a3472 2

	    $title=(grep /^Title:/,@@output)[0];
d3478 2
a3479 2

	    $author=(grep /^Author:/,@@output)[0];
a3484 1

d3486 1
a3486 2

	    $count=(grep /frames total/,@@output)[0];
d3492 1
a3492 2

		$length=(grep /ID_LENGTH:/,@@output)[0];
d3504 3
a3506 1

@


1.134
log
@fix set locking
@
text
@d3338 2
d3355 1
a3355 1
	system("$mplay_command -identify -v -vo null -ao null -frames 0 -cache 32 \"$file\">$file_ident 2>/dev/null </dev/null");
d3358 24
a3381 1
	system("$mplay_command -identify -v -vo null -ao null -frames 0 \"$file\">$file_ident 2>/dev/null </dev/null");
a3383 4
    if (-f $file_ident) {
        $id_vid_form=`grep ID_VIDEO_CODEC $file_ident 2>/dev/null`;
        $id_vid_form=(split("=",(split("\n",$id_vid_form))[0]))[1];
        chomp($id_vid_form);
d3385 3
a3387 5
	if ($id_vid_form eq "") {
	    $id_vid_form=`grep ID_VIDEO_FORMAT $file_ident 2>/dev/null`;
	    $id_vid_form=(split("=",(split("\n",$id_vid_form))[0]))[1];
	    chomp($id_vid_form);
	}
a3388 10
	if ($id_vid_form eq "") {
	    $id_vid_form=`grep VIDEO: $file_ident 2>/dev/null`;
	    $id_vid_form=(split("  ",(split("\n",$id_vid_form))[0]))[1];
	    chomp($id_vid_form);
	}
	if (! -f $file_ident) {return;};

	$id_aud_form=`grep ID_AUDIO_FORMAT $file_ident 2>/dev/null`;
	$id_aud_form=(split("=",(split("\n",$id_aud_form))[0]))[1];
	chomp($id_aud_form);
d3391 4
a3394 3
	    $id_aud_form=`grep AUDIO: $file_ident 2>/dev/null`;
	    $id_aud_form=(split("  ",(split("\n",$id_aud_form))[0]))[1];
	    chomp($id_aud_form);
a3396 2
	if (! -f $file_ident) {return;};

d3403 7
a3413 4
	    if (! -f $file_ident) {return;};
	    $asamps=`grep AUDIO: $file_ident 2>/dev/null`;
	    $asamps=(split(" ",$asamps))[5];
	    chomp($asamps);
d3424 7
a3430 4
	    if (! -f $file_ident) {return;};
	    $bpp=`grep VIDEO: $file_ident 2>/dev/null`;
	    $bpp=(split("bpp",(split("  ",$bpp))[3]))[0];
	    chomp($bpp);
a3431 1
	    if (! -f $file_ident) {return;};
d3433 3
a3435 2
		$bpp=`grep \"Image size:\" $file_ident 2>/dev/null`;
		@@tmp=split(" ",$bpp);
d3439 18
a3456 14
	    if (! -f $file_ident) {return;};
	    $hsize=`grep ID_VIDEO_WIDTH $file_ident 2>/dev/null`;
	    $hsize=(split("=",(split("\n",$hsize))[0]))[1];
	    chomp($hsize);
	    
	    if (! -f $file_ident) {return;};
	    $vsize=`grep ID_VIDEO_HEIGHT $file_ident 2>/dev/null`;
	    $vsize=(split("=",(split("\n",$vsize))[0]))[1];
	    chomp($vsize);
	    
	    if (! -f $file_ident) {return;};
	    $fps=`grep ID_VIDEO_FPS $file_ident 2>/dev/null`;
	    $fps=(split("=",(split("\n",$fps))[0]))[1];
	    chomp($fps);
d3458 3
a3460 9
	    if (! -f $file_ident) {return;};
	    $arate=`grep ID_AUDIO_RATE $file_ident 2>/dev/null`;
	    $arate=(split("=",(split("\n",$arate))[0]))[1];
	    chomp($arate);
	    
	    if (! -f $file_ident) {return;};
	    $achans=`grep ID_AUDIO_NCH $file_ident 2>/dev/null`;
	    $achans=(split("=",(split("\n",$achans))[0]))[1];
	    chomp($achans);
d3462 3
a3464 4
	    if (! -f $file_ident) {return;};
	    $abitrate=`grep ID_AUDIO_BITRATE $file_ident 2>/dev/null`;
	    $abitrate=(split("=",(split("\n",$abitrate))[0]))[1];
	    chomp($abitrate);
d3468 1
a3468 1
		$adets=`grep AUDIO: $file_ident 2>/dev/null`;
d3475 1
a3475 2
	    if (! -f $file_ident) {return;};
	    $comment=`grep Comments: $file_ident 2>/dev/null`;
d3481 2
a3482 2
	    if (! -f $file_ident) {return;};
	    $title=`grep Title: $file_ident 2>/dev/null`;
d3488 2
a3489 2
	    if (! -f $file_ident) {return;};
	    $title=`grep Author: $file_ident 2>/dev/null`;
d3495 1
d3497 2
a3498 1
	    $count=`grep \"frames  total\" $file_ident 2>/dev/null`;
d3504 2
a3505 1
                $length=`grep ID_LENGTH $file_ident 2>/dev/null`;
d3517 1
a3517 3
	unlink $file_ident;
    }
   }
@


1.133
log
@updates
@
text
@d746 1
d753 11
a763 6
		    my $exe=`readlink -n /proc/$1/exe`;
		    my $short_exe=&my_basename($exe);
		    if ($short_exe eq $exename) {
			# and it's in use
			closedir DIR;
			exit 1;
a764 1
		    unlink "$tmpdir/$setname/$file";
a802 1

@


1.132
log
@multitrack updates
@
text
@d37 1
a37 1
$version="0.9.8.5";
@


1.131
log
@updates
@
text
@d37 1
a37 1
$version="0.9.9-cvs";
d2436 1
a2436 1
		$count=scalar(@@length)-2;
d2440 1
a2440 1
		    $filetoplay=int(rand $count)+2;
d2444 3
a2446 1
			$dir="$dir$file/";
a2447 1

a2455 1
				$found=1;
a2462 4
				$dir=$origdir;
			    }
			    else {
				$dir=$origdir;
d2465 1
a2465 3
			else {
			    $dir=$origdir;
			}
d2469 1
a2469 1
		    $dir=$origdir;
@


1.130
log
@updates and fixes
@
text
@d1130 1
a1130 1
		$syscom2=$audio_play_command . " -rawaudio on:rate=" . $arate . ":channels=" . $achans . ":samplesize=" . $asamps . " " . $mute . " " . $audiofile . " -ss ".($audio_start-1)." 2>&1";
d1140 7
a1146 1
		system($syscom2);
d1228 1
a1228 1
		    $syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo jpeg:quality=$quality -fps 100000 $ss $frames -vf scale -noframedrop -ao null \"$file\" $extra_params > $curtmpfile 2>/dev/null </dev/null";
d1231 1
a1231 1
		    $syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo png:z=$compression -fps 100000 $ss $frames -vf scale -noframedrop -ao null \"$file\" $extra_params > $curtmpfile 2>/dev/null </dev/null";
d1236 1
a1236 1
		    $syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo jpeg:quality=$quality $ss -noframedrop $frames -ao pcm $channs -vf scale -mc 0  \"$file\" $extra_params > $curtmpfile 2>/dev/null </dev/null";
d1239 1
a1239 1
		    $syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo png:z=$compression $ss -noframedrop $frames -ao pcm $channs -vf scale -mc 0  \"$file\" $extra_params > $curtmpfile 2>/dev/null </dev/null";
d1247 3
a1249 1
	    system($syscom);
d1332 1
a1332 1
	    if ($f_size>0) {
d1338 6
a1343 1
		&sig_error("This does not appear to be a valid video or image file","$GUI_NAME was unable to open it.");
@


1.129
log
@update smogrify
@
text
@d1127 1
a1127 1
		$syscom2=$audio_play_command." -c " . $achans . " -r " . $arate . " -f $signed $aendian -t $aformat -s " . $stype . " " . $audiofile . $mute . $trimcom . " $audio_effect  >/dev/null 2>&1";
d1130 1
a1130 1
		$syscom2=$audio_play_command . " -rawaudio on:rate=" . $arate . ":channels=" . $achans . ":samplesize=" . $asamps . " " . $mute . " " . $audiofile . " -ss ".($audio_start-1)." >/dev/null 2>&1";
@


1.128
log
@fixes
@
text
@d1222 1
a1222 1
		    $syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo jpeg:quality=$quality -fps 100000 $ss $frames -vf scale -noframedrop -ao null \"$file\" $extra_params > $curtmpfile 2>/dev/null</dev/null";
d1225 1
a1225 1
		    $syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo png:z=$compression -fps 100000 $ss $frames -vf scale -noframedrop -ao null \"$file\" $extra_params > $curtmpfile 2>/dev/null</dev/null";
d1230 1
a1230 1
		    $syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo jpeg:quality=$quality $ss -noframedrop $frames -ao pcm $channs -vf scale -mc 0  \"$file\" $extra_params > $curtmpfile 2>/dev/null</dev/null";
d1233 1
a1233 1
		    $syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo png:z=$compression $ss -noframedrop $frames -ao pcm $channs -vf scale -mc 0  \"$file\" $extra_params > $curtmpfile 2>/dev/null</dev/null";
d1980 1
a1980 1
	system("$mplayer_command -quiet -x $hsize -y $vsize -wid $win -ss $start_time -frames $preview_frames \"$file\" $extra_params >/dev/null 2>&1</dev/null");
d3342 1
a3342 1
	system("$mplay_command -identify -v -vo null -ao null -frames 0 -cache 32 \"$file\">$file_ident 2>/dev/null</dev/null");
d3345 1
a3345 1
	system("$mplay_command -identify -v -vo null -ao null -frames 0 \"$file\">$file_ident 2>/dev/null</dev/null");
d3590 1
a3590 1
	system(&rc_get("video_open_command") . " -quiet -ao pcm -rawaudio on:rate=$arate:channels=$achans:samplesize=$aasamps -waveheader $format -vo null $audio_in >/dev/null 2>&1</dev/null");
d4359 1
a4359 1
    system("$mplay_command -frames 0 $audio_in > $curtmpfile 2>/dev/null</dev/null");
d4396 1
a4396 1
    system(&rc_get("video_open_command") . " -quiet \"$file\" -ao pcm:waveheader:file=$audio_in $format >/dev/null 2>&1</dev/null");
@


1.127
log
@support multiframe images
@
text
@d3270 8
a3277 1
	system("$composite_command -compose plus -dissolve $pc_start -geometry $width!x$height!+$x!+$y! $fromimg $curtmpdir/$name$img_ext $toimg >/dev/null 2>&1");
@


1.126
log
@updates
@
text
@d3503 1
a3503 1
			unlink "$curtmpdir/$file2";
d4045 1
a4045 1
		&open_single_image($i);
a4046 1
		    $i++;
d4050 3
d4072 1
d4074 1
d4076 1
d4078 3
a4080 1
    my ($file_ext)=&get_ext($file);
d4086 1
a4086 1
	return;
d4098 17
d4118 3
@


1.125
log
@updates
@
text
@d1924 1
a1924 1
	    unlink <* *.>;
@


1.124
log
@fix crash with non div 4 frames
@
text
@d1858 7
d1872 1
a1872 1
	&undo(1);
d1876 10
a1885 1
	    unlink "$name$img_ext";
a1886 2

	&clean_old;
@


1.123
log
@valgrind fixes, etc
@
text
@d889 1
a889 1
	    my $count=1,$gap=1;
d893 1
a893 1
		$name=&mkname($count);
d905 1
a905 1
	    print $count-1;
@


1.122
log
@OSC updates, general updates
@
text
@d889 1
a889 1
	    my $count;
d892 11
a902 4
	    for ($count=0;;$count++) {
		$name=&mkname($count+1);
		unless (-f "$curtmpdir/$name$img_ext") {
		    last;
d905 1
a905 1
	    print $count;
@


1.121
log
@updates
@
text
@d270 2
d4856 3
@


1.120
log
@updates
@
text
@d4855 1
a4855 1
	    $current_keymap=`grep \"keymap file version 2\" $lives_home_dir$default_keymap 2>/dev/null`;
@


1.119
log
@updates
@
text
@d1778 4
d1826 1
d1830 10
a1839 1
	&sig_complete(--$count);
@


1.118
log
@updates, add 3gp encoding to ffmeg_encoder
@
text
@d891 1
a891 1
		$name=&mkname($count);
@


1.117
log
@updates
@
text
@d37 1
a37 1
$version="0.9.8-cvs";
@


1.116
log
@updates
@
text
@d448 3
d2255 1
d3288 4
@


1.115
log
@capture external window updates pt 3
@
text
@d245 2
a246 2
	&rc_set_if_not_set("default_height",240);
	&rc_set_if_not_set("default_width",320);
@


1.114
log
@capture external window updates pt 1
@
text
@d2195 8
d2205 19
d3703 1
a3703 1
    #if $arate<0, we will insert silence (not tested)
d3932 3
@


1.113
log
@updates
@
text
@d269 2
a270 13
	# test for mplayer mf syntax
	system("mplayer -mf on >/tmp/.smog.mptest 2>/dev/null</dev/null");
	$test=`grep deprecated /tmp/.smog.mptest`;
	if (!($test eq "")) {
	    &rc_set("mplayer_mf_version",2);
	}
	else {
	    &rc_set("mplayer_mf_version",1);
	}
	unlink "/tmp/.smog.mptest";
	
	#"-vo jpeg:options"
	
@


1.112
log
@various optimisations
@
text
@d2852 10
a2861 11
	if (-f "$curtmpdir/audio.orig") {
	    unlink "$curtmpdir/audio";
	    rename "$curtmpdir/audio.orig","$curtmpdir/audio";
	    unlink "$curtmpdir/audio.bak";
	}
	else {
	    if (-f "$curtmpdir/audio.bak") {
		unlink "$curtmpdir/audio";
		rename "$curtmpdir/audio.bak","$curtmpdir/audio";
	    }
	}
d2863 2
@


1.111
log
@fixes and code cleanup
@
text
@d530 6
a535 21
	$frames=-2;

	if (defined(open IN,"< header2")) {
	    read IN,$val,4;

	    # TODO - do not assume, store endianness in header !
	    $endian=&get_endian;
	    $frames=&getint($val);
	    read IN,$title,256;
	    read IN,$author,256;
	    read IN,$comment,256;
	}

	$title=~ tr/\x00//d;
	$author=~ tr/\x00//d;
	$comment=~ tr/\x00//d;

	# very old backups didn't have a header2
	if (! -f "header2") {
	    if (!($nfile eq "")) {
		unlink <event.*>;
d537 28
a564 5
		if (-f "audio") {
		    $frames--;
		}
		if (-f "header") {
		    $frames--;
a565 5
		
		opendir DIR,$curtmpdir;
		@@length=readdir(DIR);
		$frames+=scalar(@@length);
		closedir DIR;
a566 1
	}
d568 7
a574 3
	# leave headers for restoring VJ sets
	if ($leave_headers==1) {
	    $fsize=0;
d578 1
d1334 1
a1334 1
	if (($count==$xframes+1)&&(($frames eq "")||(!($frames eq "") && ($count<$ARGV[4])||($ARGV[3]==0)))) {
d1364 1
a1364 1
	unless ($ss eq ""||$achans==0) {
@


1.110
log
@audio rendering rewrite pt 2
@
text
@d484 11
d843 3
a845 3
		`rm /tmp/.smogval*`;
		`rm -r *`;
		`rm .*`;
d1522 1
a1522 1
			    `rm -f $origaudio`;
d1754 1
a1754 1
	system("for i in *.tar; do tar -xf \$i 2>/dev/null; rm \$i; done");
d2073 1
a2073 1
	    system("cp $curtmpdir/audio $curtmpdir/audio.bak");
d2859 5
d4389 1
a4389 1
    unlink <*.mgk *.bak *.pre *.tmp pause>;
d4863 1
a4863 1
			system("mv $file $new_temp/");
d4870 1
a4870 1
			`rm -r $file`;
d4879 1
a4879 1
			    system("mv $file $new_temp/");
d4887 1
a4887 1
			system("mv $file $new_temp/");
d4895 2
a4896 2
    `rm .* 2>/dev/null`;
    `rm /tmp/.smogval* 2>/dev/null`;
@


1.109
log
@various fixes
@
text
@a673 84
	if ($command eq "render_append_audio") {
	    #during rendering we append audio segments onto a growing audio file
	    $handle=$ARGV[1];

	    # current values
	    $nrate=$ARGV[2];
	    $nchans=$ARGV[3];
	    $samps=$nsamps=$ARGV[4];
	    $nsigned=$ARGV[5];
	    $nendian=$ARGV[6];

	    # new audio segment values
	    $handle2=$ARGV[7];
	    $start=$ARGV[8];
	    $end=$ARGV[9];

	    $arate=$ARGV[10];
	    $achans=$ARGV[11];
	    $asamps=$ARGV[12];
	    $asigned=$ARGV[13];
	    $aendian=$ARGV[14];

	    $where=$ARGV[15];

	    $stretch=$ARGV[16];

	    $reverse=0;
	    if ($stretch<0) {
		#need to append in reverse
		$stretch=-$stretch;
		$reverse=1;
		$tmp=$end;
		$end=$start;
		$start=$tmp;
	    }

	    # clip the new audio from $start to $end
	    $curtmpdir="$tmpdir/$handle2";
	    $audio_out=&clip_audio($start,$end);

	    # resample new audio (if required)
	    unless ($arate==$nrate&&$achans==$nchans&&$asamps==$nsamps&&$nsigned==$asigned&&$nendian==$aendian&&$stretch==1.) {
		$audio_in=$audio_out;
		$audio_out=$audio_in.".bak";
		&resample_audio;
		unlink $audio_in;
		rename $audio_out,$audio_in;
		$audio_out=$audio_in;
	    }

	    $curtmpdir="$tmpdir/$handle";

	    #insert silence up to $where
	    $audiofile="$curtmpdir/audio";
	    $desired_length=$where*$nrate*$nchans*$samps/8;
	    &append_silence($desired_length,$audiofile);

	    if ($reverse==1) {
		$align=$nchans*$samps/8;
		open IN,"< $audio_out";
		while (read IN,$bytes,$align) {
		    unshift (@@array,$bytes);
		}
		close IN;
		unlink $audio_out;
		open OUT,"> $audio_out";
		foreach $bytes (@@array) {
		    print OUT $bytes;
		}
		close OUT;
	    }

	    #append new audio
	    `cat $audio_out >> $audiofile`;
	    unlink ($audio_out);
	    
	    $fsize=-s $audiofile;
	    &sig_complete($fsize);
	    exit 0;

	}



@


1.108
log
@various fixes
@
text
@d299 1
a299 1
	open OUT,"> $tmpdir/test" or exit 5;
d301 1
a301 1
	unlink "$tmpdir/test";
@


1.107
log
@record audio events
@
text
@d2543 4
a2546 3
		$end=($end-$start+1.)/$fps;
		$start=0.;
		$where/=$fps;
@


1.106
log
@mt audio rendering fixes
@
text
@d698 11
d715 1
a715 1
	    unless ($arate==$nrate&&$achans==$nchans&&$asamps==$nsamps&&$nsigned==$signed&&$nendian==$endian) {
d731 15
@


1.105
log
@new test output plugins
@
text
@d242 1
a242 1
	&rc_set_if_not_set("lives_warning_mask",3072);
d263 1
@


1.104
log
@multitrack audio
@
text
@d1181 1
a1181 1
	&sig_complete_auio;
@


1.103
log
@update to 0.9.8-cvs, threaded dialog mutexes
@
text
@d263 1
d673 58
d2048 1
d2092 1
a2092 1
	if (!($arate==$nrate&&$achans==$nchans&&$asamps==$nsamps&&$nsigned==$signed&&$nendian==$endian)) {
d2508 1
a2508 1
		$start=($start-1)/$fps;
d2516 1
a2516 1
		$end=($end-$start+1)/$fps;
@


1.102
log
@fixes/mt filter map finder
@
text
@d37 1
a37 1
$version="0.9.7-cvs";
@


1.101
log
@mt updates
@
text
@d1122 1
a1122 1
	&sig_complete_audio;
d1201 1
a1201 1
		    $syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo jpeg:quality=$quality -fps 100000 $ss $frames -noframedrop -ao null \"$file\" $extra_params > $curtmpfile 2>/dev/null</dev/null";
d1204 1
a1204 1
		    $syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo png:z=$compression -fps 100000 $ss $frames -noframedrop -ao null \"$file\" $extra_params > $curtmpfile 2>/dev/null</dev/null";
d1209 1
a1209 1
		    $syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo jpeg:quality=$quality $ss -noframedrop $frames -ao pcm $channs -mc 0  \"$file\" $extra_params > $curtmpfile 2>/dev/null</dev/null";
d1212 1
a1212 1
		    $syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo png:z=$compression $ss -noframedrop $frames -ao pcm $channs -mc 0  \"$file\" $extra_params > $curtmpfile 2>/dev/null</dev/null";
@


1.100
log
@updates
@
text
@d263 3
d4865 4
a4868 2
		if ($file =~ /^recovery/) {
		    system("mv $file $new_temp/");
@


1.99
log
@fix for improved file opening
@
text
@d3385 1
a3385 1
                $count=$fps*$length;
d3451 1
a3451 10

    if ($asamps =~/le$/) {
	$endian=1;
    }
    elsif ($asamps =~/be$/) {
	$endian=0;
    }
    else {
	$endian=&get_endian; # assume audio endian matches machine endian
    }
@


1.98
log
@fix mono mpeg encoding
@
text
@a452 6
	    $command="get_details_remote";
	}
	else {
	    &get_file_info;
	    &sig_complete($handle,$count,$type,$hsize,$vsize,$bpp,$fps,$f_size,$arate,$achans,$asamps,$signed,$endian,$af_size,$title,$author,$comment);
	    exit 0;
d454 3
d1223 1
a1223 4
	    $type=$info[1];
	    if ($type=~ m/^\[/) {
		$type=substr($type,1,-1);
	    }
a2320 6
	if ($command eq "get_details_remote") {
	    &get_file_info;
	    &sig_complete($handle,$count,$type,$hsize,$vsize,$bpp,$fps,$f_size,$arate,$achans,$asamps,$signed,$endian,$af_size,$title,$author,$comment);
	    exit 0;
	}

d3250 9
a3258 3
	$id_vid_form=`grep ID_VIDEO_FORMAT $file_ident 2>/dev/null`;
	$id_vid_form=(split("=",(split("\n",$id_vid_form))[0]))[1];
	chomp($id_vid_form);
d3381 9
d3471 4
@


1.97
log
@multrect part 1
@
text
@d1558 1
a1558 3
		unless ($areq&2) {
		    $fields.=" $arate $achans $asamps $ssigned";
		}
@


1.96
log
@load files with strange audio values
@
text
@d3450 10
a3459 1
    $endian=&get_endian; # assume audio endian matches machine endian
@


1.95
log
@load files with strange audio values
@
text
@a3262 2
    $file_ident="./test.txt";

@


1.94
log
@updates
@
text
@d3240 1
a3240 1
    $signed=1;
d3263 2
d3306 5
d3355 9
d3443 7
a3449 5
    if ($asamps==8) {
	$signed=0;
    }
    else {
	$signed=1;
a3462 5
    # mplayer may force the channs to 2 regardless
    # TODO - uncomment this in case of problems
    #if ($achans>0) {
	#$achans=2;
    #}
@


1.93
log
@jack startup fix
@
text
@d1192 1
a1192 1
	    if ($achans eq "") {
@


1.92
log
@post 0.9.6 fixes
@
text
@d253 1
a253 1
	&rc_set_if_not_set("jack_opts",0);
@


1.91
log
@update to 0.9.6 full
@
text
@d37 1
a37 1
$version="0.9.6-cvs";
@


1.90
log
@multitrack improvements
@
text
@d889 13
d2687 18
@


1.89
log
@multitrack/render preferences
@
text
@d242 1
a242 1
	&rc_set_if_not_set("lives_warning_mask",3096);
@


1.88
log
@multitrack improvements
@
text
@d256 1
d258 5
@


1.87
log
@event_list updates
@
text
@d256 1
@


1.86
log
@optimise delete all audio
@
text
@d758 11
a768 6
		    my $exe=`readlink -n /proc/$1/exe`;
		    my $short_exe=&my_basename($exe);
		    unless ($short_exe eq $exename) {
			print $file;
			closedir DIR;
			exit 0;
@


1.85
log
@tempdir changes, final part
@
text
@a3758 1
    `touch $audio_temp; chmod 600 $audio_temp`;
d3760 2
a3761 10
    $align=$achans*$asamps/8;

    # step 1
    $spos=&align($arate*$align*$start);
    $epos=&align($arate*$align*$end);

    my ($fsize)=&align(-s $audio_in);

    if ($epos>$fsize) {
	$epos=$fsize;
d3763 40
a3802 1
    if ($spos>$epos) {
d3804 13
a3817 37

    $seekstart=$spos;
    my ($size)=$spos;
    
    if ($size>0) {
	$fblocks=int($size/32);
	$rblocks=$size-($fblocks*32);
	system("dd if=$audio_in of=$audio_temp bs=32 count=$fblocks >/dev/null 2>&1");
	system("dd if=$audio_in of=$audio_temp bs=1 count=$rblocks skip=".($fblocks*32)." seek=".($fblocks*32)." >/dev/null 2>&1");
    }

    #step 2
    $size=($epos-$spos);

    if ($size>0) {
	$fblocks=int($size/32);
	$rblocks=$size-($fblocks*32);
	system("dd if=$audio_in of=$audio_bak bs=32 skip=".int($spos/32)." count=$fblocks >/dev/null 2>&1");
	system("dd if=$audio_in of=$audio_bak bs=1 count=$rblocks skip=".($spos+$fblocks*32)." seek=".($fblocks*32)." >/dev/null 2>&1");
    }


    #step 3
    $spos=$epos;
    $epos=$fsize;
    $size=($epos-$spos);
    
    if ($size>0) {
	$fblocks=int($size/32);
	$rblocks=$size-($fblocks*32);
	system("dd if=$audio_in of=$audio_temp bs=32 count=$fblocks skip=".int($spos/32)." seek=".int($seekstart/32)." >/dev/null 2>&1");
	system("dd if=$audio_in of=$audio_temp bs=1 count=$rblocks skip=".($spos+$fblocks*32)." seek=".($seekstart+$fblocks*32)." >/dev/null 2>&1");
    }

    # step 4
    unlink $audio_in;
    rename "$audio_temp", "$audio_in";
@


1.84
log
@smogrify fix
@
text
@a459 1
	    `touch $curtmpdir/.order`;
d719 21
a739 8
	if ($command eq "get_next_in_set") {
	    # this is a special function for lives-exe. It will look for 
	    # clips on the disk that have the marker file "set.$name"
	    $last=$ARGV[1];
	    $setname=$ARGV[2];
	    $pid=$ARGV[3];
	    if (defined($ARGV[4])) {
		$quickload=$ARGV[4];
d741 5
a745 4
	    else {
		$quickload=0;
	    }
	    $found="";
a746 1
	    $srchdir="";
a747 4
	    if (-d "$tmpdir/$setname/clips") {
		#new style set exists, good
		$srchdir="$setname/clips";
	    }
d749 15
a763 8
	    opendir DIR,"$tmpdir/$srchdir";
	    if ($quickload==1) {
		@@sorted_files=readdir(DIR);
	    }
	    else {
		while ($file=readdir(DIR)) {
		    unless ($file =~ /^\./) {
			$hash{$file}=sprintf("%020d",(stat("$tmpdir/$srchdir/$file/.order"))[8]);
a765 1
		@@sorted_files = sort {$hash{$a} cmp $hash{$b}} keys %hash;
d767 18
a784 1
	    closedir DIR;
d786 1
a786 4
	    foreach my $subdir (@@sorted_files) {
		unless ($srchdir eq "") {
		    $subdir="$srchdir/$subdir";
		}
d788 8
a795 8
		    if ($last eq "none") {
			$found=$subdir;
			last;
		    }
		    if ($last eq $subdir) {
			$last="none";
		    }
		}
d799 13
a811 2
		$found="none";
	    }
a812 2
	    $infofile="$tmpdir/.info.$pid";
	    `sync;sync;sync`;
a813 8
	    if (-d $tmpdir) {
		open OUT,"> $infofile";
		print OUT $found;
		close OUT;
	    }
	    exit 0;
	}
	
d860 17
d3259 1
a3259 1
	    if ($asamps =~ /^s*/) {
d4593 8
d4769 4
a4772 5
	unless ($file =~ /^\./ || ($file eq "layouts"&& (!defined($new_temp)||$new_temp eq "") ) ) {
	    $in_set=0;
	    if (chdir "$tmpdir/$file") {
		$fullfile=$file;
		if (-d "$tmpdir/$file/clips/") {
d4774 3
a4776 6
		    $file.="/clips";
		}
		find (\&fndset,"$tmpdir/$file/");
		chdir $tmpdir;
		if (!$in_set) {
		    `rm -r $file`;
d4779 4
a4782 3
		    chdir $file;
		    unless (-f "noprune") {
			&prune;
d4784 9
a4792 3
		    chdir $tmpdir;
		    unless (!defined($new_temp)||$new_temp eq "") {
			system("mv $fullfile $new_temp/");
d4796 5
d4804 1
a4804 1
    chdir $tmpdir;
@


1.83
log
@header.lives changes pt 2
@
text
@d1130 1
a1130 1
		    $syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo jpeg:quality=$quality -fps 100000 $ss $frames -noframedrop -ao null \"$file\" $extra_params > $curtmpfile 2>/dev/null</dev";
@


1.82
log
@header.lives changes
@
text
@d552 1
a552 1
	    unlink <header*>;
d1672 1
a1672 1
	unless (-f "header.tar"||-f "header") {
@


1.81
log
@header.lives changes
@
text
@d4467 1
d4504 1
d4526 9
a4534 4
	while (<IN>) {
	    if ($part==1&&$_=~ /(<\/$key>)$/) {
		close IN;
		return $string;
d4536 3
a4538 9
	    if ($part==1||$_=~ /^(<$key>)/) {
		if ($part==1) {
		    $_=~ s/\n//g;
		    $string.=$_;
		}
		else {
		    $part=1;
		    $string=$2;
		}
d4541 1
@


1.80
log
@updates/tmpdir reshuffle
@
text
@d294 7
a300 1
    
d323 8
d460 1
a460 1
	    `touch $tmpdir/.order`;
d724 1
a724 1
	    $name=$ARGV[2];
d726 6
d734 3
a736 1
	    if (-d "$tmpdir/$name/clips") {
d738 6
a743 2
		opendir DIR,"$tmpdir/$name/clips";
		$newstyle=1;
d746 6
a751 2
		opendir DIR,$tmpdir;
		$newstyle=0;
a752 1
	    my @@allfiles = readdir DIR;
a754 3
	    foreach (@@allfiles) { $hash{$_}=sprintf("%020d",(stat("$tmpdir/$_/.order"))[8])};
	    @@sorted_files = sort {$hash{$a} cmp $hash{$b}} keys %hash;

d756 7
a762 3
                unless ($subdir =~ /^\./) {
		    if ($newstyle==1) {
			$subdir="$name/clips/$subdir";
d764 2
a765 8
		    if (-f "$tmpdir/$subdir/set.$name") {
			if ($last eq "none") {
			    $found=$subdir;
			    last;
			}
			if ($last eq $subdir) {
			    $last="none";
			}
d4413 2
a4414 3
    if (&rc_get($key) eq "") {
	&rc_set($key,$value);
    }
d4434 4
d4465 7
a4471 1
		if ($part==1||$_=~ /(.*)(<$key>)(.*)/) {
d4484 1
a4484 1
		    if ($string=~ /(.*)(<\/$key>)(.*)/) {
d4515 4
d4525 1
a4525 1
	    if ($part==1&&$_=~ /(.*)(<\/$key>)/) {
d4529 1
a4529 1
	    if ($part==1||$_=~ /(<$key>)(.*)/) {
@


1.79
log
@multitrack layout updates
@
text
@d714 9
a722 1
	    opendir DIR,$tmpdir;
d731 3
d4679 5
d4696 1
a4696 1
			system("mv $file $new_temp/");
@


1.78
log
@fix set ordering
@
text
@d242 1
a242 1
	&rc_set_if_not_set("lives_warning_mask",0);
d4665 1
a4665 1
	unless ($file =~ /^\./ || $file eq "layouts") {
@


1.77
log
@updates
@
text
@d442 1
d444 1
d446 1
d715 8
a722 2
	    while (defined($subdir=readdir(DIR))&&$found eq "") {
		unless ($subdir =~ /^\./) {
d726 1
a733 1
	    closedir DIR;
d2612 1
a2612 2
    $len=length ($num);
    $ret=substr("00000000",$len) . $num;
d4220 1
a4220 1
    unlink <*.mgk *.bak *.pre pause>;
@


1.76
log
@mp3 opening fix
@
text
@d4657 1
a4657 1
	unless ($file =~ /^\./) {
@


1.75
log
@updates
@
text
@d2199 1
a2199 1
	if ($ext eq ".ogg") {
d2202 1
a2202 1
	if ($ext eq ".wav") {
d4018 8
a4025 2
	system("mpg123 -w $audio_in --rate 44100 --stereo \"$file\" >/dev/null 2>&1");
	$f_size=-s $audio_in;
d4037 1
d4049 5
d4113 1
a4113 1
    system(&rc_get("video_open_command") . " -quiet \"$file\" -ao pcm:nowaveheader:file=$audio_in $format >/dev/null 2>&1</dev/null");
@


1.74
log
@extra_frame
@
text
@d1631 1
a1631 1
	system("for i in `ls *.tar 2>/dev/null`; do tar -xf \$i 2>/dev/null; rm \$i; done");
d3122 1
d3249 2
@


1.73
log
@extra_frame
@
text
@a229 1
	&rc_set_if_not_set("mplayer_extra_frame",0);
d1202 1
a1202 1
	if (&rc_get("mplayer_extra_frame")&&(($frames eq "")||(!($frames eq "") && ($count<$ARGV[4])||($ARGV[3]==0)))) {
@


1.72
log
@image opening fix
@
text
@d230 1
a230 1
	&rc_set_if_not_set("mplayer_extra_frame",1);
@


1.71
log
@image opening regression fix
@
text
@d1071 5
a1075 1
	unless ($type eq "jpeg" || $type eq "png") {
a1125 1
	}
d1127 3
a1129 11
	if (! -d $curtmpdir) {
	    #curtmpdir can be removed by cancel
	    exit 1;
	}

	# double check number of frames
	$found=0;
	for ($i=$count;$i>0&&$found==0;$i--) {
	    $name=&mkname($i);
	    if (-f "$name$img_ext") {
		$found=$i;
d1131 4
a1134 5
	}

	if ($count==$found) {
	    #check for extra frames
	    for ($i=$count+1;$found==$i-1;$i++) {
a1139 2
	}
	$count=$found;
d1141 17
a1157 5
	unless ($type eq "jpeg"||$type eq "png"||$type eq "Frames"||$count>0) {
	    opendir DIR,$curtmpdir;
	    while ($file=readdir(DIR)) {
		if ($file =~ /$img_ext$/) {
		    $count++;
d1159 1
a1160 1
	    closedir DIR;
d1162 1
a1162 1
	
a3286 3
		if ($count>1) {
		    $type="Frames";
		}
@


1.70
log
@jack audio updates
@
text
@d255 1
a1069 1

d1071 2
d1074 2
a1075 12
	$frames=$xframes;

	if ($achans eq "") {
	    $channs="";
	}
	else {
	    $channs="-channels $achans";
	}

	if ($withsound eq "0") {
	    if ($img_ext eq ".jpg") {
		$syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo jpeg:quality=$quality -fps 100000 $ss $frames -noframedrop -ao null \"$file\" $extra_params > $curtmpfile 2>/dev/null</dev";
d1078 1
a1078 1
		$syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo png:z=$compression -fps 100000 $ss $frames -noframedrop -ao null \"$file\" $extra_params > $curtmpfile 2>/dev/null</dev/null";
d1080 8
a1087 4
	}
	else {
	    if ($img_ext eq ".jpg") {
		$syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo jpeg:quality=$quality $ss -noframedrop $frames -ao pcm $channs -mc 0  \"$file\" $extra_params > $curtmpfile 2>/dev/null</dev/null";
d1090 6
a1095 1
		$syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo png:z=$compression $ss -noframedrop $frames -ao pcm $channs -mc 0  \"$file\" $extra_params > $curtmpfile 2>/dev/null</dev/null";
d1097 25
a1123 25
	if (defined($DEBUG_OPEN)) {
	    print STDERR "open command for $handle is: $syscom\n";
	}
	
	system($syscom);

	@@info=split /  /, `grep VIDEO: $curtmpfile`;
	@@info2=split / /, `grep AUDIO: $curtmpfile`;

	unlink $curtmpfile;
	$type=$info[1];
	if ($type=~ m/^\[/) {
	    $type=substr($type,1,-1);
	}
	
	$size=$info[2];
	$hsize=(split /x/,$size)[0];
	$vsize=(split /x/,$size)[1];
	$bpp=$info[3];
	chomp($bpp);
	$fps=(split / /,$info[4])[0];

	$arate=$info2[1];
	$achans=$info2[3];

@


1.69
log
@jack audio part 3
@
text
@d1887 1
a1887 1
	$audio_in="audiodump";
d1898 1
a1898 2
	elsif ($type eq "wav")  {
	    $audio_in="audiodump.wav";
d2189 1
a2189 1
	$audio_in=$curtmpdir."/audiodump";
@


1.68
log
@bugfixes/event updates
@
text
@d3323 1
a3323 1
    if (&rc_get("audio_player") eq "sox") {
d3328 1
a3328 1
	system(&rc_get("video_open_command") . " -quiet $audio_in -ao pcm -nowaveheader $format -aofile $audio_out >/dev/null 2>&1");
d3440 45
a3484 5
    if (&rc_get("audio_player") eq "mplayer") {
	my ($aasamps)=$asamps/8;
	# doesn't work...
	$format=&get_mplayer_format;
	system(&rc_get("video_open_command") . " -quiet -ao pcm -rawaudio on:rate=$arate:channels=$achans:samplesize=$aasamps -nowaveheader $format -vo null $audio_in >/dev/null 2>&1</dev/null");
d3487 1
a3487 49
	if ($asamps==8) {
	    $osamps="b";
	}
	else {
	    $osamps="w";
	}
	
	
	if ($nsamps==8) {
	    $nsamps="b";
	}
	else {
	    $nsamps="w";
	}

	if ($asigned==1) {
	    $osigned="-s";
	}
	else {
	    $osigned="-u";
	}
	
	if ($nsigned==1) {
	    $nsigned="-s";
	}
	else {
	    $nsigned="-u";
	}
	
	if ($aendian==$endian) {
	    $oendian="";
	}
	else {
	    $oendian="-x";
	}
	
	if ($nendian==$endian) {
	    $nendian="";
	}
	else {
	    $nendian="-x";
	}
	
	if (defined($stretch)) {
	    system("sox -t raw -r $arate -c $achans $osigned -$osamps $oendian $audio_in -t raw -r $nrate -c $nchans $nsigned $nendian -$nsamps $audio_out stretch $stretch>/dev/null 2>&1");
	}
	else {
	    system("sox -t raw -r $arate -c $achans $osigned -$osamps $oendian $audio_in -t raw -r $nrate -c $nchans $nsigned $nendian -$nsamps $audio_out>/dev/null 2>&1");
	}
d3493 1
d4098 1
a4098 1
    system(&rc_get("video_open_command") . " -quiet \"$file\" -ao pcm -nowaveheader $format -aofile $audio_in >/dev/null 2>&1</dev/null");
d4175 1
a4175 1
	    return "-format 16";
d4177 1
a4177 1
	return "-format 8";
d4181 1
a4181 1
	    return "-format 64";
d4183 1
a4183 1
	return "-format 32";
d4186 1
a4186 1
	return "-format 256";
d4188 1
a4188 1
    return "-format 128";
@


1.67
log
@add layout_blends/RFX layout tweaks
@
text
@d258 1
a258 1
	system("mplayer -mf on >/tmp/.smog.mptest 2>/dev/null");
d1074 7
d1083 1
a1083 1
		$syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo jpeg:quality=$quality -fps 100000 $ss $frames -noframedrop -ao null \"$file\" $extra_params > $curtmpfile 2>/dev/null";
d1086 1
a1086 1
		$syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo png:z=$compression -fps 100000 $ss $frames -noframedrop -ao null \"$file\" $extra_params > $curtmpfile 2>/dev/null";
d1091 1
a1091 1
		$syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo jpeg:quality=$quality $ss -noframedrop $frames -ao pcm -channels $achans -mc 0  \"$file\" $extra_params > $curtmpfile 2>/dev/null";
d1094 1
a1094 1
		$syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo png:z=$compression $ss -noframedrop $frames -ao pcm -channels $achans -mc 0  \"$file\" $extra_params > $curtmpfile 2>/dev/null";
a1147 1

d1817 1
a1817 1
	system("$mplayer_command -quiet -x $hsize -y $vsize -wid $win -ss $start_time -frames $preview_frames \"$file\" $extra_params >/dev/null 2>&1");
d3121 1
a3121 1
	system("$mplay_command -identify -v -vo null -ao null -frames 0 -cache 32 \"$file\">$file_ident 2>/dev/null");
d3124 1
a3124 1
	system("$mplay_command -identify -v -vo null -ao null -frames 0 \"$file\">$file_ident 2>/dev/null");
d3206 1
a3206 1
	  
d3340 1
a3340 1
	system(&rc_get("video_open_command") . " -quiet -ao pcm -rawaudio on:rate=$arate:channels=$achans:samplesize=$aasamps -waveheader $format -vo null $audio_in >/dev/null 2>&1");
d3444 1
a3444 1
	system(&rc_get("video_open_command") . " -quiet -ao pcm -rawaudio on:rate=$arate:channels=$achans:samplesize=$aasamps -nowaveheader $format -vo null $audio_in >/dev/null 2>&1");
d4068 1
a4068 1
    system("$mplay_command -frames 0 $audio_in > $curtmpfile 2>/dev/null");
d4105 1
a4105 1
    system(&rc_get("video_open_command") . " -quiet \"$file\" -ao pcm -nowaveheader $format -aofile $audio_in >/dev/null 2>&1");
@


1.66
log
@updates
@
text
@d37 1
a37 1
$version="0.9.6-pre1";
@


1.65
log
@rendered effects preview
@
text
@d37 1
a37 1
$version="0.9.6-cvs";
@


1.64
log
@updates
@
text
@a1472 1
		&sig_progress($i);
d1478 1
a1499 1
		&sig_progress($i);
d1502 1
a1559 1
		&sig_progress(int($start+($i-$start)/4));
d1562 1
a1566 1
		&sig_progress(int($start+($end-$start)/4));
d1572 1
a1577 1
		&sig_progress($start+($i-$start));
d1590 1
a1661 1
		&sig_progress($fcount++);
d1680 1
a2416 1
	    &sig_progress($i);
d2450 1
a2654 3
	if ($option==1) {
	    &sig_progress($i);
	}
d2666 3
a2687 1
	&sig_progress($i);
d2694 1
a2741 1
	&sig_progress($start+($i-$start)*2);
d2744 2
a2746 1
	rename $curtmpdir."/.revtemp",$curtmpdir."/".$to.$img_ext;
a2792 1
	&sig_progress($num_frames-$i);
d2798 1
a2808 1
	    &sig_progress(int($num_frames-$where+$j++-$start+1));
d2820 1
a3953 1
	&sig_progress($i);
d3985 1
@


1.63
log
@update
@
text
@d2471 1
@


1.62
log
@fix buggy opening of mono clips (finally)
@
text
@d2463 7
d2479 4
a2482 1
	    $out_ext=".mgk";
a2491 1
	    &clean_old;
d2524 4
a2527 2
		&mv_mgk;
		&sig_complete($nwidth,$nheight);
d2554 4
a2557 2
		&mv_mgk;
		&sig_complete($nwidth,$nheight);
d4197 1
a4197 1
    unlink <*.mgk *.bak pause>;
@


1.61
log
@RFX spec updates
@
text
@d1068 6
d1084 1
a1084 1
		$syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo jpeg:quality=$quality $ss -noframedrop $frames -ao pcm -mc 0  \"$file\" $extra_params > $curtmpfile 2>/dev/null";
d1087 1
a1087 1
		$syscom=$mplay_command . " -quiet $band -osdlevel 0 -vo png:z=$compression $ss -noframedrop $frames -ao pcm -mc 0  \"$file\" $extra_params > $curtmpfile 2>/dev/null";
a1114 1
	$asamps=$info2[5];
a1119 5
	&get_file_info;
	if (! -d $curtmpdir) {
	    #curtmpdir can be removed by cancel
	    exit 1;
	}
@


1.60
log
@cleanup somgrify
@
text
@d776 1
a776 1
		$plugin_name="$home/lives/plugins/effects/rendered/custom/$command";
d779 1
a779 1
		$plugin_name="$home/lives/plugins/effects/rendered/test/$command";
d2477 1
a2477 1
		$plugin_name="$home/lives/plugins/effects/rendered/custom/$command";
d2480 1
a2480 1
		$plugin_name="$home/lives/plugins/effects/rendered/test/$command";
d2527 1
a2527 1
			($nwidth,$nheight)=split($size," ");
d2536 1
a2536 1
			@@err=split($errt,"\n");
@


1.59
log
@allow up to 64 virtual realtime effect keys
@
text
@a11 1
$rfx_builder="build-lives-rfx-plugin";
d88 1
a88 1
		if (!($uid==@@stat[4]&&$gid==@@stat[5])) {
d712 1
a712 1
	    while (($subdir=readdir(DIR))&&$found eq "") {
d782 1
a782 1
	    @@ARGV[0]="onchange_init";
a929 4
	$frames_played=0;
       	$thread=1;

	$vid_start=($start-1.)/$fps;
a1059 2
	$got_audio=0;

d2237 1
a2237 1
		    $file=@@length[$filetoplay];
a2246 1
			    $l=length($file);
d2502 1
a2502 1
		@@ARGV[0]="process";
d3159 1
a3159 1
		$bpp=substr(@@tmp[5],1,2);
d3216 1
a3216 1
	    $count=@@tmp[2];
d3569 1
a3569 1
    my ($audio_from)=$audio_from;
d3576 2
a3577 2
	    system("dd if=$audio_from of=$audio_to bs=32 count=$fblocks skip=".int($nspos/32)." seek=".int($nwpos/32)." >/dev/null 2>&1");
	    system("dd if=$audio_from of=$audio_to bs=1 count=$rblocks skip=".($nspos+$fblocks*32)." seek=".($nwpos+$fblocks*32)." >/dev/null 2>&1");
d3596 1
a3596 1
	    $audio_from=$audio_to;
a3761 1
	$skip=0;
d3872 1
a3872 1
	$bppstr=@@info[4];
d3874 3
a3876 3
	$bpp=@@bpp[0];
	@@sizestr=split /\+/,@@info[2];
	@@size=split /x/,@@sizestr[0];
d3878 2
a3879 2
	$hsize=@@size[0];
	$vsize=@@size[1];
d4123 1
a4123 1
	return (((@@val[3]*256+@@val[2])*256+@@val[1])*256)+@@val[0];
d4126 1
a4126 1
	return (((@@val[0]*256+@@val[1])*256+@@val[2])*256)+@@val[3];
@


1.58
log
@add jack integration tab in preferences
@
text
@d219 4
d224 4
a229 2
	&rc_set_if_not_set("audio_play_command",$audio_play_command);
	&rc_set_if_not_set("audio_player",$audio_player);
a245 3
	&rc_set_if_not_set("midisynch","false");
	&rc_set_if_not_set("conserve_space","false");
	&rc_set_if_not_set("insert_resample","true");
a249 2
	&rc_set_if_not_set("gui_theme","editor");
	&rc_set_if_not_set("antialias","true");
d254 1
a254 2
	# resize action when opening images - can be one of: "bound", "default" or "none"
	&rc_set_if_not_set("image_resize_action","none");
d256 1
@


1.57
log
@updates
@
text
@d255 1
@


1.56
log
@update to 0.9.6-cvs
@
text
@d888 1
a904 1

a993 1

d3152 4
@


1.55
log
@sync with 0.9.5 test release
@
text
@d38 1
a38 1
$version="0.9.5";
@


1.54
log
@WEED_PLUGIN_PATH
@
text
@d38 1
a38 1
$version="0.9.5-cvs";
@


1.53
log
@updates
@
text
@d552 1
a552 1
	if ($in_home) {
d555 3
@


1.52
log
@updates
@
text
@d4433 2
a4434 2
    my ($rcfile)=$home."/".$rc_filename;
    my ($string)="";
d4442 4
d4448 1
d4453 1
a4453 5
		    $string.=$2;
		}
		$string=~ s/\n//g;
		if ($string=~ /(.*)(<\/$key>)/) {
		    return $1;
d4457 2
@


1.51
log
@eliminate pause before disk file opening
@
text
@d3291 4
a3294 3
    if ($achans>0) {
	$achans=2;
    }
@


1.50
log
@smogrify fixes, including ogg stream playing
@
text
@a426 3

	# only open the first image if it's a directory
	# otherwise it is too slow
a427 1
	&get_file_info;
d429 9
a437 2
	&sig_complete($handle,$count,$type,$hsize,$vsize,$bpp,$fps,$f_size,$arate,$achans,$asamps,$signed,$endian,$af_size,$title,$author,$comment);
	exit 0;
d2208 5
d3102 8
a3109 1
    system("$mplay_command -identify -v -vo null -ao null -frames 0 -cache 32 \"$file\">$file_ident 2>/dev/null");
@


1.49
log
@events system update
@
text
@d992 1
a992 1
		$syscom2=$audio_play_command . " -slave -rawaudio on:rate=" . $arate . ":channels=" . $achans . ":samplesize=" . $asamps . " " . $mute . " " . $audiofile . " -ss ".($audio_start-1)." >/dev/null 2>&1";
d1070 1
a1070 1
		$syscom=$mplay_command . " -quiet -slave $band -osdlevel 0 -vo jpeg:quality=$quality -fps 100000 $ss $frames -noframedrop -ao null \"$file\" $extra_params > $curtmpfile 2>/dev/null";
d1073 1
a1073 1
		$syscom=$mplay_command . " -quiet -slave $band -osdlevel 0 -vo png:z=$compression -fps 100000 $ss $frames -noframedrop -ao null \"$file\" $extra_params > $curtmpfile 2>/dev/null";
d1078 1
a1078 1
		$syscom=$mplay_command . " -quiet -slave $band -osdlevel 0 -vo jpeg:quality=$quality $ss -noframedrop $frames -ao pcm -mc 0  \"$file\" $extra_params > $curtmpfile 2>/dev/null";
d1081 1
a1081 1
		$syscom=$mplay_command . " -quiet -slave $band -osdlevel 0 -vo png:z=$compression $ss -noframedrop $frames -ao pcm -mc 0  \"$file\" $extra_params > $curtmpfile 2>/dev/null";
d1811 1
a1811 1
	system("$mplayer_command -quiet -slave -x $hsize -y $vsize -wid $win -ss $start_time -frames $preview_frames \"$file\" $extra_params >/dev/null 2>&1");
d3094 1
a3094 1
    system("$mplay_command -identify -v -slave -vo null -ao null -frames 0 \"$file\">$file_ident 2>/dev/null");
d3292 1
a3292 1
	system(&rc_get("video_open_command") . " -quiet -slave $audio_in -ao pcm -nowaveheader $format -aofile $audio_out >/dev/null 2>&1");
d3304 1
a3304 1
	system(&rc_get("video_open_command") . " -quiet -slave -ao pcm -rawaudio on:rate=$arate:channels=$achans:samplesize=$aasamps -waveheader $format -vo null $audio_in >/dev/null 2>&1");
d3408 1
a3408 1
	system(&rc_get("video_open_command") . " -quiet -slave -ao pcm -rawaudio on:rate=$arate:channels=$achans:samplesize=$aasamps -nowaveheader $format -vo null $audio_in >/dev/null 2>&1");
d3795 3
a3797 1
    if ($file_ext eq ".avi"||$file_ext eq ".mp4"||$file_ext eq ".mpg") {
d4033 1
a4033 1
    system("$mplay_command -slave -frames 0 $audio_in > $curtmpfile 2>/dev/null");
d4070 1
a4070 1
    system(&rc_get("video_open_command") . " -quiet -slave \"$file\" -ao pcm -nowaveheader $format -aofile $audio_in >/dev/null 2>&1");
@


1.48
log
@realtime recording updates pt 1
@
text
@d1073 1
a1073 1
		$syscom=$mplay_command . " -quiet -slave $band -osdlevel 0 -vo png -z $compression -fps 100000 $ss $frames -noframedrop -ao null \"$file\" $extra_params > $curtmpfile 2>/dev/null";
d1081 1
a1081 1
		$syscom=$mplay_command . " -quiet -slave $band -osdlevel 0 -vo png -z $compression $ss -noframedrop $frames -ao pcm -mc 0  \"$file\" $extra_params > $curtmpfile 2>/dev/null";
@


1.47
log
@change long double to long for timing
@
text
@d4557 9
a4565 3
	unless ($old_version eq $version||&location("build-lives-plugin-multi") eq "") {
	    `build-lives-plugin-multi custom`;
	    `build-lives-plugin-multi test`;
@


1.46
log
@show progress when resampling/reordering
@
text
@d4552 5
@


1.45
log
@audio loop cleanup
@
text
@d1656 1
d1662 1
@


1.44
log
@remove vid player mplayer, improve clean_diskspace,fix rippleTV
@
text
@d1007 2
@


1.43
log
@smogrify fix (omitted from last release)
@
text
@a24 1
$video_player="internal";
a187 1
	$video_play_command="- internal -";
a219 2
	&rc_set_if_not_set("video_player",$video_player);
	&rc_set_if_not_set("video_play_command",$video_play_command);
d698 1
a698 1
	    # clips on the disk that have the marker file "set.uid.gid"
a829 1
	$play_vid=1;
a835 4
	if ($fps<0) {
	    $fps=-$fps;
	    $play_vid=0;
	}
a846 1
	$loops=" ";
a848 5
	    $loops=" -loop 0 ";
	    if ($start!=1) {
		$loop*=2;
		$loops=" ";
	    }
a928 32
	# if playing a preview, we want to play *all* the .mgk files
	if ($img_ext eq ".mgk") {
	    $vid_start="0.";
	}

	$frames=" -frames ".($end-$start+1)." ";
	if ($end==0) {
	    $frames=" ";
	}

	if ($play_vid) {
	    $video_player=&rc_get("video_player");
	    $mplay_command=&rc_get("video_play_command");
	    $mf_ver=&rc_get("mplayer_mf_version");
	    if (defined($DEBUG_VID_PLAYER)) {
		$vid_err="";
	    }
	    else {
		$vid_err=">/dev/null 2>&1";
	    }
	    # mplayer -mf format changed twice in version 1.0pre
	    if ($mf_ver==2) {
		$syscom="$mplay_command $fs $loops -quiet -osdlevel 0 -slave -mf type=jpg:fps=$fps:h=$vsize:w=$hsize $wid -ao null -ss $vid_start $frames mf://$curtmpdir/*$img_ext $vid_err";
	    }
	    else {
		$syscom=$mplay_command . $fs . $loops . " -quiet -osdlevel 0 -slave -mf on -mf type=jpg:fps=" . $fps . $wid . " -ao null " . $height . $width . "-ss " . $vid_start . $frames . $curtmpdir . "/\\*" . $img_ext . $vid_err;
	    }
	    if (defined($DEBUG_VID_PLAYER)) {
		print "video play com is $syscom\n";
	    }
	}

a994 1
	    $thread=fork();
d996 3
a998 6
	else {
	    if ($play_vid) {
		system ($syscom);
		&sig_complete_video;
	    }
	    if (! -d "$curtmpdir" || -f "$curtmpdir/.stoploop") {
a1000 23
	    if ($loop<0) {
		# continuous loop audio
		do {
		    # wait for this process to be killed
		    sleep 60;
		    if (! -d "$curtmpdir" || -f "$curtmpdir/.stoploop") {
			$loop=0;
		    }
		} while ($loop);
		&sig_complete_audio;
		if ($play_vid) {
		    &stop;
		}
	    }
	    exit 0;
	}
	
	if ($thread) {
	    if ($play_vid) {
		system($syscom);
		&sig_complete_video($frames_played);
		exit 0;
	    }
d1002 1
a1002 2
		# if using internal player, just exit
		exit 0;
d1004 2
a1005 9
	    
	} else {
	    do {
		system($syscom2);
		if (! -d "$curtmpdir" || -f "$curtmpdir/.stoploop" || ! -f $audiofile) {
		    $loop=0;
		}
	    } while ($loop<0);
	    &sig_complete_audio;
d1007 1
a1007 5
	    if ($loop && $play_vid) {
		&stop;
	    }
	    exit 0;
	}
d1011 1
a1011 1
    if ($command eq "open") {
d4589 1
a4589 1
    my $start_total=(split / /, `du -sb 2>/dev/null`)[0];
d4603 5
d4616 1
d4619 1
a4619 1
    my $end_total=(split / /, `du -sb 2>/dev/null`)[0];
d4623 9
@


1.42
log
@i18n fixes
@
text
@d3182 6
d3193 7
@


1.41
log
@make sure all files have license/copyright
@
text
@d759 1
a759 21
		use File::Find;
		opendir DIR,$tmpdir;
		while ($file=readdir(DIR)) {
		    unless ($file =~ /^\./) {
			$in_set=0;
			if (chdir "$tmpdir/$file") {
			    find (\&fndset,"$tmpdir/$file/");
			    chdir $tmpdir;
			    if (!$in_set) {
				`rm -r $file`;
			    }
			    else {
				unless ($new_temp eq "") {
				    system("mv $file $new_temp/");
				}
			    }
			}
		    }
		}
		closedir DIR;
		`rm .*`;
d2627 6
d4658 32
@


1.40
log
@fix crash with bg/fn key
@
text
@d4 1
a4 1
# Released under the GPL 2.0 - see file COPYING for details
@


1.39
log
@smogrify update
@
text
@d210 8
a217 1
	
@


1.38
log
@fix for wrong sized images from mplayer
@
text
@d2115 1
a2115 1
	@@wid=split(/\s/,$win_id);
@


1.37
log
@Net/Open BSD fix
@
text
@d1256 4
@


1.36
log
@Net/Open BSD fix
@
text
@d4374 1
@


1.35
log
@fix bug in smogrify when upgrading
@
text
@d4360 1
@


1.34
log
@fix debug output for encoding
@
text
@d4622 1
a4622 1
	unless ($old_version eq $version||&get_location("build-lives-plugin-multi") eq "") {
@


1.33
log
@fix breakage in smogrify, perl code needs to be stricter
@
text
@a1455 3
	    else {
		$DEBUG_ENCODERS=0;
	    }
d1517 6
d1525 1
a1525 1
		$fields.=" $DEBUG_ENCODERS";
@


1.32
log
@fix regressions
@
text
@a5 1
package smogrify;
@


1.31
log
@updates
@
text
@d1970 1
a1970 1
	$audio_in="audiodump.wav";
d1982 1
d2165 3
a2167 2
	$audio_out="$curtmpdir/audio";
	$audio_bak="$curtmpdir/audio.bak";
d2169 1
a2169 1
	$file=$audio_in="$curtmpdir/audiodump.wav";
d2189 1
a2189 1
	    $audio_in="$curtmpdir/audiodump";
d2220 2
a2221 2
	# remove the audio file in audiodump.wav
	# plus any audio.* files (e.g. from append audio)
d2225 1
a2225 1
	unlink <audiodump*>;
d2273 1
a2273 1
	$audio_in=$curtmpdir."/audiodump.wav";
d2283 1
@


1.30
log
@audio open/append fix, allow new formats
@
text
@d3 1
a3 1
# smogrify - Copyright G. Finch 2003
d6 1
@


1.29
log
@fix typo
@
text
@d1980 3
d1984 1
a1984 1
	    &wav_open;
a2264 1

d2266 1
d2282 3
a2290 35
    if ($command eq "mp3open") {
	unlink "$curtmpdir/pause";

	$file=$ARGV[2];
	$audio_in=$curtmpdir."/audiodump.wav";

	&mp3_open;

	&sig_complete($arate,$achans,$asamps,$asigned,$aendian,$f_size);
	exit 0;
    }

    if ($command eq "oggopen") {
	unlink "$curtmpdir/pause";

	$file=$ARGV[2];
	$audio_in=$curtmpdir."/audiodump.wav";

	&ogg_open;
	&sig_complete($arate,$achans,$asamps,$asigned,$aendian,$f_size);
	exit 0;
    }

    if ($command eq "wavopen") {
	unlink "$curtmpdir/pause";

	$file=$ARGV[2];
	$audio_in=$curtmpdir."/audiodump.wav";

	&wav_open;
	&sig_complete($arate,$achans,$asamps,$asigned,$aendian,$f_size);
	exit 0;
    }


d4126 13
@


1.28
log
@RFX tweaks
@
text
@d4633 3
a4635 2
	`build-lives-plugin-multi custom`;
	`build-lives-plugin-multi test`;
a4636 1

@


1.27
log
@run RFX post-loop code on cancel/keep
@
text
@d4632 3
@


1.26
log
@gcc 2.9.x fix
@
text
@d68 1
a68 1
    if ($command eq "cancel" ) {
d94 6
a99 1
		system("kill -9 $target_pid 2>/dev/null");
d1604 1
a1604 1
	system("smogrify cancel $handle");
d2658 1
a2672 1

@


1.25
log
@BSD fix killall/pkill
@
text
@d4364 2
a4365 1
    if (`uname` =~ /BSD$/) {
d4377 2
a4378 1
	if (`uname` =~ /BSD$/) {
@


1.24
log
@remove dependency on mplayer
@
text
@d4364 6
a4369 1
    system("killall -HUP -g smogrify >/dev/null 2>&1");
d4376 6
a4381 1
	system("killall -9 sox >/dev/null 2>&1");
a4384 1

@


1.23
log
@various fixes, update to post 0.9.1
@
text
@d3219 1
a3219 1
	    
d3302 17
a3318 11
	# see if it is image(s)

	&open_images(1);
	opendir DIR,$curtmpdir;
	while ($file2=readdir(DIR)) {
	    if ($file2 =~ /$img_ext$/) {
		$count++;
		$imresact="none";
		if ($only_first) {
		    unlink "$curtmpdir/$file2";
		    last;
d3321 3
a3323 1
		    $f_size+=-s $file2;
d3326 14
a3339 3
	    else {
		unless ($file2 eq $audio_in) {
		    unlink $file2;
d3341 2
a3344 19

	closedir DIR;
	if ($count) {
	    # got image(s)
	    $frames=$count;
	    # got image(s)
	    if ($img_ext eq ".jpg") {
		$type="jpeg";
	    }
	    else {
		$type="png";
	    }
	    
	    if ($count>1) {
		$type="Frames";
	    }
	    $count=0;
	    $name=&mkname(1);
	}
@


1.22
log
@update smogrify mplayer open cmd
@
text
@d39 1
a39 1
$version="0.9.1-pre7-cvs";
d243 1
a243 1
	&rc_set_if_not_set("encoder_acodec",0); # default of PCM
@


1.21
log
@fps accuracy
@
text
@d1162 1
a1162 1
		$syscom=$mplay_command . " -quiet -slave $band -osdlevel 0 -vo jpeg -jpeg quality=$quality -fps 100000 $ss $frames -noframedrop -ao null \"$file\" $extra_params > $curtmpfile 2>/dev/null";
d1170 1
a1170 1
		$syscom=$mplay_command . " -quiet -slave $band -osdlevel 0 -vo jpeg -jpeg quality=$quality $ss -noframedrop $frames -ao pcm -mc 0  \"$file\" $extra_params > $curtmpfile 2>/dev/null";
@


1.20
log
@atomic resample/resize
@
text
@d1757 4
a1760 1
			system("cp $from$img_ext $to.mgk");
d4176 3
@


1.19
log
@autoresample pt 1
@
text
@d1576 1
d1578 3
a1580 3
	    my $end=$ARGV[2];
	    my $width=$ARGV[2];
	    my $height=$ARGV[2];
d1585 1
d1589 1
d1724 6
a1729 1
	    $newwidth=$ARGV[4];
d1736 3
a1738 1
	&clean_old;
d2741 9
a2749 2
	    if (-f "$curtmpdir/$name$img_ext") {
		rename "$curtmpdir/$name$img_ext","$curtmpdir/$name.bak";
a2750 2
	    rename "$curtmpdir/$name.mgk","$curtmpdir/$name$img_ext";
	}
@


1.18
log
@fix bug on fresh install startup
@
text
@d1573 3
d1577 14
d1717 6
d1725 1
d1741 8
a1748 1
		    system("cp $from$img_ext $to.mgk");
@


1.17
log
@usability fixes
@
text
@d461 1
a461 1
	system("$convert_command $curtmpdir/$name$img_ext \"$nfile\"");
d2893 1
a2893 1
	system("$convert_command +antialias -size $width"."x$height $name$input_ext -scale $width!x$height! $name$resize_ext");
d2896 1
a2896 1
	system("$convert_command -size $width"."x$height $name$input_ext -resize $width!x$height! $name$resize_ext");
d2952 1
a2952 1
	system("$convert_command +antialias -size $width"."x$height $name$input_ext -crop $nwidth" . "!x" . $nheight . "!+" . $left . "+" . $top . " $name$resize_ext");
d2955 1
a2955 1
	system("$convert_command +antialias -size $width"."x$height $name$input_ext -crop $nwidth" . "!x" . $nheight . "!+" . $left . "+" . $top . " $name.$resize_ext");
d2958 1
a2958 1
    system("$convert_command -size $nwidth"."x$nheight $name$resize_ext -resize ".int($nwidth*$rscale)."!x".int($nheight*$rscale)."! $name.tmp");
d2960 1
a2960 1
    system("$convert_command -size ".int($nwidth*$rscale)."x".int($nheight*$rscale)." $name.tmp -crop $width" . "!x" . $height . "!+" . int((int($nwidth*$rscale)-$width-.5)/2) . "+" . int((int($nheight*$rscale)-$height-.5)/2) . " $name$resize_ext");
d2979 1
a2979 1
	system("$convert_command +antialias -size $width"."x$height $name$input_ext -crop $nwidth!x$nheight!+$x+$y $name$resize_ext");
d2982 1
a2982 1
	system("$convert_command -antialias -size $width"."x$height $name$input_ext -crop $nwidth!x$nheight!+$x+$y $name$resize_ext");
d3011 2
a3012 2
	system("$convert_command -size $size!x$size! xc:$bgcolour blank.jpg");
	system("$composite_command -compose plus -dissolve 100 -geometry $hsize!x$vsize!+$xstart!+$ystart! $name$input_ext blank.jpg $name$input_ext");
d3019 1
a3019 1
    system("$convert_command $name$input_ext -crop $width" . "!x" . $height . "!+" . $x . "+" . $y . " $name$resize_ext");
d3035 1
a3035 1
	    system("$convert_command +antialias -size $width"."x$height $fromimg -scale $width!x$height! resize.png");
d3038 1
a3038 1
	    system("$convert_command -size $width"."x$height $fromimg -resize $width!x$height! resize.png");
d3041 1
a3041 1
	system("$convert_command -size $width!x$height! xc:transparent -matte blank.png");
d3043 1
a3043 1
	    system("$convert_command resize.png -threshold $threshold mask.png");
d3046 1
a3046 1
	    system("$convert_command resize.png -threshold ".(65535-$threshold)." -negate mask.png");
d3048 3
a3050 3
	system("$composite_command resize.png blank.png mask.png output.png");
	system("$composite_command -compose plus -dissolve $pc_start -geometry +$x!+$y! output.png $curtmpdir/$name$img_ext $toimg.jpg");
	system("$convert_command +matte $toimg.jpg $toimg");
d3058 1
a3058 1
	    system("$convert_command +antialias -size $width"."x$height $fromimg -scale $width!x$height! resize.png");
d3061 1
a3061 1
	    system("$convert_command -size $width"."x$height $fromimg -resize $width!x$height! resize.png");
d3064 2
a3065 2
	system("$convert_command $curtmpdir/$name$img_ext resize2.png");
	system("$convert_command -size $owidth!x$oheight! xc:transparent -matte blank.png");
d3067 1
a3067 1
	    system("$convert_command -threshold ".($threshold_plus)." resize2.png mask.png");
d3070 1
a3070 1
	    system("$convert_command -threshold ".(65536-$threshold_plus)." -negate resize2.png mask.png");
d3073 1
a3073 1
	system("$composite_command resize2.png blank.png mask.png output.png");
d3076 2
a3077 2
	    system("$composite_command -compose plus -dissolve $pc_start -geometry -$x!-$y! output.png resize.png $toimg.png");
	    system("$composite_command -geometry +$x!+$y! $toimg.png resize2.png $toimg.jpg");
d3080 1
a3080 1
	    system("$composite_command -compose plus -dissolve $pc_start -geometry -$x!-$y! output.png resize.png $toimg.jpg");
d3083 1
a3083 1
	system("$convert_command +matte $toimg.jpg $toimg");
d3977 1
a3977 1
		    system("$convert_command -crop $width" . "!x" . $height . "! $nextname$img_ext $nextname.mgk");
@


1.16
log
@fix for save selection audio clipping
@
text
@d40 1
a40 2
$img_ext=".jpg"; # can be .jpg or .png (untested; only mpeg encoder will work)
#TODO - get $img_ext from <default_image_format> in ~/.lives
d3154 2
a3155 1
	
d3159 1
d3171 2
a3172 1
	    $asamps=`cat $file_ident | grep AUDIO: 2>/dev/null`;
d3176 2
a3177 1
	    $bpp=`cat $file_ident | grep VIDEO: 2>/dev/null`;
d3181 1
d3183 1
a3183 1
		$bpp=`cat $file_ident | grep \"Image size:\" 2>/dev/null`;
d3188 2
a3189 1
	    $hsize=`cat $file_ident | grep ID_VIDEO_WIDTH 2>/dev/null`;
d3193 2
a3194 1
	    $vsize=`cat $file_ident | grep ID_VIDEO_HEIGHT 2>/dev/null`;
d3198 2
a3199 1
	    $fps=`cat $file_ident | grep ID_VIDEO_FPS 2>/dev/null`;
d3203 2
a3204 1
	    $arate=`cat $file_ident | grep ID_AUDIO_RATE 2>/dev/null`;
d3208 2
a3209 1
	    $achans=`cat $file_ident | grep ID_AUDIO_NCH 2>/dev/null`;
d3213 2
a3214 1
	    $abitrate=`cat $file_ident | grep ID_AUDIO_BITRATE 2>/dev/null`;
d3218 2
a3219 1
	    $comment=`cat $file_ident | grep Comments: 2>/dev/null`;
d3225 2
a3226 1
	    $title=`cat $file_ident | grep Title: 2>/dev/null`;
d3232 2
a3233 1
	    $title=`cat $file_ident | grep Author: 2>/dev/null`;
d3239 2
a3240 1
	    $count=`cat $file_ident | grep \"frames  total\" 2>/dev/null`;
a3884 1
    #TODO use @@words
@


1.15
log
@nice fixes for encoding
@
text
@d656 4
d1427 14
d1461 3
a1463 5
		$audiofile=$audio_in="$curtmpdir/audio";
		if ($areq&1) {
		    $aud_start=($start-1)/$fps;
		    $aud_end=$end/$fps;
			
d1476 11
@


1.14
log
@build updates part 1
@
text
@d1473 1
a1473 1
		    for ($i=1;$i<=$end;$i++) {
d1476 1
a1476 1
			if ($i<$start) {
d1480 1
a1480 1
			    system ("/bin/ln -s $from$img_ext $name$img_ext");
d1519 32
@


1.13
log
@stability/OSC/autolives
@
text
@a10 1
$gui_bootstrap_file="/tmp/.smogrify";
d39 1
a39 1
$version="0.9.1-pre7";
d50 1
a51 1
$gui_bootstrap_file.=".".$uid.".".$gid;
a58 1
	$home=&get_home_dir;
a175 8
    if ($command eq "get_homedir") {
	$id=$ARGV[1];
	open OUT,"> /tmp/.smogrify.$id" or exit 1;
	print OUT "$home";
	close OUT;
	exit 0;
    }

d178 5
a182 2
	if (defined($ARGV[1])&&!($ARGV[1] eq "")) {
	    $home=$ARGV[1];
d184 2
a185 1
	    $firsttime=0;
d187 2
a188 5
	    $video_open_command=&location("mplayer");
	    $video_play_command="- internal -";

	    $audio_player="sox";
	    $audio_play_command=&rc_get_default("sox_command");
d190 15
a204 80
	    $real_convert_command=(split(" ",$convert_command))[0];
	    $convert_version=`$real_convert_command | grep -i version`;
	    $convert_version=(split(" ",$convert_version))[2];
	    $convert_version_hash=&version_hash($convert_version);

	    if ($audio_play_command eq "") {
		$audio_player="mplayer";
		$audio_play_command=&rc_get_default("mplayer_audio_command");
	    }

	    # get $tmpdir from .rc file, if no .rc file, create it
	    if (! -s "$home/$rc_filename") {
		# set comment at start of file
		&rc_set("","");
		$firsttime=1;
	    }

	    &rc_set_if_not_set("version",$version);
	    &rc_set_if_not_set("tempdir",$default_tmpdir);
	    &rc_set_if_not_set("video_open_command",$video_open_command);
	    &rc_set_if_not_set("open_compression_percent",25);
	    &rc_set_if_not_set("video_player",$video_player);
	    &rc_set_if_not_set("video_play_command",$video_play_command);
	    &rc_set_if_not_set("encoder",$encoder);
	    &rc_set_if_not_set("output_type","mjpeg");
	    &rc_set_if_not_set("audio_play_command",$audio_play_command);
	    &rc_set_if_not_set("audio_player",$audio_player);
	    &rc_set_if_not_set("audio_effect","none");
	    &rc_set_if_not_set("mplayer_extra_frame",1);
	    &rc_set_if_not_set("default_image_format","jpeg");
	    &rc_set_if_not_set("default_fps",25);
	    &rc_set_if_not_set("bgcolour","black");
	    &rc_set_if_not_set("vid_load_dir","/usr/local/");
	    &rc_set_if_not_set("vid_save_dir","/usr/local/");
	    &rc_set_if_not_set("image_dir","/usr/local/");
	    &rc_set_if_not_set("proj_dir","/usr/local/");
	    &rc_set_if_not_set("audio_dir","/usr/local/");
	    &rc_set_if_not_set("save_directories","false");
	    &rc_set_if_not_set("stop_screensaver","true");
	    &rc_set_if_not_set("open_maximised","true");
	    &rc_set_if_not_set("show_recent_files","true");
	    &rc_set_if_not_set("lives_warning_mask",0);
	    &rc_set_if_not_set("dl_bandwidth_K",64);
	    &rc_set_if_not_set("midisynch","false");
	    &rc_set_if_not_set("conserve_space","false");
	    &rc_set_if_not_set("insert_resample","true");
	    &rc_set_if_not_set("show_player_stats","false");
	    &rc_set_if_not_set("default_height",240);
	    &rc_set_if_not_set("default_width",320);
	    &rc_set_if_not_set("show_toolbar","true");
	    &rc_set_if_not_set("gui_theme","editor");
	    &rc_set_if_not_set("antialias","true");
	    &rc_set_if_not_set("PAL/NTSC","PAL");
	    &rc_set_if_not_set("debug_encoders","false");
	    &rc_set_if_not_set("encoder_acodec",0); # default of PCM

	    # resize action when opening images - can be one of: "bound", "default" or "none"
	    &rc_set_if_not_set("image_resize_action","none");

	    # test for mplayer mf syntax
	    system("mplayer -mf on >/tmp/.smog.mptest 2>/dev/null");
	    $test=`grep deprecated /tmp/.smog.mptest`;
	    if (!($test eq "")) {
		&rc_set("mplayer_mf_version",2);
	    }
	    else {
		&rc_set("mplayer_mf_version",1);
	    }
	    unlink "/tmp/.smog.mptest";

	    #"-vo jpeg:options"
	    
	    $tmpdir=&rc_get("tempdir");
	    &save_home_dir;
	    
	    $convert_old_version=&rc_get("convert_version");
	    unless ($convert_old_version eq $convert_version) {
		&rc_set("convert_version",$convert_version);
	    }
	    &version_check_and_upgrade;
d207 48
d256 19
a274 5
	    # we didn't get the home directory...that's baaaaaddd....
	    $tmpdir=$default_tempdir;
	    unlink $gui_bootstrap_file;
	    open OUT,">> $gui_bootstrap_file" or exit 4;
	    print OUT "unknown\n$version|$tmpdir|0|smogrify error|Home directory was not found";
a277 4
	open OUT,">> $gui_bootstrap_file" or exit 4;
	print OUT "$version|$tmpdir|$firsttime|$msg|$msg2";
	close OUT;

d4379 3
a4381 2
sub save_home_dir {
    # save the home directory in a temp file - for use later to find .rc file
a4384 1
    print OUT "$home\n";
d4386 2
d4389 1
d4394 5
a4398 3
	    open OUT,">> $gui_bootstrap_file" or exit 4;
	    print OUT "$version|$tmpdir|$msg|$msg2";
	    close OUT;
d4414 1
a4414 8
    # get the home directory which we wrote in save_home_dir
    my ($string);
    open IN,"< $gui_bootstrap_file";
    read IN,$string,256;
    close IN;

    $string=~ /(.*)\n(.*)/;
    $1;
@


1.12
log
@stability fixes
@
text
@d1283 1
a1283 1
		&sig_complete($handle,$count,$type,$hsize,$vsize,$bpp,$fps,$f_size,$arate,$achans,$asamps,$signed,$endian,$af_size,$title,$author,$comment."xxx");
@


1.11
log
@fix cvs breakage
@
text
@d1283 1
a1283 1
		&sig_complete($handle,$count,$type,$hsize,$vsize,$bpp,$fps,$f_size,$arate,$achans,$asamps,$signed,$endian,$af_size,$title,$author,$comment);
@


1.10
log
@stability, encoder audio fix
@
text
@d171 1
@


1.9
log
@switch libvis palette to RGB24, update version to pre7
@
text
@d1473 1
a1473 1
		    $desired_length=$aud_length*$arate*$achans*$asamps;
@


1.8
log
@patches
@
text
@d40 1
a40 1
$version="0.9.1-pre6";
@


1.7
log
@more encoder plugin enhancements
@
text
@d502 3
d1132 1
a1134 1
	    $band="";
d1137 7
a1143 3
	    $bandwidth=&rc_get("dl_bandwidth_K");
	    if ($bandwidth eq "") {
		$bandwidth=64;
a1144 1
	    $band="-bandwidth $bandwidth"."000";
d4079 1
@


1.6
log
@encoder plugin enhancements
@
text
@d66 1
a66 1
	    print "command is $command\n";
d324 5
d670 1
a670 1
		    #unlink <audiodump.wav audioclip>;
d1184 1
a1184 1
	    print "open command for $handle is: $syscom\n";
d1398 2
a1399 1
	    
d1495 1
d2560 2
a2561 3

	if (caller) {
	    print "smogrify: unrecognised command $command\n";
d2580 2
a2581 2
    print "$command must have a parameter\n";
    print "show usage...\n";
d4365 1
a4365 1
	print "Smogrify: Unable to read values from rc file, $rcfile\n";
@


1.5
log
@colourspace fixes, etc
@
text
@d1492 2
a1493 1
		$fields="$fps \"$nfile\" $start $end $img_ext $otype $atype";
a1496 1
		$fields.=" $DEBUG_ENCODERS";
@


1.4
log
@various fixes, inc. livido generator stability
@
text
@d665 1
a665 1
		    unlink <audiodump.wav audioclip>;
@


1.3
log
@
	Fixes for livido generators
@
text
@d340 5
d1426 5
@


1.2
log
@updates
@
text
@d248 1
a248 1
	    &rc_set_if_not_set("gui_theme","camera");
@


1.1
log
@Initial revision
@
text
@d266 1
d268 1
a268 1
	    unlink "/tmp/.smog.mptest";
@


1.1.1.1
log
@Initial Import
@
text
@@
