A method of encoding image frames in a video sequence, said image frames being encoded into a sequence of output image frames arranged in groups of pictures, each group of pictures comprising an intra-frame and one or more subsequent inter-frames, each group of pictures in said sequence of output image frames having a key frame distance defined by a number of frames separating the intra-frame and a subsequent inter-frame directly referencing the intra-frame, the method comprising: encoding a plurality of video test sequences, each video test sequence having a respective noise level, wherein each video test sequence is encoded using a respective quantisation parameter and using a plurality of key frame distances, for each video test sequence determining an output bitrate for each key frame distance, storing, for each combination of noise level, quantisation parameter, and key frame distance, the determined output bitrate, for each such combination of noise level and quantisation parameter, identifying as maximum permissible key frame distance a maximum key frame distance at which output bitrate decreases in response to an increase in key frame distance, for each combination of noise level and quantisation parameter storing the maximum permissible key frame distance in a look-up table, determining a noise level of at least one image frame in said video sequence, determining a representative quantisation parameter, representative of one or more quantisation parameters, with which said image frames are to be encoded, based on the determined noise level and the determined representative quantisation parameter, selecting a maximum permissible key frame distance from the look up table, encoding the image frames in the video sequence based on the determined representative quantisation parameter and using a key frame distance which is less than or equal to the selected maximum permissible key frame distance. encoding a plurality of video test sequences, each video test sequence having a respective noise level, wherein each video test sequence is encoded using a respective quantisation parameter and using a plurality of key frame distances, for each video test sequence determining an output bitrate for each key frame distance, storing, for each combination of noise level, quantisation parameter, and key frame distance, the determined output bitrate, for each such combination of noise level and quantisation parameter, identifying as maximum permissible key frame distance a maximum key frame distance at which output bitrate decreases in response to an increase in key frame distance, for each combination of noise level and quantisation parameter storing the maximum permissible key frame distance in a look-up table, determining a noise level of at least one image frame in said video sequence, determining a representative quantisation parameter, representative of one or more quantisation parameters, with which said image frames are to be encoded, based on the determined noise level and the determined representative quantisation parameter, selecting a maximum permissible key frame distance from the look up table, encoding the image frames in the video sequence based on the determined representative quantisation parameter and using a key frame distance which is less than or equal to the selected maximum permissible key frame distance.