This study proposes a dual-stream spatiotemporal attention framework to address the challenges of pose interference and category imbalance in in-the-wild pain assessment, termed Residual Convolutional Block Attention Bidirectional Long Short-Term Memory Network (ResCBL-Net), for pain recognition on imbalanced video data. At the artificial intelligence algorithm level, the framework utilizes a Residual Network (ResNet) embedded with a Convolutional Block Attention Module (CBAM) to extract key spatial features, thereby enhancing focus on pain-related regions and suppressing irrelevant interference, while integrating a stacked Bidirectional Long Short-Term Memory (BiLSTM) network to capture temporal dynamic changes in facial expressions. To mitigate the long-tail distribution problem, an improved Dynamically Weighted Composite Focus (DWCF) loss function is introduced to optimize the discriminatory performance of minority classes from the algorithmic foundation. Concurrently, Gradient-weighted Class Activation Mapping (Grad-CAM) is integrated to provide intuitive and easily understandable visual explanations for the decision-making process of the framework. From an engineering application perspective, the study addresses the challenges of deployment and is very robust and transparent in a complex real world environment, creating a very good, non-invasive solution. Experimental results show that the method obtains a high accuracy of 99.67% on the balanced data set, and 85% on the imbalanced data set, which is enough to prove the effectiveness of the method in a real-world application for the long-tail dataset, thereby providing sufficient technical support for clinical intelligent monitoring.