Download Latest Codecs

0 views
Skip to first unread message

Francesca Cruiz

unread,
Aug 3, 2024, 4:11:09 PM8/3/24
to nagiraca

In electronic communications, an endec is a device that acts as both an encoder and a decoder on a signal or data stream,[5] and hence is a type of codec. Endec is a portmanteau of encoder/decoder.

A coder or encoder encodes a data stream or a signal for transmission or storage, possibly in encrypted form, and the decoder function reverses the encoding for playback or editing. Codecs are used in videoconferencing, streaming media, and video editing applications.

In the mid-20th century, a codec was a device that coded analog signals into digital form using pulse-code modulation (PCM). Later, the name was also applied to software for converting between digital signal formats, including companding functions.

An audio codec converts analog audio signals into digital signals for transmission or encodes them for storage. A receiving device converts the digital signals back to analog form using an audio decoder for playback. An example of this is the codecs used in the sound cards of personal computers. A video codec accomplishes the same task for video signals.

In addition to encoding a signal, a codec may also compress the data to reduce transmission bandwidth or storage space. Compression codecs are classified primarily into lossy codecs and lossless codecs.

Lossless codecs are often used for archiving data in compressed form while retaining all information present in the original stream. If preserving the original quality of the stream is more important than eliminating the correspondingly larger data sizes, lossless codecs are preferred. This is especially true if the data is to undergo further processing (for example, editing) in which case the repeated application of processing (encoding and decoding) on lossy codecs will degrade the quality of the resulting data such that it is no longer identifiable (visually, audibly, or both). Using more than one codec or encoding scheme successively can also degrade quality significantly. The decreasing cost of storage capacity and network bandwidth has a tendency to reduce the need for lossy codecs for some media.

Many popular codecs are lossy. They reduce quality in order to maximize compression. Often, this type of compression is virtually indistinguishable from the original uncompressed sound or images, depending on the codec and the settings used.[7] The most widely used lossy data compression technique in digital media is based on the discrete cosine transform (DCT), used in compression standards such as JPEG images, H.26x and MPEG video, and MP3 and AAC audio. Smaller data sets ease the strain on relatively expensive storage sub-systems such as non-volatile memory and hard disk, as well as write-once-read-many formats such as CD-ROM, DVD, and Blu-ray Disc. Lower data rates also reduce cost and improve performance when the data is transmitted, e.g., over the internet.

Two principal techniques are used in codecs, pulse-code modulation and delta modulation. Codecs are often designed to emphasize certain aspects of the media to be encoded. For example, a digital video (using a DV codec) of a sports event needs to encode motion well but not necessarily exact colors, while a video of an art exhibit needs to encode color and surface texture well.

Audio codecs for cell phones need to have very low latency between source encoding and playback. In contrast, audio codecs for recording or broadcasting can use high-latency audio compression techniques to achieve higher fidelity at a lower bit rate.

There are thousands of audio and video codecs, ranging in cost from free to hundreds of dollars or more. This variety of codecs can create compatibility and obsolescence issues. The impact is lessened for older formats, for which free or nearly-free codecs have existed for a long time. The older formats are often ill-suited to modern applications, however, such as playback on small portable devices. For example, raw uncompressed PCM audio (44.1 kHz, 16-bit stereo, as represented on an audio CD or in a .wav or .aiff file) has long been a standard across multiple platforms, but its transmission over networks is slow and expensive compared with more modern compressed formats, such as Opus and MP3.

Many multimedia data streams contain both audio and video, and often some metadata that permits synchronization of audio and video. Each of these three streams may be handled by different programs, processes, or hardware; but for the multimedia data streams to be useful in stored or transmitted form, they must be encapsulated together in a container format.

Lower bitrate codecs allow more users, but they also have more distortion. Beyond the initial increase in distortion, lower bit rate codecs also achieve their lower bit rates by using more complex algorithms that make certain assumptions, such as those about the media and the packet loss rate. Other codecs may not make those same assumptions. When a user with a low bitrate codec talks to a user with another codec, additional distortion is introduced by each transcoding.

Audio Video Interleave (AVI) is sometimes erroneously described as a codec, but AVI is actually a container format, while a codec is a software or hardware tool that encodes or decodes audio or video into or from some audio or video format. Audio and video encoded with many codecs might be put into an AVI container, although AVI is not an ISO standard. There are also other well-known container formats, such as Ogg, ASF, QuickTime, RealMedia, Matroska, and DivX Media Format. MPEG transport stream, MPEG program stream, MP4, and ISO base media file format are examples of container formats that are ISO standardized.

This module defines base classes for standard Python codecs (encoders anddecoders) and provides access to the internal Python codec registry, whichmanages the codec and error handling lookup process. Most standard codecsare text encodings, which encode text to bytes (anddecode bytes to text), but there are also codecs provided that encode text totext, and bytes to bytes. Custom codecs may encode and decode between arbitrarytypes, but some module features are restricted to be used specifically withtext encodings or with codecs that encode tobytes.

Errors may be given to set the desired error handling scheme. Thedefault error handler is 'strict' meaning that encoding errors raiseValueError (or a more codec specific subclass, such asUnicodeEncodeError). Refer to Codec Base Classes for moreinformation on codec error handling.

Errors may be given to set the desired error handling scheme. Thedefault error handler is 'strict' meaning that decoding errors raiseValueError (or a more codec specific subclass, such asUnicodeDecodeError). Refer to Codec Base Classes for moreinformation on codec error handling.

The stateless encoding and decoding functions. These must befunctions or methods which have the same interface asthe encode() and decode() methods of Codecinstances (see Codec Interface).The functions or methods are expected to work in a stateless mode.

Incremental encoder and decoder classes or factory functions.These have to provide the interface defined by the base classesIncrementalEncoder and IncrementalDecoder,respectively. Incremental codecs can maintain state.

Register a codec search function. Search functions are expected to take oneargument, being the encoding name in all lower case letters with hyphensand spaces converted to underscores, and return a CodecInfo object.In case a search function cannot find a given encoding, it should returnNone.

While the builtin open() and the associated io module are therecommended approach for working with encoded text files, this moduleprovides additional utility functions and classes that allow the use of awider range of codecs when working with binary files:

If encoding is not None, then theunderlying encoded files are always opened in binary mode.No automatic conversion of '\n' is done on reading and writing.The mode argument may be any binary mode acceptable to the built-inopen() function; the 'b' is automatically added.

encoding specifies the encoding which is to be used for the file.Any encoding that encodes to and decodes from bytes is allowed, andthe data types supported by the file methods depend on the codec used.

Data written to the wrapped file is decoded according to the givendata_encoding and then written to the original file as bytes usingfile_encoding. Bytes read from the original file are decodedaccording to file_encoding, and the result is encodedusing data_encoding.

Uses an incremental encoder to iteratively encode the input provided byiterator. This function is a generator.The errors argument (as well as anyother keyword argument) is passed through to the incremental encoder.

Uses an incremental decoder to iteratively decode the input provided byiterator. This function is a generator.The errors argument (as well as anyother keyword argument) is passed through to the incremental decoder.

Each codec has to define four interfaces to make it usable as codec in Python:stateless encoder, stateless decoder, stream reader and stream writer. Thestream reader and writers typically reuse the stateless encoder/decoder toimplement the file protocols. Codec authors also need to define how thecodec will handle encoding and decoding errors.

Replace with backslashed escape sequences.On encoding, use hexadecimal form of Unicodecode point with formats \xhh\uxxxx \Uxxxxxxxx.On decoding, use hexadecimal form of bytevalue with format \xhh.Implemented inbackslashreplace_errors().

On decoding, replace byte with individualsurrogate code ranging from U+DC80 toU+DCFF. This code will then be turnedback into the same byte when the'surrogateescape' error handler is usedwhen encoding the data. (See PEP 383 formore.)

Register the error handling function error_handler under the name name.The error_handler argument will be called during encoding and decodingin case of an error, when name is specified as the errors parameter.

For encoding, error_handler will be called with a UnicodeEncodeErrorinstance, which contains information about the location of the error. Theerror handler must either raise this or a different exception, or return atuple with a replacement for the unencodable part of the input and a positionwhere encoding should continue. The replacement may be either str orbytes. If the replacement is bytes, the encoder will simply copythem into the output buffer. If the replacement is a string, the encoder willencode the replacement. Encoding continues on original input at thespecified position. Negative position values will be treated as beingrelative to the end of the input string. If the resulting position is out ofbound an IndexError will be raised.

c80f0f1006
Reply all
Reply to author
Forward
0 new messages