An
encoder and method for encoding a media
signal is presented. The
encoder is configured to perform a first-pass encoding of the media
signal with restricting the first-pass encoding onto a set of frames out of a sequence of immediately consecutive frames of the media
signal and using a probe quantization parameter, QP, for each of the set of frames of the media signal, so as to obtain a first-pass bitrate for each of the set of frames, determine, based on the first-pass bitrate for each of the set of frames, a start QP for each of the sequence of immediately consecutive frames; and perform a second-pass encoding of the media signal with using the start QP for each of the sequence of immediately consecutive frames, wherein the sequence of immediately consecutive frames is a
group of pictures having a hierarchical referencing structure with temporal
layers including a temporal base layer 0 up to a highest temporal layer N-1 and the
encoder is configured to select the set of frames out of the sequence of immediately consecutive frames so that the set of frames includes all frames of temporal
layers 0 to k-1, and, for each temporal layer k to N-1, only a proper subset of the frames of the sequence of immediately consecutive frames which belong to the respective temporal layer, wherein 1 < k < N, and / or the encoder is configured to perform scene detection to detect scene changes, and select the set of frames out of the sequence of immediately consecutive frames depending on whether any of the scene changes falls into the sequence of immediately consecutive frames so that the set of frames represents a sequentially subsampled subset of a sequence of immediately consecutive frames of the media signal in case of none of the scene changes falling into the sequence of immediately consecutive frames, and / or the encoder is configured to perform scene detection to detect scene changes separating scenes, and determine, based on the first-pass bitrate for each of the set of frames, the start QP for each of the sequence of immediately consecutive frames in a manner depending on the scene changes so that, for each of the sequence of immediately consecutive frames, the start QP is exclusively determined based on the first-pass bitrate of one or more frames within the set of frames, which fall into a scene into which the respective frame falls.