mendevi.decode

Perform decoding measures.

Functions

available_decoders(codec, pix_fmt)

Yield the ffmpeg encoder to decode the video from an accelerated device.

create_video_sample(codec, pix_fmt)

Generate a small sample with the given codec and pixel format.

decode(vid, **kwargs)

Decode an existing video.

decode_and_store(database, env_id, vid, **kwargs)

Decode a video file and store the result in the database.

get_decode_cmd(video, additional_filter[, ...])

Return the ffmpeg decode cmd.

try_decode_sample_encoder(sample, decoder)

Return True if ffmpeg can decode that video.

Details

mendevi.decode.available_decoders(codec: str, pix_fmt: str) tuple[str, str | None][source]

Yield the ffmpeg encoder to decode the video from an accelerated device.

mendevi.decode.create_video_sample(codec: str, pix_fmt: str) Path[source]

Generate a small sample with the given codec and pixel format.

mendevi.decode.decode(vid: Path, **kwargs: dict) tuple[str, str | None, str, dict[str]][source]

Decode an existing video.

Parameters

vidpathlib.Path

The source video file to be decoded.

**kwargsdict

Transmitted to get_decode_cmd().

Returns

cmdstr

The ffmpeg command.

activitydict[str]

The computeur activity during the decoding process.

mendevi.decode.decode_and_store(database: Path, env_id: int, vid: Path, **kwargs: dict) None[source]

Decode a video file and store the result in the database.

Parameters

databasepathlike

The path of the existing database to be updated.

env_idint

The primary integer key of the environment.

vidpathlib.Path

The path of the video to be encoded.

**kwargs

Transmitted to decode().

mendevi.decode.get_decode_cmd(video: Path, additional_filter: str, resolution: tuple[int, int] | None = None, family: str | None = None) CmdFFMPEG[source]

Return the ffmpeg decode cmd.

Parameters

videopathlib.Path

The video to be decoded. It is required to know the resolution in order to adapt the filter.

additional_filterstr

The additional video filter, (can be an empty string).

resolutiontuple[int, int], optional

The new (heigh, width) video shape.

familystr, optional

If provided, force to use a specific decoder type.

Returns

filterstr

The full ffmpeg decode bash command arguments.

Examples

>>> import cutcutcodec
>>> from mendevi.decode import get_decode_cmd
>>> video = cutcutcodec.utils.get_project_root() / "media" / "video" / "intro.webm"
>>> print(get_decode_cmd(video, additional_filter="", resolution=None))
ffmpeg -hide_banner -y -loglevel verbose -threads 1 -i /...intro.webm -vf format=rgb24 -f null -
>>> print(get_decode_cmd(video, additional_filter="", resolution=(480, 720)))
ffmpeg ... -i ...intro.webm -vf scale=h=480:w=720:sws_flags=bicubic,format=rgb24 -f null -
>>>
mendevi.decode.try_decode_sample_encoder(sample: Path, decoder: str) bool[source]

Return True if ffmpeg can decode that video.