Objective. Cardiovascular diseases (CVDs) are a main cause of deaths all over the world. This research focuses on computer-aided analysis of phonocardiogram (PCG) signals based on deep learning that can enable improved and timely detection of heart abnormalities. The two widely used publicly available PCG datasets are from the PhysioNet/CinC (2016) and PASCAL (2011) challenges. The datasets are significantly different in terms of the tools used for data acquisition, clinical protocols, digital storages and signal qualities, making it challenging to process and analyze. Approach. In this work, we have used short-time Fourier transform-based spectrograms to learn the representative patterns of the normal and abnormal PCG signals. Spectrograms generated from both the datasets are utilized to perform four different studies: (i) train, validate and test different variants of convolutional neural network (CNN) models with PhysioNet dataset, (ii) train, validate and test the best performing CNN structure on the PASCAL dataset, as well as (iii) on the combined PhysioNet-PASCAL dataset and (iv) finally, the transfer learning technique is employed to train the best performing pre-trained network from the first study with PASCAL dataset. Main results. The first study achieves an accuracy, sensitivity, specificity, precision and F1 scores of 95.75%, 96.3%, 94.1%, 97.52%, and 96.93%, respectively, while the second study shows accuracy, sensitivity, specificity, precision and F1 scores of 75.25%, 74.2%, 76.4%, 76.73%, and 75.42%, respectively. The third study shows accuracy, sensitivity, specificity, precision and F1 scores of 92.7%, 94.98%, 89.95%, 95.3% and 94.6%, respectively. Finally, the fourth study shows a precision of 96.98% on the noisy PASCAL dataset with transfer learning approach. Significance. The proposed approach employs a less complex and relatively light custom CNN model that outperforms most of the recent competing studies by achieving comparatively high classification accuracy and precision, making it suitable for screening CVDs using PCG signals.