One challenge in a video surveillance system is the data rate required to represent digital video. Accordingly, the use of lossy video compression at a compression ratio of 100:1, or higher, is an essential part of any distributed live video system. The ensuing distortion can interfere with the goals of surveillance by confounding both human analysis and computer vision based processing. This paper investigates the interaction between the video coding layer and target detection, and proposes methods for improving overall system effectiveness. Previous related research has focused on joint optimization of the video coding layer where several streams share the same bandwidth. Our work is distinguished from prior studies in several area: we use Gradual Decoder Refresh, rather than the traditional GOP, to enable low delay and similarly avoid the use of B frames, which necessitate frame reordering. We extend the previous work by providing the ROC curves for the detection of foreground object motion, as a function of the quantization parameter. We also consider the H.265 video coding standard, in addition to H.264. We note some surprising findings. We show that H.265 can significantly underperform H.264 in terms of Area Under Curve vs. Bitrate, and that it is possible to produce large "false alarm" blobs for moving object detection, even for a stationary, relatively noise-free source coded at low QP.