Content-based video analysis serves as the cornerstone for many applications: video understanding or summarization, multimedia information retrieval and data mining, etc. In our research, we aim to automatically detect anomalous events from surveillance videos (such as video monitoring traffic flow or pedestrian congestion in public spaces). Conceptually, what constitutes an anomaly varies in different video scenarios and is difficult to be defined in a general case. Our first solution is based on unsupervised clustering of object trajectories and anomalous trajectory identification in a probabilistic framework. Then we extend this solution to an arbitrary time length (any part of a complete trajectory) and multiple objects (multiple trajectories). Furthermore, we solve problems specifically in video scenarios where object trajectories cannot be extracted (e.g., crowd motion analysis). Our contributions include a novel hierarchical clustering algorithm and categorization of anomalous video events by spatiotemporal context.