= 352 && $device_height >= 288 ) { $video_size = "352x288"; } elseif ( $device_width >= 176 && $device_height >= 144 ) { $video_size = "176x144"; } else { $video_size = "128x96"; } // Allow for margins etc $device_width -= 16; $device_height -= 16; $event_width = $event['Width']; $event_height = $event['Height']; if ( !isset( $rate ) ) $rate = reScale( RATE_SCALE, $event['DefaultRate'], ZM_WEB_DEFAULT_RATE ); $event_dir = ZM_DIR_EVENTS."/".$event['MonitorId']."/".sprintf( "%d", $eid ); $video_formats = array(); $ffmpeg_formats = preg_split( '/\s+/', ZM_FFMPEG_FORMATS ); foreach ( $ffmpeg_formats as $ffmpeg_format ) { preg_match( '/^([^*]+)(\**)$/', $ffmpeg_format, $matches ); $video_formats[$matches[1]] = $matches[1]; if ( $matches[2] == '*' ) { $default_video_format = $matches[1]; } elseif ( $matches[2] == '**' ) { $default_phone_format = $matches[1]; } } if ( isset($default_phone_format) ) { $video_format = $default_phone_format; } elseif ( isset($default_video_format) ) { $video_format = $default_video_format; } else { $video_format = $ffmpeg_formats[0]; } if ( !empty($generate) ) { $command = ZM_PATH_BIN."/zmvideo.pl -e ".$event['Id']." -f ".$video_format." -r ".sprintf( "%.2f", ($rate/RATE_SCALE) )." -S ".$video_size; if ( $overwrite ) $command .= " -o"; $generated = exec( $command, $output, $status ); } $video_files = array(); if ( $dir = opendir( $event_dir ) ) { while ( ($file = readdir( $dir )) !== false ) { $file = $event_dir.'/'.$file; if ( is_file( $file ) ) { if ( preg_match( '/-S([\da-z]+)\.(?:'.join( '|', $video_formats ).')$/', $file, $matches ) ) { if ( $matches[1] == $video_size ) { $video_files[] = $file; } } } } closedir( $dir ); } if ( isset($download) ) { header( "Content-disposition: attachment; filename=".$video_files[$download]."; size=".filesize($video_files[$download]) ); readfile( $video_files[$download] ); exit; } ?>