A method for encoding data of an original media file for playback by a user equipment in a communications network, wherein the method is implemented by a server located between the user equipment and an origin server that provides the original media file, the method comprising: receiving, from the user equipment, a request for a range of encoded data to be generated by encoding data from the original media file, wherein the original media file is a video file comprising video key frames interleaved with audio samples associated with the video frames; generating video key frame position data that indicates a position of video key frames in the original media file and a position of corresponding encoded video key frames in an encoded media file to be generated by encoding the original media file; converting, using the video key frame position data, the request for a range of encoded data into a request for a range of original data from the original media file, wherein the converting comprises: identifying a first video key frame of the range of original data required to provide to the user equipment, from the encoded data to be generated, the requested range of encoded data; determining that at least one audio sample associated with the first video key frame precedes the first video key frame in the range of original data; identifying a further video key frame that precedes the first video key frame and the associated at least one audio sample in the range of original data; and initiating the range of original data with the further video key frame; sending the request for a range of original data to the origin server so as to retrieve the range of original data; receiving the range of original data from the origin server; encoding the range of original data to generate encoded data; and providing to the user equipment, from the generated encoded data, the requested range of encoded data. receiving, from the user equipment, a request for a range of encoded data to be generated by encoding data from the original media file, wherein the original media file is a video file comprising video key frames interleaved with audio samples associated with the video frames; generating video key frame position data that indicates a position of video key frames in the original media file and a position of corresponding encoded video key frames in an encoded media file to be generated by encoding the original media file; converting, using the video key frame position data, the request for a range of encoded data into a request for a range of original data from the original media file, wherein the converting comprises: identifying a first video key frame of the range of original data required to provide to the user equipment, from the encoded data to be generated, the requested range of encoded data; determining that at least one audio sample associated with the first video key frame precedes the first video key frame in the range of original data; identifying a further video key frame that precedes the first video key frame and the associated at least one audio sample in the range of original data; and initiating the range of original data with the further video key frame; identifying a first video key frame of the range of original data required to provide to the user equipment, from the encoded data to be generated, the requested range of encoded data; determining that at least one audio sample associated with the first video key frame precedes the first video key frame in the range of original data; identifying a further video key frame that precedes the first video key frame and the associated at least one audio sample in the range of original data; and initiating the range of original data with the further video key frame; sending the request for a range of original data to the origin server so as to retrieve the range of original data; receiving the range of original data from the origin server; encoding the range of original data to generate encoded data; and providing to the user equipment, from the generated encoded data, the requested range of encoded data.