Transcoder#

Transcoder#

Transcoder Overview#

The Transcoder class provides a simple interface for transcoding video streams. It combines decoding, encoding, and muxing operations to convert video files from one format to another while preserving audio streams.

The Transcoder can be configured with various parameters to control its behavior:

Parameter

Type

Description

enc_file_path

str

Path to the input container file (source video to transcode)

muxed_file_path

str

Path to the output container file after transcoding

gpu_id

int

GPU device ID on which to perform decoding and encoding

cuda_context

int

CUDA context under which the transcoding operations are performed

cuda_stream

int

CUDA stream used by the decoder and encoder

**kwargs

dict

Encode configuration settings (codec, bitrate, preset, etc.)

Methods#

segmented_transcode(start, end)

Transcodes a specific segment of the video defined by start and end timestamps.

See segmented_transcode for detailed documentation.

segmented_transcode#

Transcodes a specific segment of the video defined by start and end timestamps.

Description#

The segmented_transcode method extracts and transcodes a specific time range from the input video. It seeks to the start time, forces an IDR frame at the beginning of the segment for independent playback, re-encodes video frames, and copies corresponding audio packets.

Syntax#

transcoder.segmented_transcode(start, end)

Method Signature#

segmented_transcode(start: float, end: float) -> None

Parameters#

Parameter

Type

Description

start

float

Start timestamp in seconds (rounded to 2 decimal places)

end

float

End timestamp in seconds (rounded to 2 decimal places)

See Also#