Virtual Machine (VM) resource management is crucial to satisfy the Quality of Service (QoS) demands of various multimedia services in a media cloud platform. To this end, this paper presents a VM resource allocation model that dynamically and optimally utilizes VM resources to satisfy QoS requirements of media-rich cloud services or applications. It additionally maintains high system utilization by avoiding the over-provisioning of VM resources to services or applications. The objective is to 1) minimize the number of physical machines for cost reduction and energy saving; 2) control the processing delay of media services to improve response time; and 3) achieve load balancing or overall utilization of physical resources. The proposed VM allocation is mapped into the multidimensional bin-packing problem, which is NP-complete. To solve this problem, we have designed a Mixed Integer Linear Programming (MILP) model, as well as heuristics for quantitatively optimizing the VM allocation. The simulation results show that our scheme outperforms the existing VM allocation schemes in a media cloud environment, in terms of cost reduction, response time reduction and QoS guarantee.