A method of video coding comprising a) dividing a sequence to be encoded into a plurality of temporal portions, each temporal portion comprising one or more frames; b) performing a trial encoding of each of the temporal portions using a plurality of different quality settings for each portion, and analysing the resulting encoded portions to determine for each temporal portion, in accordance with a plurality of encoding quality settings, data establishing the relationship between each of the quality settings and (i) a perceptual quality metric for the temporal portion and (ii) the number of bits generated by encoding the temporal portion at that quality setting, and wherein the plurality of quality settings are quantiser step size settings; c) analysing the data along with a target quality and target bit rate to choose a set of quality settings, one per temporal portion, that tends to minimise a combined quality cost for the sequence encoded using the chosen set of quality settings within the constraint that transmission of the encoded sequence at the target bit rate via a receiver buffer of a specified size and initial buffer fullness shall not cause underflow or overflow; wherein minimising a combined quality cost utilises a Viterbi algorithm with state values dependent on the receiver buffer fullness, and the paths through a Viterbi trellis are pruned, by removing paths with higher combined quality cost if more than one path converge at a state and further by removing paths that correspond to either buffer overflow or underflow, to obtain an optimum path having the lowest combined quality cost, and wherein the combined quality cost is the sum of individual quality costs, and each of the individual quality costs is a function of the amount of deviation of the perceptual quality metric of the respective encoded portion from the target quality, the function being such that the cost generally increases as the absolute value of the deviation increases; and d) encoding the sequence using the chosen quality settings; characterized in that the target bit rate has been specified, and the method further includes a step of determining the target quality that corresponds to this bit rate, where the target quality is determined by iteratively performing a plurality of trial analyses in accordance with step (c) with the specified target bit rate and a plurality of target quality values, wherein the target quality value selected is the one that reduces the amount of deviation of the perceptual quality metric from the target quality during the iteration; and the target quality is determine by (i) defining a first target quality; (ii) measuring the average perceptual quality metric and standard deviation of the perceptual quality metric obtained using this target; (iii) if the standard deviation exceeds a threshold, setting the target quality to the average perceptual quality metric obtained and repeating steps (ii) and (iii) at least once. a) dividing a sequence to be encoded into a plurality of temporal portions, each temporal portion comprising one or more frames; b) performing a trial encoding of each of the temporal portions using a plurality of different quality settings for each portion, and analysing the resulting encoded portions to determine for each temporal portion, in accordance with a plurality of encoding quality settings, data establishing the relationship between each of the quality settings and (i) a perceptual quality metric for the temporal portion and (ii) the number of bits generated by encoding the temporal portion at that quality setting, and wherein the plurality of quality settings are quantiser step size settings; c) analysing the data along with a target quality and target bit rate to choose a set of quality settings, one per temporal portion, that tends to minimise a combined quality cost for the sequence encoded using the chosen set of quality settings within the constraint that transmission of the encoded sequence at the target bit rate via a receiver buffer of a specified size and initial buffer fullness shall not cause underflow or overflow; wherein minimising a combined quality cost utilises a Viterbi algorithm with state values dependent on the receiver buffer fullness, and the paths through a Viterbi trellis are pruned, by removing paths with higher combined quality cost if more than one path converge at a state and further by removing paths that correspond to either buffer overflow or underflow, to obtain an optimum path having the lowest combined quality cost, and wherein the combined quality cost is the sum of individual quality costs, and each of the individual quality costs is a function of the amount of deviation of the perceptual quality metric of the respective encoded portion from the target quality, the function being such that the cost generally increases as the absolute value of the deviation increases; and d) encoding the sequence using the chosen quality settings; characterized in that (i) defining a first target quality; (ii) measuring the average perceptual quality metric and standard deviation of the perceptual quality metric obtained using this target; (iii) if the standard deviation exceeds a threshold, setting the target quality to the average perceptual quality metric obtained and repeating steps (ii) and (iii) at least once.